[python-arrayfire] 180/250: Functions specific to opencl backend

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 28 22:59:46 UTC 2016


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

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

commit 92af636362126bc04b74188904df92ec5af80df5
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Fri Dec 11 15:37:36 2015 -0500

    Functions specific to opencl backend
---
 arrayfire/opencl.py | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)

diff --git a/arrayfire/opencl.py b/arrayfire/opencl.py
new file mode 100644
index 0000000..5c075df
--- /dev/null
+++ b/arrayfire/opencl.py
@@ -0,0 +1,109 @@
+#######################################################
+# Copyright (c) 2015, ArrayFire
+# All rights reserved.
+#
+# This file is distributed under 3-clause BSD license.
+# The complete license agreement can be obtained at:
+# http://arrayfire.com/licenses/BSD-3-Clause
+########################################################
+
+"""
+Functions specific to OpenCL backend.
+
+This module provides interoperability with other OpenCL libraries.
+"""
+
+def get_context(retain=False):
+    """
+    Get the current OpenCL context being used by ArrayFire.
+
+    Parameters
+    ----------
+
+    retain : bool. optional. Default: False.
+        Specifies if the context needs to be retained by arrayfire before returning.
+
+    Returns
+    -----------
+    context : integer denoting the context id.
+    """
+
+    import ctypes as ct
+    from .util import safe_call as safe_call
+    from .library import backend as backend
+
+    if (backend.name() != "opencl"):
+        raise RuntimeError("Invalid backend loaded")
+
+    context = ct.c_void_p(0)
+    safe_call(backend.get().afcl_get_context(ct.pointer(context), retain))
+    return context.value
+
+def get_queue(retain):
+    """
+    Get the current OpenCL command queue being used by ArrayFire.
+
+    Parameters
+    ----------
+
+    retain : bool. optional. Default: False.
+        Specifies if the context needs to be retained by arrayfire before returning.
+
+    Returns
+    -----------
+    queue : integer denoting the queue id.
+    """
+
+    import ctypes as ct
+    from .util import safe_call as safe_call
+    from .library import backend as backend
+
+    if (backend.name() != "opencl"):
+        raise RuntimeError("Invalid backend loaded")
+
+    queue = ct.c_int(0)
+    safe_call(backend.get().afcl_get_queue(ct.pointer(queue), retain))
+    return queue.value
+
+def get_device_id():
+    """
+    Get native (unsorted) OpenCL device ID
+
+    Returns
+    --------
+
+    idx : int.
+        Specifies the `cl_device_id` of the device.
+    """
+
+    import ctypes as ct
+    from .util import safe_call as safe_call
+    from .library import backend as backend
+
+    if (backend.name() != "opencl"):
+        raise RuntimeError("Invalid backend loaded")
+
+    idx = ct.c_int(0)
+    safe_call(backend.get().afcl_get_device_id(ct.pointer(idx)))
+    return idx.value
+
+def set_device_id(idx):
+    """
+    Set native (unsorted) OpenCL device ID
+
+    Parameters
+    ----------
+
+    idx : int.
+        Specifies the `cl_device_id` of the device.
+    """
+
+    import ctypes as ct
+    from .util import safe_call as safe_call
+    from .library import backend as backend
+
+    if (backend.name() != "opencl"):
+        raise RuntimeError("Invalid backend loaded")
+
+    safe_call(backend.get().afcl_set_device_id(idx))
+    return

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