-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tensor.zeros to use async memset #1806
Conversation
This is akin to _full_usm_ndarray, but does not take fill_value, hence does not require castings. It dispatches straight to handler::memset.
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Array API standard conformance tests for dpctl=0.18.0dev0=py310hdf72452_344 ran successfully. |
@oleksandr-pavlyk |
Bitwise zero values, and 1-byte wide types now use memset, instead of using fill. ``` In [1]: import dpctl.tensor as dpt, dpctl.tensor._tensor_impl as ti In [2]: res = dpt.empty(10**6, dtype="i8") In [3]: %timeit -n 2000 -r 11 ti._full_usm_ndarray(0, dst=res, sycl_queue=res.sycl_queue)[0].wait() 243 µs ± 22.6 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [4]: %timeit -n 2000 -r 11 ti._full_usm_ndarray(0, dst=res, sycl_queue=res.sycl_queue)[0].wait() 229 µs ± 14 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [5]: %timeit -n 2000 -r 11 ti._zeros_usm_ndarray(dst=res, sycl_queue=res.sycl_queue)[0].wait() 227 µs ± 23 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [6]: %timeit -n 2000 -r 11 ti._zeros_usm_ndarray(dst=res, sycl_queue=res.sycl_queue)[0].wait() 233 µs ± 25.9 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [7]: %timeit -n 2000 -r 11 ti._zeros_usm_ndarray(dst=res, sycl_queue=res.sycl_queue)[0].wait() 301 µs ± 54.1 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [8]: %timeit -n 2000 -r 11 ti._zeros_usm_ndarray(dst=res, sycl_queue=res.sycl_queue)[0].wait() 236 µs ± 17.2 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [9]: %timeit -n 2000 -r 11 ti._full_usm_ndarray(0, dst=res, sycl_queue=res.sycl_queue)[0].wait() 240 µs ± 35.2 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [10]: %timeit -n 2000 -r 11 ti._full_usm_ndarray(1, dst=res, sycl_queue=res.sycl_queue)[0].wait() 243 µs ± 17.6 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [11]: %timeit -n 2000 -r 11 ti._full_usm_ndarray(1, dst=res, sycl_queue=res.sycl_queue)[0].wait() 263 µs ± 39.9 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [12]: %timeit -n 2000 -r 11 ti._full_usm_ndarray(0, dst=res, sycl_queue=res.sycl_queue)[0].wait() 239 µs ± 26.4 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) In [13]: %timeit -n 2000 -r 11 ti._zeros_usm_ndarray(dst=res, sycl_queue=res.sycl_queue)[0].wait() 224 µs ± 18.1 µs per loop (mean ± std. dev. of 11 runs, 2,000 loops each) ```
da954f9
to
f0d926a
Compare
Array API standard conformance tests for dpctl=0.18.0dev0=py310hdf72452_345 ran successfully. |
Co-authored-by: ndgrigorian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, the change looks good to me
Array API standard conformance tests for dpctl=0.18.0dev0=py310hdf72452_346 ran successfully. |
Addressed outstanding FIXME note to use async call to populate array with zeros.
Added optimization for
_full_usm_ndarray
to usehandler::memset
instead ofhandler::fill
for 1-byte wide types and for other types when fill value is bitwise zero.