[arrayfire] 60/248: Change unified backend priority. Add af/backend.h to arrayfire.h

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:53:56 UTC 2015


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

ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.

commit 4a0f164e970238c8d0e3f11d1c321cd77142ae08
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Fri Sep 18 10:26:41 2015 -0400

    Change unified backend priority. Add af/backend.h to arrayfire.h
    
    * Priority is now CUDA -> OpenCL -> CPU
---
 include/arrayfire.h                |  1 +
 src/api/unified/symbol_manager.cpp | 15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/arrayfire.h b/include/arrayfire.h
index ff6a3e5..4cbbebd 100644
--- a/include/arrayfire.h
+++ b/include/arrayfire.h
@@ -270,6 +270,7 @@
 #include "af/algorithm.h"
 #include "af/arith.h"
 #include "af/array.h"
+#include "af/backend.h"
 #include "af/blas.h"
 #include "af/constants.h"
 #include "af/complex.h"
diff --git a/src/api/unified/symbol_manager.cpp b/src/api/unified/symbol_manager.cpp
index 752e007..534a7ec 100644
--- a/src/api/unified/symbol_manager.cpp
+++ b/src/api/unified/symbol_manager.cpp
@@ -116,10 +116,17 @@ AFSymbolManager& AFSymbolManager::getInstance()
 AFSymbolManager::AFSymbolManager()
     : activeHandle(NULL), defaultHandle(NULL), numBackends(0)
 {
-    for(int i=0; i<NUM_BACKENDS; ++i) {
-        bkndHandles[i] = openDynLibrary(i);
-        if (bkndHandles[i]) {
-            activeHandle = bkndHandles[i];
+    // In reverse order of priority. The last successful backend loaded will be
+    // the most prefered one.
+    static const int order[] = {AF_BACKEND_CPU,
+                                AF_BACKEND_OPENCL,
+                                AF_BACKEND_CUDA};
+
+    for(int i = 0; i < NUM_BACKENDS; ++i) {
+        int backend = order[i] - 1;
+        bkndHandles[backend] = openDynLibrary(backend);
+        if (bkndHandles[backend]) {
+            activeHandle = bkndHandles[backend];
             numBackends++;
         }
     }

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