File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 30
30
#include < dpnp_iface.hpp>
31
31
#include " queue_sycl.hpp"
32
32
33
+
34
+ static bool use_sycl_device_memory ()
35
+ {
36
+ // TODO need to move all getenv() into common dpnpc place
37
+ const char * dpnpc_memtype_device = getenv (" DPNPC_OUTPUT_DPARRAY_USE_MEMORY_DEVICE" );
38
+ if (dpnpc_memtype_device != nullptr )
39
+ {
40
+ return true ;
41
+ }
42
+
43
+ return false ;
44
+ }
45
+
33
46
// This variable is needed for the NumPy corner case
34
47
// if we have zero memory array (ex. shape=(0,10)) we must keep the pointer to somewhere
35
48
// memory of this variable must not be used
@@ -42,7 +55,12 @@ char* dpnp_memory_alloc_c(size_t size_in_bytes)
42
55
// std::cout << "dpnp_memory_alloc_c(size=" << size_in_bytes << std::flush;
43
56
if (size_in_bytes > 0 )
44
57
{
45
- array = reinterpret_cast <char *>(malloc_shared (size_in_bytes, DPNP_QUEUE));
58
+ cl::sycl::usm::alloc memory_type = cl::sycl::usm::alloc::shared;
59
+ if (use_sycl_device_memory ())
60
+ {
61
+ memory_type = cl::sycl::usm::alloc::device;
62
+ }
63
+ array = reinterpret_cast <char *>(malloc (size_in_bytes, DPNP_QUEUE, memory_type));
46
64
if (array == nullptr )
47
65
{
48
66
// TODO add information about number of allocated bytes
You can’t perform that action at this time.
0 commit comments