[arrayfire] 03/41: BUGFIX: Return cl_mem properly from OpenCL backend.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 21 14:56:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/experimental
in repository arrayfire.

commit b2110ac97026ffe089d480785fe2aaf0b0c97031
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Thu Mar 3 14:43:49 2016 -0500

    BUGFIX: Return cl_mem properly from OpenCL backend.
---
 include/af/device.h          | 2 ++
 include/af/opencl.h          | 6 +++---
 src/backend/opencl/Array.hpp | 9 ++++++---
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/af/device.h b/include/af/device.h
index b08bd51..6297102 100644
--- a/include/af/device.h
+++ b/include/af/device.h
@@ -428,6 +428,8 @@ extern "C" {
 
        The device pointer \p ptr is notfreed by memory manager until \ref af_unlock_device_ptr is called.
        \ingroup device_func_mem
+
+       \note For OpenCL backend *ptr should be cast to cl_mem.
     */
     AFAPI af_err af_get_device_ptr(void **ptr, const af_array arr);
 
diff --git a/include/af/opencl.h b/include/af/opencl.h
index 16b85d7..8cb6e8e 100644
--- a/include/af/opencl.h
+++ b/include/af/opencl.h
@@ -450,10 +450,10 @@ namespace af
 #if !defined(AF_OPENCL)
 template<> AFAPI cl_mem *array::device() const
 {
-    cl_mem *mem = new cl_mem;
-    af_err err = af_get_device_ptr((void **)mem, get());
+    cl_mem *mem_ptr = new cl_mem;
+    af_err err = af_get_device_ptr((void **)mem_ptr, get());
     if (err != AF_SUCCESS) throw af::exception("Failed to get cl_mem from array object");
-    return mem;
+    return mem_ptr;
 }
 #endif
 
diff --git a/src/backend/opencl/Array.hpp b/src/backend/opencl/Array.hpp
index 8c5bda9..0b1f019 100644
--- a/src/backend/opencl/Array.hpp
+++ b/src/backend/opencl/Array.hpp
@@ -77,15 +77,18 @@ namespace opencl
     template<typename T>
     void *getDevicePtr(const Array<T>& arr)
     {
-        cl::Buffer *buf = arr.device();
+        const cl::Buffer *buf = arr.device();
         memLock((T *)buf);
-        return (void *)((*buf)());
+        cl_mem mem = (*buf)();
+        return (void *)mem;
     }
 
     template<typename T>
     void *getRawPtr(const Array<T>& arr)
     {
-        return (void *)(arr.get());
+        const cl::Buffer *buf = arr.get();
+        cl_mem mem = (*buf)();
+        return (void *)mem;
     }
 
     template<typename T>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list