[Libreoffice-commits] core.git: Branch 'feature/calc-pluggable-opencl' - sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Sep 16 11:17:24 PDT 2013


 sc/source/core/opencl/openclwrapper.cxx |   72 +++++++++++++++++++++-----------
 1 file changed, 49 insertions(+), 23 deletions(-)

New commits:
commit c7f043f5abaf19fce179ebf5f9b8053202e6841a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Sep 16 20:08:32 2013 +0200

    only list opencl devices with double support
    
    Change-Id: I90eec86fff08fd20f4567551932bf328adc85859

diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index ea2d754..511c8df 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -729,6 +729,42 @@ int OpenclDevice::initOpenclRunEnv( int argc )
     return 0;
 }
 
+namespace {
+
+void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bAmdFp64)
+{
+    bKhrFp64 = false;
+    bAmdFp64 = false;
+
+    // Check device extensions for double type
+    size_t aDevExtInfoSize = 0;
+
+    cl_uint clStatus = clGetDeviceInfo( deviceId, CL_DEVICE_EXTENSIONS, 0, NULL, &aDevExtInfoSize );
+    if( clStatus != CL_SUCCESS )
+        return;
+
+    boost::scoped_array<char> pExtInfo(new char[aDevExtInfoSize]);
+
+    clStatus = clGetDeviceInfo( deviceId, CL_DEVICE_EXTENSIONS,
+                   sizeof(char) * aDevExtInfoSize, pExtInfo.get(), NULL);
+
+    if( clStatus != CL_SUCCESS )
+        return;
+
+    if ( strstr( pExtInfo.get(), "cl_khr_fp64" ) )
+    {
+        bKhrFp64 = true;
+    }
+    else
+    {
+        // Check if cl_amd_fp64 extension is supported
+        if ( strstr( pExtInfo.get(), "cl_amd_fp64" ) )
+            bAmdFp64 = true;
+    }
+}
+
+}
+
 int OpenclDevice::initOpenclRunEnv( GPUEnv *gpuInfo )
 {
     size_t length;
@@ -859,32 +895,14 @@ int OpenclDevice::initOpenclRunEnv( GPUEnv *gpuInfo )
     }
 
     clStatus = clGetCommandQueueInfo( gpuInfo->mpCmdQueue, CL_QUEUE_THREAD_HANDLE_AMD, 0, NULL, NULL );
-    // Check device extensions for double type
-    size_t aDevExtInfoSize = 0;
-
-    clStatus = clGetDeviceInfo( gpuInfo->mpArryDevsID[0], CL_DEVICE_EXTENSIONS, 0, NULL, &aDevExtInfoSize );
-    CHECK_OPENCL( clStatus, "clGetDeviceInfo" );
-
-    char *aExtInfo = new char[aDevExtInfoSize];
 
-    clStatus = clGetDeviceInfo( gpuInfo->mpArryDevsID[0], CL_DEVICE_EXTENSIONS,
-                   sizeof(char) * aDevExtInfoSize, aExtInfo, NULL);
-    CHECK_OPENCL( clStatus, "clGetDeviceInfo" );
+    bool bKhrFp64 = false;
+    bool bAmdFp64 = false;
 
-    gpuInfo->mnKhrFp64Flag = 0;
-    gpuInfo->mnAmdFp64Flag = 0;
+    checkDeviceForDoubleSupport(gpuInfo->mpArryDevsID[0], bKhrFp64, bAmdFp64);
 
-    if ( strstr( aExtInfo, "cl_khr_fp64" ) )
-    {
-        gpuInfo->mnKhrFp64Flag = 1;
-    }
-    else
-    {
-        // Check if cl_amd_fp64 extension is supported
-        if ( strstr( aExtInfo, "cl_amd_fp64" ) )
-            gpuInfo->mnAmdFp64Flag = 1;
-    }
-    delete []aExtInfo;
+    gpuInfo->mnKhrFp64Flag = bKhrFp64;
+    gpuInfo->mnAmdFp64Flag = bAmdFp64;
 
     return 0;
 }
@@ -2675,6 +2693,14 @@ void createDeviceInfo(cl_device_id aDeviceId, OpenclPlatformInfo& rPlatformInfo)
     if(nState != CL_SUCCESS)
         return;
 
+    bool bKhrFp64 = false;
+    bool bAmdFp64 = false;
+    checkDeviceForDoubleSupport(aDeviceId, bKhrFp64, bAmdFp64);
+
+    // only list devices that support double
+    if(!bKhrFp64 && !bAmdFp64)
+        return;
+
     aDeviceInfo.mnComputeUnits = nComputeUnits;
 
     rPlatformInfo.maDevices.push_back(aDeviceInfo);


More information about the Libreoffice-commits mailing list