[arrayfire] 162/284: Added helper functions for device type and unified mem in OpenCL

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:29 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 a1823b3efd981f008bc1884dcd22935f4467cf9c
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Thu Jan 7 14:44:09 2016 -0500

    Added helper functions for device type and unified mem in OpenCL
---
 src/backend/opencl/platform.cpp | 24 ++++++++++++++++++++++++
 src/backend/opencl/platform.hpp |  6 ++++++
 2 files changed, 30 insertions(+)

diff --git a/src/backend/opencl/platform.cpp b/src/backend/opencl/platform.cpp
index 0cd46d2..005f2c1 100644
--- a/src/backend/opencl/platform.cpp
+++ b/src/backend/opencl/platform.cpp
@@ -256,6 +256,10 @@ std::string getInfo()
                  << (device.getInfo<CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE>()>0 ? "True" : "False")
                  << ")";
 #endif
+            // TODO Move this inside debug
+            info << "Unified Memory("
+                 << (isHostUnifiedMemory(device) ? "True" : "False")
+                 << ")";
             info << std::endl;
 
             nDevices++;
@@ -311,6 +315,26 @@ const cl::Device& getDevice()
     return *(devMngr.mDevices[devMngr.mActiveQId]);
 }
 
+cl_device_type getDeviceType()
+{
+    cl::Device device = getDevice();
+    cl_device_type type = device.getInfo<CL_DEVICE_TYPE>();
+    return type;
+}
+
+bool isHostUnifiedMemory(const cl::Device &device)
+{
+    return device.getInfo<CL_DEVICE_HOST_UNIFIED_MEMORY>();
+}
+
+bool OpenCLCPUOffload()
+{
+    static const bool sync = getEnvVar("AF_OPENCL_CPU_OFFLOAD") == "1";
+    bool offload = false;
+    if(sync) offload = isHostUnifiedMemory(getDevice());
+    return offload;
+}
+
 bool isGLSharingSupported()
 {
     DeviceManager& devMngr = DeviceManager::getInstance();
diff --git a/src/backend/opencl/platform.hpp b/src/backend/opencl/platform.hpp
index 84cb7b8..85c533f 100644
--- a/src/backend/opencl/platform.hpp
+++ b/src/backend/opencl/platform.hpp
@@ -97,6 +97,12 @@ cl::CommandQueue& getQueue();
 
 const cl::Device& getDevice();
 
+cl_device_type getDeviceType();
+
+bool isHostUnifiedMemory(const cl::Device &device);
+
+bool OpenCLCPUOffload();
+
 bool isGLSharingSupported();
 
 bool isDoubleSupported(int device);

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