Skip to content

Commit b3b6345

Browse files
committed
Add SVMAllocator (in Python)
1 parent 823e893 commit b3b6345

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

pyopencl/tools.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ def _register_types():
6767
# }}}
6868

6969

70+
# {{{ svm allocator
71+
72+
# FIXME: Replace me with C++
73+
class SVMAllocator:
74+
def __init__(self, ctx, flags, *, alignment=0, queue=None):
75+
self._context = ctx
76+
self._flags = flags
77+
self._alignment = alignment
78+
self._queue = queue
79+
80+
def __call__(self, nbytes):
81+
import pyopencl as cl
82+
return cl.SVM(cl.svm_empty(
83+
self._context, self._flags, (nbytes,), np.int8, "C", self._alignment,
84+
self._queue))
85+
86+
# }}}
87+
88+
7089
# {{{ first-arg caches
7190

7291
_first_arg_dependent_caches = []

0 commit comments

Comments
 (0)