Skip to content

Commit a3f7dbe

Browse files
authored
Add user control on type of ctor sycl memory type in dpctl (#883)
1 parent ae54d5c commit a3f7dbe

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

dpnp/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
Explicitly use NumPy.ndarray as return type for creation functions
4444
'''
4545

46+
__DPNP_OUTPUT_DPCTL_DEFAULT_SHARED__ = int(os.getenv('DPNP_OUTPUT_DPCTL_DEFAULT_SHARED', 0))
47+
'''
48+
Explicitly use SYCL shared memory parameter in DPCtl array constructor for creation functions
49+
'''
50+
4651
__DPNP_DPCTL_AVAILABLE__ = False
4752
'''
4853
Availability of the DPCtl package in the environment

dpnp/dpnp_container.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ def create_output_container(shape, type):
6969
result = numpy.ndarray(shape, dtype=type)
7070
elif config.__DPNP_DPCTL_AVAILABLE__:
7171
""" Create DPCTL array """
72-
result = dpctl.usm_ndarray(shape, dtype=numpy.dtype(type).name)
72+
if config.__DPNP_OUTPUT_DPCTL_DEFAULT_SHARED__:
73+
"""
74+
From DPCtrl documentation:
75+
'buffer can be strings ('device'|'shared'|'host' to allocate new memory)'
76+
"""
77+
result = dpctl.usm_ndarray(shape, dtype=numpy.dtype(type).name, buffer='shared')
78+
else:
79+
"""
80+
Can't pass 'None' as buffer= parameter to allow DPCtrl uses it's default
81+
"""
82+
result = dpctl.usm_ndarray(shape, dtype=numpy.dtype(type).name)
7383
else:
7484
""" Create DPNP array """
7585
result = dparray(shape, dtype=type)

0 commit comments

Comments
 (0)