[arrayfire] 376/408: BUGFIX: For calculating number of elements for a buffer in OpenCL backend

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:12:34 UTC 2015


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

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

commit 619ecf70230c3322573140df2b06b08dd7102b5c
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Wed Sep 2 14:04:01 2015 -0400

    BUGFIX: For calculating number of elements for a buffer in OpenCL backend
---
 src/backend/opencl/kernel/ireduce.hpp | 6 ++++--
 src/backend/opencl/kernel/reduce.hpp  | 5 +++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/backend/opencl/kernel/ireduce.hpp b/src/backend/opencl/kernel/ireduce.hpp
index 5fa0fa6..8bc06f2 100644
--- a/src/backend/opencl/kernel/ireduce.hpp
+++ b/src/backend/opencl/kernel/ireduce.hpp
@@ -332,7 +332,7 @@ namespace kernel
     T ireduce_all(uint *loc, Param in)
     {
         try {
-            int in_elements = in.info.dims[3] * in.info.strides[3];
+            int in_elements = in.info.dims[0] * in.info.dims[1] * in.info.dims[2] * in.info.dims[3];
 
             // FIXME: Use better heuristics to get to the optimum number
             if (in_elements > 4096) {
@@ -397,7 +397,9 @@ namespace kernel
 
                 unique_ptr<T> h_ptr(new T[in_elements]);
                 T* h_ptr_raw = h_ptr.get();
-                getQueue().enqueueReadBuffer(*in.data, CL_TRUE, 0, sizeof(T) * in_elements, h_ptr_raw);
+
+                getQueue().enqueueReadBuffer(*in.data, CL_TRUE, sizeof(T) * in.info.offset,
+                                             sizeof(T) * in_elements, h_ptr_raw);
 
 
                 MinMaxOp<op, T> Op(h_ptr_raw[0], 0);
diff --git a/src/backend/opencl/kernel/reduce.hpp b/src/backend/opencl/kernel/reduce.hpp
index 5ac55b5..e46d5e4 100644
--- a/src/backend/opencl/kernel/reduce.hpp
+++ b/src/backend/opencl/kernel/reduce.hpp
@@ -287,7 +287,7 @@ namespace kernel
     To reduce_all(Param in, int change_nan, double nanval)
     {
         try {
-            int in_elements = in.info.dims[3] * in.info.strides[3];
+            int in_elements = in.info.dims[0] * in.info.dims[1] * in.info.dims[2] * in.info.dims[3];
 
             // FIXME: Use better heuristics to get to the optimum number
             if (in_elements > 4096) {
@@ -342,7 +342,8 @@ namespace kernel
             } else {
 
                 unique_ptr<Ti> h_ptr(new Ti[in_elements]);
-                getQueue().enqueueReadBuffer(*in.data, CL_TRUE, 0, sizeof(Ti) * in_elements, h_ptr.get());
+                getQueue().enqueueReadBuffer(*in.data, CL_TRUE, sizeof(Ti) * in.info.offset,
+                                             sizeof(Ti) * in_elements, h_ptr.get());
 
                 Transform<Ti, To, op> transform;
                 Binary<To, op> reduce;

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