[Libreoffice-commits] core.git: include/opencl opencl/source

Tor Lillqvist tml at collabora.com
Thu Feb 5 05:03:57 PST 2015


 include/opencl/openclwrapper.hxx |    8 --------
 opencl/source/openclwrapper.cxx  |   14 ++++++++++++++
 2 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit 119d9c33b03790d52d57a27854064ec554a5777c
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Feb 5 13:16:09 2015 +0200

    The horrible CHECK_OPENCL() fortunately is used only in openclwrapper.cxx
    
    So move it there. While at it, make it use SAL_WARN() instead of
    printf.
    
    Also, add a few more SAL_WARN() and SAL_INFO().
    
    Change-Id: Ib058fb20d07757331ca364a8d7649abc59e9494b

diff --git a/include/opencl/openclwrapper.hxx b/include/opencl/openclwrapper.hxx
index d869819..9fde5d6 100644
--- a/include/opencl/openclwrapper.hxx
+++ b/include/opencl/openclwrapper.hxx
@@ -24,14 +24,6 @@
 #include <osl/file.hxx>
 #include <rtl/string.hxx>
 
-
-#define CHECK_OPENCL(status,name)    \
-if( status != CL_SUCCESS )    \
-{    \
-    printf ("OpenCL error code is %d at " SAL_DETAIL_WHERE " when %s .\n", status, name);    \
-    return false;    \
-}
-
 #define MAX_CLFILE_NUM 50
 #define OPENCL_CMDQUEUE_SIZE 1 // number of command queues per OpenCL device.
 
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index 64a84cd..db53a04 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -44,6 +44,13 @@
 #define DRIVER_VERSION_LENGTH 1024
 #define PLATFORM_VERSION_LENGTH 1024
 
+#define CHECK_OPENCL(status,name) \
+if( status != CL_SUCCESS )  \
+{ \
+    SAL_WARN( "opencl", "OpenCL error code " << status << " at " SAL_DETAIL_WHERE " from " name ); \
+    return false; \
+}
+
 using namespace std;
 
 namespace opencl {
@@ -762,6 +769,8 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
     cps[1] = reinterpret_cast<cl_context_properties>(platformId);
     cps[2] = 0;
     cl_context context = clCreateContext( cps, 1, &pDeviceId, NULL, NULL, &nState );
+    if (nState != CL_SUCCESS)
+        SAL_WARN("opencl", "clCreateContext failed: " << nState);
 
     if(nState != CL_SUCCESS || context == NULL)
     {
@@ -771,12 +780,15 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
         SAL_WARN("opencl", "failed to set/switch opencl device");
         return false;
     }
+    SAL_INFO("opencl", "Created context " << context << " for platform " << platformId << ", device " << pDeviceId);
 
     cl_command_queue command_queue[OPENCL_CMDQUEUE_SIZE];
     for (int i = 0; i < OPENCL_CMDQUEUE_SIZE; ++i)
     {
         command_queue[i] = clCreateCommandQueue(
             context, pDeviceId, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &nState);
+        if (nState != CL_SUCCESS)
+            SAL_WARN("opencl", "clCreateCommandQueue failed: " << nState);
 
         if (command_queue[i] == NULL || nState != CL_SUCCESS)
         {
@@ -794,6 +806,8 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
             SAL_WARN("opencl", "failed to set/switch opencl device");
             return false;
         }
+
+        SAL_INFO("opencl", "Created command queue " << command_queue[i] << " for context " << context);
     }
 
     setOpenCLCmdQueuePosition(0); // Call this just to avoid the method being deleted from unused function deleter.


More information about the Libreoffice-commits mailing list