[python-arrayfire] 39/58: Check and load a functional backend
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 d8db269942e92a9eeab482d1dc5b3d6788e31122
Author: pradeep <pradeep at arrayfire.com>
Date: Sun Sep 18 22:17:39 2016 +0530
Check and load a functional backend
Though libraries of a given backend can be present on the target
machine, there can be scenarios where a compatible hardware device
is not available. In such cases, backend loader checks if current
selected backend has a device ready for use. If no appropriate
device exists, the next backend in the priority list is checked
for same criteria. This process is repeated until a working
backend is found. In the event that no functional backend is found,
the program throws a runtime error.
---
arrayfire/library.py | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/arrayfire/library.py b/arrayfire/library.py
index cbf85f2..93d3cd5 100644
--- a/arrayfire/library.py
+++ b/arrayfire/library.py
@@ -534,9 +534,23 @@ class _clibrary(object):
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)
+ raise RuntimeError("Could not load any ArrayFire libraries.\n" + more_info_str)
def get_id(self, name):
return self.__backend_name_map[name]
--
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