[python-arrayfire] 40/58: Check if arrayfire can be run immediately after loading the library

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Sep 28 13:57:07 UTC 2016


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

ghisvail-guest pushed a commit to branch master
in repository python-arrayfire.

commit 2f8503d8a60c402f751a065334d7ce7065dbfdb0
Author: Pavan Yalamanchili <contact at pavanky.com>
Date:   Thu Sep 22 14:45:48 2016 -0700

    Check if arrayfire can be run immediately after loading the library
---
 arrayfire/library.py | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/arrayfire/library.py b/arrayfire/library.py
index 93d3cd5..fc76c9f 100644
--- a/arrayfire/library.py
+++ b/arrayfire/library.py
@@ -521,6 +521,10 @@ class _clibrary(object):
             except:
                 pass
 
+        c_dim4 = c_dim_t*4
+        out = ct.c_void_p(0)
+        dims = c_dim4(10, 10, 1, 1)
+
         # Iterate in reverse order of preference
         for name in ('cpu', 'opencl', 'cuda', ''):
             libnames = self.__libname(name)
@@ -528,27 +532,16 @@ class _clibrary(object):
                 try:
                     ct.cdll.LoadLibrary(libname)
                     __name = 'unified' if name == '' else name
-                    self.__clibs[__name] = ct.CDLL(libname)
-                    self.__name = __name
+                    clib = ct.CDLL(libname)
+                    self.__clibs[__name] = clib
+                    err = clib.af_randu(ct.pointer(out), 4, ct.pointer(dims), Dtype.f32.value)
+                    if (err == ERR.NONE.value):
+                        self.__name = __name
+                        clib.af_release_array(out)
                     break;
                 except:
                     pass
 
-        c_dim4 = c_dim_t*4
-
-        out = c_dim_t(0)
-        dims = c_dim4(10, 10, 10, 10)
-
-        for key, value in self.__clibs:
-            err = value.af_randu(ct.pointer(out), 4, ct.pointer(dims), 0)
-            if (err == ERR.NONE.value):
-                if (self.__name != key):
-                    self.__name = key
-                break
-            else:
-                self.__name = None
-                pass
-
         if (self.__name is None):
             raise RuntimeError("Could not load any ArrayFire libraries.\n" + more_info_str)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-arrayfire.git



More information about the debian-science-commits mailing list