[arrayfire] 106/408: PERF: Improvements to tile when tiling along singleton dimensions

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:30 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 05de8bf558010438dd0b2f9120d51d2b0cb301ab
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Mon Jul 6 10:08:37 2015 -0400

    PERF: Improvements to tile when tiling along singleton dimensions
---
 src/api/c/tile.cpp | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/api/c/tile.cpp b/src/api/c/tile.cpp
index 463dd36..5064677 100644
--- a/src/api/c/tile.cpp
+++ b/src/api/c/tile.cpp
@@ -7,12 +7,15 @@
  * http://arrayfire.com/licenses/BSD-3-Clause
  ********************************************************/
 
+#include <iostream>
 #include <af/data.h>
+#include <af/arith.h>
 #include <err_common.hpp>
 #include <handle.hpp>
 #include <backend.hpp>
 #include <ArrayInfo.hpp>
 #include <tile.hpp>
+#include <arith.hpp>
 
 using af::dim4;
 using namespace detail;
@@ -20,7 +23,30 @@ using namespace detail;
 template<typename T>
 static inline af_array tile(const af_array in, const af::dim4 &tileDims)
 {
-    return getHandle(tile<T>(getArray<T>(in), tileDims));
+    const Array<T> inArray = getArray<T>(in);
+    const dim4 inDims = inArray.dims();
+
+
+    // FIXME: Always use JIT instead of checking for the condition.
+    // The current limitation exists for performance reasons. it should change in the future.
+
+    bool take_jit_path = true;
+    dim4 outDims(1, 1, 1, 1);
+
+    // Check if JIT path can be taken. JIT path can only be taken if tiling a singleton dimension.
+    for (int i = 0; i < 4; i++) {
+        take_jit_path &= (inDims[i] == 1 || tileDims[i] == 1);
+        outDims[i] = inDims[i] * tileDims[i];
+    }
+
+    if (take_jit_path) {
+        // FIXME: This Should ideally call a NOP function, but adding 0 should be OK
+        // This does not allocate any memory, just a JIT node
+        Array<T> tmpArray = createValueArray<T>(outDims, scalar<T>(0));
+        return getHandle(arithOp<T, af_add_t>(inArray, tmpArray, outDims));
+    } else {
+        return getHandle(tile<T>(inArray, tileDims));
+    }
 }
 
 af_err af_tile(af_array *out, const af_array in, const af::dim4 &tileDims)

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