Skip to content

Commit

Permalink
Some SVM fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Jul 27, 2022
1 parent 1f4f769 commit f721a96
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/demo_array_svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

alloc = SVMAllocator(ctx, cl.svm_mem_flags.READ_WRITE, queue=queue)
alloc = SVMAllocator(ctx, 0, cl.svm_mem_flags.READ_WRITE, queue)

a_dev = cl_array.to_device(queue, a, allocator=alloc)
print("A_DEV", a_dev.data)
Expand Down
19 changes: 0 additions & 19 deletions pyopencl/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,6 @@ def _register_types():
# }}}


# {{{ svm allocator

# FIXME: Replace me with C++
class SVMAllocator:
def __init__(self, ctx, flags, *, alignment=0, queue=None):
self._context = ctx
self._flags = flags
self._alignment = alignment
self._queue = queue

def __call__(self, nbytes):
import pyopencl as cl
return cl.SVMAllocation(
self._context, nbytes, self._alignment, self._flags,
queue=self._queue)

# }}}


# {{{ first-arg caches

_first_arg_dependent_caches = []
Expand Down
10 changes: 8 additions & 2 deletions src/wrap_mempool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Warp memory pool
// Wrap memory pool
//
// Copyright (C) 2009 Andreas Kloeckner
//
Expand Down Expand Up @@ -349,7 +349,7 @@ namespace
: m_context(ctx), m_alignment(alignment), m_flags(flags)
{
if (queue)
m_queue.set(m_queue.data());
m_queue.set(queue->data());
}

svm_allocator(svm_allocator const &src)
Expand Down Expand Up @@ -679,6 +679,12 @@ void pyopencl_expose_mempool(py::module &m)
.def("__call__", svm_allocator_call)
;
}

{
typedef svm_held_pointer cls;
py::class_<cls> wrapper(
m, "_tools_SVMHeldPointer");
}
#endif
}

Expand Down

0 comments on commit f721a96

Please sign in to comment.