From 60d9c49f417579a06e4f12ff2fe2dffd0ebeb904 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Tue, 12 Feb 2019 16:37:03 -0600
Subject: [PATCH] SVM fixes

---
 pyopencl/__init__.py   | 11 +++++++----
 src/wrap_cl_part_2.cpp |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index 2c673fda..5f92e136 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -1692,10 +1692,11 @@ def enqueue_copy(queue, dest, src, **kwargs):
 
     elif get_cl_header_version() >= (2, 0) and isinstance(dest, SVM):
         # to SVM
-        if isinstance(src, SVM):
-            src = src.mem
+        if not isinstance(src, SVM):
+            src = SVM(src)
 
-        return _cl._enqueue_svm_memcpy(queue, dest.mem, src, **kwargs)
+        is_blocking = kwargs.pop("is_blocking", True)
+        return _cl._enqueue_svm_memcpy(queue, is_blocking, dest, src, **kwargs)
 
     else:
         # assume to-host
@@ -1723,7 +1724,9 @@ def enqueue_copy(queue, dest, src, **kwargs):
         elif isinstance(src, SVM):
             # from svm
             # dest is not a SVM instance, otherwise we'd be in the branch above
-            return _cl._enqueue_svm_memcpy(queue, dest, src.mem, **kwargs)
+            is_blocking = kwargs.pop("is_blocking", True)
+            return _cl._enqueue_svm_memcpy(
+                    queue, is_blocking, SVM(dest), src, **kwargs)
         else:
             # assume from-host
             raise TypeError("enqueue_copy cannot perform host-to-host transfers")
diff --git a/src/wrap_cl_part_2.cpp b/src/wrap_cl_part_2.cpp
index 22d9f3c1..4ef6afca 100644
--- a/src/wrap_cl_part_2.cpp
+++ b/src/wrap_cl_part_2.cpp
@@ -284,7 +284,7 @@ void pyopencl_expose_part_2(py::module &m)
       ;
   }
 
-  m.def("_enqueue_svm_memcpyw", enqueue_svm_memcpy,
+  m.def("_enqueue_svm_memcpy", enqueue_svm_memcpy,
       py::arg("queue"),
       py::arg("is_blocking"),
       py::arg("dst"),
-- 
GitLab