[arrayfire] 15/41: BUGFIX: Getting device ptr now forces JIT evaluation.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 21 14:56:22 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 332b6c478d301ac5e66b637bad8f2daabcbd5148
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Wed Mar 9 23:59:23 2016 -0500

    BUGFIX: Getting device ptr now forces JIT evaluation.
    
    - Added relevant tests
---
 src/backend/cpu/Array.hpp    | 6 ++++--
 src/backend/cuda/Array.hpp   | 4 ++--
 src/backend/opencl/Array.hpp | 4 ++--
 test/array.cpp               | 6 ++++++
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/backend/cpu/Array.hpp b/src/backend/cpu/Array.hpp
index 2a3afcf..da7b804 100644
--- a/src/backend/cpu/Array.hpp
+++ b/src/backend/cpu/Array.hpp
@@ -85,12 +85,14 @@ namespace cpu
     {
         T *ptr = arr.device();
         memLock(ptr);
+
         return (void *)ptr;
     }
 
     template<typename T>
     void *getRawPtr(const Array<T>& arr)
     {
+        getQueue().sync();
         return (void *)(arr.get(false));
     }
 
@@ -187,10 +189,10 @@ namespace cpu
         T* device()
         {
             getQueue().sync();
-            if (!isOwner() || data.use_count() > 1) {
+            if (!isOwner() || getOffset() || data.use_count() > 1) {
                 *this = Array<T>(dims(), get(), true, true);
             }
-            return this->data.get();
+            return this->get();
         }
 
         T* device() const
diff --git a/src/backend/cuda/Array.hpp b/src/backend/cuda/Array.hpp
index 7678754..d6adfd0 100644
--- a/src/backend/cuda/Array.hpp
+++ b/src/backend/cuda/Array.hpp
@@ -181,10 +181,10 @@ namespace cuda
 
         T* device()
         {
-            if (!isOwner() || data.use_count() > 1) {
+            if (!isOwner() || getOffset() || data.use_count() > 1) {
                 *this = Array<T>(dims(), get(), true, true);
             }
-            return this->data.get();
+            return this->get();
         }
 
         T* device() const
diff --git a/src/backend/opencl/Array.hpp b/src/backend/opencl/Array.hpp
index f87c772..d2fa942 100644
--- a/src/backend/opencl/Array.hpp
+++ b/src/backend/opencl/Array.hpp
@@ -164,10 +164,10 @@ namespace opencl
 
         cl::Buffer* device()
         {
-            if (!isOwner() || data.use_count() > 1) {
+            if (!isOwner() || getOffset() || data.use_count() > 1) {
                 *this = Array<T>(dims(), (*get())(), (size_t)getOffset(), true);
             }
-            return this->data.get();
+            return this->get();
         }
 
         cl::Buffer* device() const
diff --git a/test/array.cpp b/test/array.cpp
index 47e0c3a..e08e604 100644
--- a/test/array.cpp
+++ b/test/array.cpp
@@ -492,3 +492,9 @@ TEST(Device, empty)
     array a = array();
     ASSERT_EQ(a.device<float>() == NULL, 1);
 }
+
+TEST(Device, JIT)
+{
+    array a = constant(1, 5, 5);
+    ASSERT_EQ(a.device<float>() != NULL, 1);
+}

-- 
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