[arrayfire] 23/284: converted triangle fn in cpu backend to async call

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:15 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 5eea071e457ca37c2a285365c42f9f1c1bd1d0c0
Author: pradeep <pradeep at arrayfire.com>
Date:   Thu Nov 19 18:11:16 2015 -0500

    converted triangle fn in cpu backend to async call
---
 src/backend/cpu/triangle.cpp | 56 ++++++++++++++++++++++++--------------------
 1 file changed, 31 insertions(+), 25 deletions(-)

diff --git a/src/backend/cpu/triangle.cpp b/src/backend/cpu/triangle.cpp
index 6b0f326..ed7f348 100644
--- a/src/backend/cpu/triangle.cpp
+++ b/src/backend/cpu/triangle.cpp
@@ -12,6 +12,8 @@
 #include <Array.hpp>
 #include <triangle.hpp>
 #include <math.hpp>
+#include <platform.hpp>
+#include <async_queue.hpp>
 
 namespace cpu
 {
@@ -19,42 +21,46 @@ namespace cpu
 template<typename T, bool is_upper, bool is_unit_diag>
 void triangle(Array<T> &out, const Array<T> &in)
 {
-    T *o = out.get();
-    const T *i = in.get();
+    auto func = [=] (Array<T> out, const Array<T> in) {
+        T *o = out.get();
+        const T *i = in.get();
 
-    dim4 odm = out.dims();
+        dim4 odm = out.dims();
 
-    dim4 ost = out.strides();
-    dim4 ist = in.strides();
+        dim4 ost = out.strides();
+        dim4 ist = in.strides();
 
-    for(dim_t ow = 0; ow < odm[3]; ow++) {
-        const dim_t oW = ow * ost[3];
-        const dim_t iW = ow * ist[3];
+        for(dim_t ow = 0; ow < odm[3]; ow++) {
+            const dim_t oW = ow * ost[3];
+            const dim_t iW = ow * ist[3];
 
-        for(dim_t oz = 0; oz < odm[2]; oz++) {
-            const dim_t oZW = oW + oz * ost[2];
-            const dim_t iZW = iW + oz * ist[2];
+            for(dim_t oz = 0; oz < odm[2]; oz++) {
+                const dim_t oZW = oW + oz * ost[2];
+                const dim_t iZW = iW + oz * ist[2];
 
-            for(dim_t oy = 0; oy < odm[1]; oy++) {
-                const dim_t oYZW = oZW + oy * ost[1];
-                const dim_t iYZW = iZW + oy * ist[1];
+                for(dim_t oy = 0; oy < odm[1]; oy++) {
+                    const dim_t oYZW = oZW + oy * ost[1];
+                    const dim_t iYZW = iZW + oy * ist[1];
 
-                for(dim_t ox = 0; ox < odm[0]; ox++) {
-                    const dim_t oMem = oYZW + ox;
-                    const dim_t iMem = iYZW + ox;
+                    for(dim_t ox = 0; ox < odm[0]; ox++) {
+                        const dim_t oMem = oYZW + ox;
+                        const dim_t iMem = iYZW + ox;
 
-                    bool cond = is_upper ? (oy >= ox) : (oy <= ox);
-                    bool do_unit_diag = (is_unit_diag && ox == oy);
-                    if(cond) {
-                        o[oMem] = do_unit_diag ? scalar<T>(1) : i[iMem];
-                    } else {
-                        o[oMem] = scalar<T>(0);
-                    }
+                        bool cond = is_upper ? (oy >= ox) : (oy <= ox);
+                        bool do_unit_diag = (is_unit_diag && ox == oy);
+                        if(cond) {
+                            o[oMem] = do_unit_diag ? scalar<T>(1) : i[iMem];
+                        } else {
+                            o[oMem] = scalar<T>(0);
+                        }
 
+                    }
                 }
             }
         }
-    }
+    };
+
+    getQueue().enqueue(func, out, in);
 }
 
 template<typename T, bool is_upper, bool is_unit_diag>

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