-
Notifications
You must be signed in to change notification settings - Fork 242
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
Make SVM practical #452
Make SVM practical #452
Conversation
01be96d
to
81f06d6
Compare
With 3abf89c, examples/svm.py is failing with the following message:
The following patch works around it (it also adds the missing diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index 22562d1..9c62cea 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -1141,21 +1141,6 @@ def _add_functionality():
.. automethod:: enqueue_release
"""
- if get_cl_header_version() >= (2, 0):
- class _ArrayInterfaceSVMAllocation(SVMAllocation):
- def __init__(self, ctx, size, alignment, flags, _interface=None,
- queue=None):
- """
- :arg ctx: a :class:`Context`
- :arg flags: some of :class:`svm_mem_flags`.
- """
- super().__init__(ctx, size, alignment, flags, queue)
-
- # mem_flags.READ_ONLY applies to kernels, not the host
- read_write = True
- _interface["data"] = (
- int(self._ptr_as_int()), not read_write)
-
# }}}
# {{{ SVM
@@ -1396,6 +1381,23 @@ def _add_functionality():
_add_functionality()
+if get_cl_header_version() >= (2, 0):
+ class _ArrayInterfaceSVMAllocation(SVMAllocation):
+ def __init__(self, ctx, size, alignment, flags, _interface=None,
+ queue=None):
+ """
+ :arg ctx: a :class:`Context`
+ :arg flags: some of :class:`svm_mem_flags`.
+ """
+ super().__init__(ctx, size, alignment, flags, queue)
+
+ # mem_flags.READ_ONLY applies to kernels, not the host
+ read_write = True
+ _interface["data"] = (
+ int(self._ptr_as_int()), not read_write)
+
+ self.__array_interface__ = _interface
+
# }}} (Do you prefer me to send these as PRs on top of this PR?) |
7f20c75 is a WIP commit that doesn't even compile. It's intended to prevent further duplication of work with @matthiasdiener (cf. #587). Sorry about not getting this pushed sooner. |
c34af00
to
1f4f769
Compare
0cf016f has broken compatibility with |
Attemping to run
|
39efdaf
to
f368652
Compare
Are you able to get a backtrace (e.g. with |
It appears that a good part of the slower execution of SVM comes from the ordering of the argument type checks in Lines 4504 to 4518 in 8bce4f6
We check for memory objects (images, buffers) first, and for SVM second. FWIW, reversing that order seems to help a lot, and the exception handling appears to play a big part in the time spent. Unfortunately, according to pybind/pybind11#649, the |
After pulling in the lastest changes and recompiling I am no longer seeing segmentation faults on Rocm 5.2.0 for |
With the changes in https://github.com/inducer/pyopencl/compare/7ef5ce5ec280038559295d45986c96302c193d6d..87420b1334806b7fa0fb0104e80a09366869b9f0, this performs about equivalently to buffers (with pocl) in my unscientific benchmarking. |
Co-authored by: Matthias Diener <[email protected]>
Co-authored-by: Andreas Kloeckner <[email protected]>
Co-authored-by: Andreas Kloeckner <[email protected]>
OK, I've done my final review, made some final fixes. If it passes CI here and on Gitlab, then it'll go in. 🎉 |
I'll call that passing. 🙂 |
Draft because it's missing:
Ensure that SVM allocators can't be passed to buffer mem pool and vice versa.the queue-associated SVM allocation is one potential solution for that, at least for in-order queues. See also SVM deallocation should wait for completion of operations on them #449.demo_array_svm
crashes for the moment,clang
.