[arrayfire] 267/284: JIT evaluation can now be tweaked by environment variables

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:40 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 82e655825f74b9faf371550a20c839fee1701564
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue Feb 2 19:12:29 2016 -0500

    JIT evaluation can now be tweaked by environment variables
---
 src/backend/cpu/Array.cpp       |  5 +++--
 src/backend/cpu/platform.cpp    | 16 ++++++++++++++++
 src/backend/cpu/platform.hpp    |  2 ++
 src/backend/cuda/Array.cpp      |  5 +++--
 src/backend/cuda/platform.cpp   | 17 +++++++++++++++++
 src/backend/cuda/platform.hpp   |  2 ++
 src/backend/opencl/Array.cpp    | 16 +++-------------
 src/backend/opencl/platform.cpp | 22 ++++++++++++++++++++++
 src/backend/opencl/platform.hpp |  2 ++
 9 files changed, 70 insertions(+), 17 deletions(-)

diff --git a/src/backend/cpu/Array.cpp b/src/backend/cpu/Array.cpp
index 891604c..6d51f63 100644
--- a/src/backend/cpu/Array.cpp
+++ b/src/backend/cpu/Array.cpp
@@ -19,6 +19,7 @@
 #include <queue.hpp>
 #include <cstring>
 #include <cstddef>
+#include <MemoryManager.hpp>
 
 namespace cpu
 {
@@ -159,8 +160,8 @@ createNodeArray(const dim4 &dims, Node_ptr node)
     n->getInfo(length, buf_count, bytes);
     n->reset();
 
-    if (length > MAX_TNJ_LEN ||
-        buf_count >= MAX_BUFFERS ||
+    if (length > getMaxJitSize() ||
+        buf_count >= getMaxBuffers() ||
         bytes >= getMaxBytes()) {
         out.eval();
     }
diff --git a/src/backend/cpu/platform.cpp b/src/backend/cpu/platform.cpp
index 65a5ab1..7e6bc81 100644
--- a/src/backend/cpu/platform.cpp
+++ b/src/backend/cpu/platform.cpp
@@ -180,6 +180,22 @@ CPUInfo::CPUInfo()
 namespace cpu
 {
 
+unsigned getMaxJitSize()
+{
+    const int MAX_JIT_LEN = 20;
+
+    static int length = 0;
+    if (length == 0) {
+        std::string env_var = getEnvVar("AF_CPU_MAX_JIT_LEN");
+        if (!env_var.empty()) {
+            length = std::stoi(env_var);
+        } else {
+            length = MAX_JIT_LEN;
+        }
+    }
+    return length;
+}
+
 int getBackend()
 {
     return AF_BACKEND_CPU;
diff --git a/src/backend/cpu/platform.hpp b/src/backend/cpu/platform.hpp
index 9118ade..82ed42c 100644
--- a/src/backend/cpu/platform.hpp
+++ b/src/backend/cpu/platform.hpp
@@ -35,4 +35,6 @@ namespace cpu {
     void sync(int device);
 
     queue& getQueue(int idx = 0);
+
+    unsigned getMaxJitSize();
 }
diff --git a/src/backend/cuda/Array.cpp b/src/backend/cuda/Array.cpp
index 6e95dd1..48bee65 100644
--- a/src/backend/cuda/Array.cpp
+++ b/src/backend/cuda/Array.cpp
@@ -16,6 +16,7 @@
 #include <memory.hpp>
 #include <platform.hpp>
 #include <cstddef>
+#include <MemoryManager.hpp>
 
 using af::dim4;
 
@@ -148,8 +149,8 @@ namespace cuda
         n->getInfo(length, buf_count, bytes);
         n->resetFlags();
 
-        if (length > MAX_JIT_LEN ||
-            buf_count >= MAX_BUFFERS ||
+        if (length > getMaxJitSize() ||
+            buf_count >= getMaxBuffers() ||
             bytes >= getMaxBytes()) {
             out.eval();
         }
diff --git a/src/backend/cuda/platform.cpp b/src/backend/cuda/platform.cpp
index 5e53fc0..67f3f08 100644
--- a/src/backend/cuda/platform.cpp
+++ b/src/backend/cuda/platform.cpp
@@ -261,6 +261,23 @@ string getCUDARuntimeVersion()
 
 }
 
+unsigned getMaxJitSize()
+{
+    const int MAX_JIT_LEN = 20;
+
+    static int length = 0;
+    if (length == 0) {
+        std::string env_var = getEnvVar("AF_CUDA_MAX_JIT_LEN");
+        if (!env_var.empty()) {
+            length = std::stoi(env_var);
+        } else {
+            length = MAX_JIT_LEN;
+        }
+    }
+
+    return length;
+}
+
 int getDeviceCount()
 {
     return DeviceManager::getInstance().nDevices;
diff --git a/src/backend/cuda/platform.hpp b/src/backend/cuda/platform.hpp
index 9302f41..6b4186b 100644
--- a/src/backend/cuda/platform.hpp
+++ b/src/backend/cuda/platform.hpp
@@ -38,6 +38,8 @@ bool isDoubleSupported(int device);
 
 void devprop(char* d_name, char* d_platform, char *d_toolkit, char* d_compute);
 
+unsigned getMaxJitSize();
+
 int getDeviceCount();
 
 int getActiveDeviceId();
diff --git a/src/backend/opencl/Array.cpp b/src/backend/opencl/Array.cpp
index c470a35..178be5b 100644
--- a/src/backend/opencl/Array.cpp
+++ b/src/backend/opencl/Array.cpp
@@ -18,14 +18,12 @@
 #include <cstddef>
 #include <af/opencl.h>
 #include <util.hpp>
+#include <MemoryManager.hpp>
 
 using af::dim4;
 
 namespace opencl
 {
-
-    const int MAX_JIT_LEN = 20;
-    const int MAX_JIT_LEN_AMD = 16; //FIXME: Change this when bug is fixed
     using JIT::BufferNode;
     using JIT::Node;
     using JIT::Node_ptr;
@@ -156,14 +154,6 @@ namespace opencl
 
     using af::dim4;
 
-    inline bool is_max_jit_len(const unsigned &len)
-    {
-        if (getActivePlatform() == AFCL_PLATFORM_AMD) {
-            return len >= MAX_JIT_LEN_AMD;
-        }
-        return len >= MAX_JIT_LEN;
-    }
-
     template<typename T>
     Array<T> createNodeArray(const dim4 &dims, Node_ptr node)
     {
@@ -177,8 +167,8 @@ namespace opencl
         n->getInfo(length, buf_count, bytes);
         n->resetFlags();
 
-        if (is_max_jit_len(length) ||
-            buf_count >= MAX_BUFFERS ||
+        if (length > getMaxJitSize() ||
+            buf_count >= getMaxBuffers() ||
             bytes >= getMaxBytes()) {
             out.eval();
         }
diff --git a/src/backend/opencl/platform.cpp b/src/backend/opencl/platform.cpp
index 9dbb3ca..6855e79 100644
--- a/src/backend/opencl/platform.cpp
+++ b/src/backend/opencl/platform.cpp
@@ -776,6 +776,28 @@ bool synchronize_calls() {
     return sync;
 }
 
+
+unsigned getMaxJitSize()
+{
+    const int MAX_JIT_LEN = 20;
+    const int MAX_JIT_LEN_AMD = 16; //FIXME: Change this when bug is fixed
+
+    static int length = 0;
+    if (length == 0) {
+        std::string env_var = getEnvVar("AF_OPENCL_MAX_JIT_LEN");
+        if (!env_var.empty()) {
+            length = std::stoi(env_var);
+        } else {
+            length = MAX_JIT_LEN;
+        }
+    }
+
+    if (getActivePlatform() == AFCL_PLATFORM_AMD) {
+        return std::min(length, MAX_JIT_LEN_AMD);
+    }
+    return length;
+}
+
 }
 
 using namespace opencl;
diff --git a/src/backend/opencl/platform.hpp b/src/backend/opencl/platform.hpp
index 9b5377d..4c745e0 100644
--- a/src/backend/opencl/platform.hpp
+++ b/src/backend/opencl/platform.hpp
@@ -98,6 +98,8 @@ int getDeviceCount();
 
 int getActiveDeviceId();
 
+unsigned getMaxJitSize();
+
 const cl::Context& getContext();
 
 cl::CommandQueue& getQueue();

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