Release GIL around blocking operations in libtensor#1753
Release GIL around blocking operations in libtensor#1753oleksandr-pavlyk merged 4 commits intomasterfrom
Conversation
|
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_160 ran successfully. |
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_161 ran successfully. |
antonwolfy
left a comment
There was a problem hiding this comment.
The dpnp tests are passed with that changes. The example also work now without any hang.
Thank you @oleksandr-pavlyk
1c70604 to
d17b50e
Compare
|
The last commit fixed a crash in the following snippet: import dpctl
import dpctl.utils as du
import dpctl.tensor as dpt
class A:
def __init__(self, arr):
self._array_obj = arr
@property
def __sycl_usm_array_interface__(self):
return self._array_obj.__sycl_usm_array_interface__
a = dpt.linspace(0, dpt.pi, num=2**27, dtype="f8")
a_dummy = A(a)
a_sin = dpt.sin(a)
print(1)
b = dpt.asarray(a_dummy, dtype="f8")
b /= 1
print(2)Technically such a code is a usage error, since script ends with pending asynchronous tasks. It used to crash due to such tasks requiring GIL which can not be acquired during the interpreter shutdown and caused seg-fault in the thread executing the cleanup The fix was to used The test is not being added here, but we must document that user is advised to perform the synchronization explicitly before the script ends, and the recommended usage would be import dpctl
import dpctl.utils as du
import dpctl.tensor as dpt
class A:
def __init__(self, arr):
self._array_obj = arr
@property
def __sycl_usm_array_interface__(self):
return self._array_obj.__sycl_usm_array_interface__
a = dpt.linspace(0, dpt.pi, num=2**27, dtype="f8")
a_dummy = A(a)
a_sin = dpt.sin(a)
print(1)
b = dpt.asarray(a_dummy, dtype="f8")
b /= 1
print(2)
# ensure all submitted tasks complete
b.sycl_queue.wait() |
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_172 ran successfully. |
1 similar comment
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_172 ran successfully. |
d17b50e to
e27c40d
Compare
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_179 ran successfully. |
Copy from NumPy ndarray to usm_ndarray is blocking, so release GIL. mask-positions (cumulative value) which returns a total is blocking, so release the GIL.
Co-authored-by: ndgrigorian <46709016+ndgrigorian@users.noreply.github.com>
Use weakref.finalize to ensure synchronization of outstanding events at exit.
e27c40d to
c6a362d
Compare
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_179 ran successfully. |
The test performs set-item on conformably permutted ndarray and usm_ndarray Also made inputs in tests sensitive to violation (not all elements are set to one, but some are set to zero too).
|
Array API standard conformance tests for dpctl=0.18.0dev0=py310ha798474_180 ran successfully. |
ndgrigorian
left a comment
There was a problem hiding this comment.
With tests added and CI passing this LGTM!
Copy from NumPy ndarray to usm_ndarray is blocking, so release GIL.
mask-positions (cumulative value) which returns a total is blocking, so release the GIL.