[arrayfire] 52/284: cpp wrappers for opencl external context related fns
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:18 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 f65ee89baf9270bdd1b85c8317c87820f283d57f
Author: pradeep <pradeep at arrayfire.com>
Date: Fri Dec 4 14:19:54 2015 -0500
cpp wrappers for opencl external context related fns
---
include/af/opencl.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/include/af/opencl.h b/include/af/opencl.h
index 99080a5..0aa8981 100644
--- a/include/af/opencl.h
+++ b/include/af/opencl.h
@@ -194,6 +194,61 @@ namespace afcl
}
#endif
+#if AF_API_VERSION >= 33
+/**
+ Push user provided device control constructs into the ArrayFire device manager pool
+
+ This function should be used only when the user would like ArrayFire to use an
+ user generated OpenCL context and related objects for ArrayFire operations.
+
+ \param[in] dev is the OpenCL device for which user provided context will be used by ArrayFire
+ \param[in] ctx is the user provided OpenCL cl_context to be used by ArrayFire
+ \param[in] que is the user provided OpenCL cl_command_queue to be used by ArrayFire. If this
+ parameter is NULL, then we create a command queue for the user using the OpenCL
+ context they provided us.
+
+ \note The cl_* objects are passed onto c++ objects (cl::Device, cl::Context & cl::CommandQueue)
+ that are defined in the `cl.hpp` OpenCL c++ header provided by Khronos Group Inc. Therefore, please
+ be aware of the lifetime of the cl_* objects before passing them to ArrayFire.
+*/
+static inline void pushDevice(cl_device_id dev, cl_context ctx, cl_command_queue que)
+{
+ af_err err = afcl_push_device_context(dev, ctx, que);
+ if (err!=AF_SUCCESS) throw af::exception("Failed to push user provided device/context to ArrayFire pool");
+}
+
+/**
+ Set active device using cl_context and cl_device_id
+
+ \param[in] dev is the OpenCL device id that is to be set as Active device inside ArrayFire
+ \param[in] ctx is the OpenCL cl_context being used by ArrayFire
+*/
+static inline void setDevice(cl_device_id dev, cl_context ctx)
+{
+ af_err err = afcl_set_device_context(dev, ctx);
+ if (err!=AF_SUCCESS) throw af::exception("Failed to set device based on cl_device_id & cl_context");
+}
+
+/**
+ Remove the user provided device control constructs from the ArrayFire device manager pool
+
+ This function should be used only when the user would like ArrayFire to remove an already
+ pushed user generated OpenCL context and related objects.
+
+ \param[in] dev is the OpenCL device id that has to be popped
+ \param[in] ctx is the cl_context object to be removed from ArrayFire pool
+
+ \note Any reference counts incremented for cl_* objects by ArrayFire internally are decremented
+ by this func call and you won't be able to call `afcl_set_device_context` on these objects after
+ this function has been called.
+*/
+static inline void popDevice(cl_device_id dev, cl_context ctx)
+{
+ af_err err = afcl_pop_device_context(dev, ctx);
+ if (err!=AF_SUCCESS) throw af::exception("Failed to remove the requested device from ArrayFire device pool");
+}
+#endif
+
/**
Create an af::array object from an OpenCL cl_mem buffer
--
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