[arrayfire] 215/284: Cleanup for opencl-cpu offload

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:34 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 a8b831b5022c6c8a840fccbaa0d5e12107aecd81
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Wed Jan 13 11:15:15 2016 -0500

    Cleanup for opencl-cpu offload
---
 src/backend/cuda/blas.cpp    | 22 ----------------------
 src/backend/opencl/Array.hpp | 21 +++------------------
 src/backend/opencl/blas.cpp  | 27 ---------------------------
 test/backend.cpp             | 16 +++++++++++-----
 test/blas.cpp                |  1 -
 5 files changed, 14 insertions(+), 73 deletions(-)

diff --git a/src/backend/cuda/blas.cpp b/src/backend/cuda/blas.cpp
index 1e5dd5d..9d3b9ca 100644
--- a/src/backend/cuda/blas.cpp
+++ b/src/backend/cuda/blas.cpp
@@ -200,28 +200,6 @@ Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
 
 }
 
-// Keeping this around for future reference
-//template<typename T, bool conjugate, bool both_conjugate>
-//Array<T> dot_(const Array<T> &lhs, const Array<T> &rhs,
-//              af_mat_prop optLhs, af_mat_prop optRhs)
-//{
-//    int N = lhs.dims()[0];
-//
-//    T out;
-//
-//    CUBLAS_CHECK((dot_func<T, conjugate>()(
-//                 getHandle(),
-//                 N,
-//                 lhs.get(), lhs.strides()[0],
-//                 rhs.get(), rhs.strides()[0],
-//                 &out)));
-//
-//    if(both_conjugate)
-//        return createValueArray(af::dim4(1), conj(out));
-//    else
-//        return createValueArray(af::dim4(1), out);
-//}
-
 template<typename T>
 Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
              af_mat_prop optLhs, af_mat_prop optRhs)
diff --git a/src/backend/opencl/Array.hpp b/src/backend/opencl/Array.hpp
index ce9c3c7..2793d5e 100644
--- a/src/backend/opencl/Array.hpp
+++ b/src/backend/opencl/Array.hpp
@@ -210,17 +210,6 @@ namespace opencl
 
         JIT::Node_ptr getNode() const;
 
-    private:
-        bool is_const() const
-        {
-            return true;
-        }
-
-        bool is_const()
-        {
-            return false;
-        }
-
     public:
         std::shared_ptr<T> getMappedPtr() const
         {
@@ -237,13 +226,9 @@ namespace opencl
             T *ptr = nullptr;
             try {
                 if(ptr == nullptr) {
-                    if(is_const()) {
-                        ptr = (T*)getQueue().enqueueMapBuffer(*const_cast<cl::Buffer*>(get()), true, CL_MAP_READ,
-                                getOffset(), getDataDims().elements() * sizeof(T));
-                    } else {
-                        ptr = (T*)getQueue().enqueueMapBuffer(*(get()), true, CL_MAP_READ|CL_MAP_WRITE,
-                                getOffset(), getDataDims().elements() * sizeof(T));
-                    }
+                    ptr = (T*)getQueue().enqueueMapBuffer(*const_cast<cl::Buffer*>(get()),
+                            true, CL_MAP_READ|CL_MAP_WRITE,
+                            getOffset(), getDataDims().elements() * sizeof(T));
                 }
             } catch(cl::Error err) {
                 CL_TO_AF_ERROR(err);
diff --git a/src/backend/opencl/blas.cpp b/src/backend/opencl/blas.cpp
index 15e2373..97a5c1a 100644
--- a/src/backend/opencl/blas.cpp
+++ b/src/backend/opencl/blas.cpp
@@ -177,33 +177,6 @@ Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
     return out;
 }
 
-// Keeping this around for future reference
-//template<typename T, bool conjugate, bool both_conjugate>
-//Array<T> dot_(const Array<T> &lhs, const Array<T> &rhs,
-//              af_mat_prop optLhs, af_mat_prop optRhs)
-//{
-//    initBlas();
-//
-//    int N = lhs.dims()[0];
-//    dot_func<T, conjugate> dot;
-//    cl::Event event;
-//    Array<T> out = createEmptyArray<T>(af::dim4(1));
-//    cl::Buffer scratch(getContext(), CL_MEM_READ_WRITE, sizeof(T) * N);
-//    CLBLAS_CHECK(
-//        dot(N,
-//            (*out.get())(), out.getOffset(),
-//            (*lhs.get())(),  lhs.getOffset(), lhs.strides()[0],
-//            (*rhs.get())(),  rhs.getOffset(), rhs.strides()[0],
-//            scratch(),
-//            1, &getQueue()(), 0, nullptr, &event())
-//        );
-//
-//    if(both_conjugate)
-//        transpose_inplace<T>(out, true);
-//
-//    return out;
-//}
-
 template<typename T>
 Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
              af_mat_prop optLhs, af_mat_prop optRhs)
diff --git a/test/backend.cpp b/test/backend.cpp
index 4bb5cdf..78b6430 100644
--- a/test/backend.cpp
+++ b/test/backend.cpp
@@ -21,11 +21,8 @@
 using std::string;
 using std::vector;
 
-const char *getActiveBackendString()
+const char *getActiveBackendString(af_backend active)
 {
-    af_backend active = (af_backend)0;
-    af_get_active_backend(&active);
-
     switch(active) {
         case AF_BACKEND_CPU   : return "AF_BACKEND_CPU";
         case AF_BACKEND_CUDA  : return "AF_BACKEND_CUDA";
@@ -39,11 +36,20 @@ void testFunction()
 {
     af_info();
 
-    printf("Active Backend Enum = %s\n", getActiveBackendString());
+    af_backend activeBackend = (af_backend)0;
+    af_get_active_backend(&activeBackend);
+
+    printf("Active Backend Enum = %s\n", getActiveBackendString(activeBackend));
 
     af_array outArray = 0;
     dim_t dims[] = {32, 32};
     ASSERT_EQ(AF_SUCCESS, af_randu(&outArray, 2, dims, (af_dtype) af::dtype_traits<T>::af_type));
+
+    // Verify backends returned by array and by function are the same
+    af_backend arrayBackend = (af_backend)0;
+    af_get_backend_id(&arrayBackend, outArray);
+    ASSERT_EQ(arrayBackend, activeBackend);
+
     // cleanup
     if(outArray != 0) ASSERT_EQ(AF_SUCCESS, af_release_array(outArray));
 }
diff --git a/test/blas.cpp b/test/blas.cpp
index b5d92f1..507cc6d 100644
--- a/test/blas.cpp
+++ b/test/blas.cpp
@@ -36,7 +36,6 @@ template<typename T, bool isBVector>
 void MatMulCheck(string TestFile)
 {
     if (noDoubleTests<T>()) return;
-    af::info();
 
     using std::vector;
     vector<af::dim4> numDims;

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