[Libreoffice-commits] core.git: sc/Library_scopencl.mk sc/source

Tor Lillqvist tml at collabora.com
Sat Sep 28 14:29:04 PDT 2013


 sc/Library_scopencl.mk                  |    9 ++++++++-
 sc/source/core/opencl/openclwrapper.cxx |    6 +++++-
 sc/source/core/opencl/openclwrapper.hxx |    8 ++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)

New commits:
commit d0fdae78797979949ec7ead20ad52b901c8c7e9a
Author: Tor Lillqvist <tml at collabora.com>
Date:   Sat Sep 28 23:20:34 2013 +0200

    Fix OpenCL use on Mac
    
    Don't use glew but just include the <OpenCL/cl.h> which is present in
    the SDK and link to the OpenCL framework.
    
    Change-Id: I3e1c3773078bc5d2550be832a273273d89381dff

diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk
index 2942e47..c2ca1f3 100644
--- a/sc/Library_scopencl.mk
+++ b/sc/Library_scopencl.mk
@@ -36,7 +36,8 @@ $(eval $(call gb_Library_use_libraries,scopencl,\
 $(eval $(call gb_Library_add_exception_objects,scopencl,\
         sc/source/core/opencl/formulagroupcl \
         sc/source/core/opencl/openclwrapper \
-        sc/source/core/opencl/clcc/clew \
+        $(if $(filter-out MACOSX,$(OS)), \
+            sc/source/core/opencl/clcc/clew) \
 ))
 
 ifeq ($(OS),LINUX)
@@ -45,4 +46,10 @@ $(eval $(call gb_Library_add_libs,scopencl,\
 ))
 endif
 
+ifeq ($(OS),MACOSX)
+$(eval $(call gb_Library_add_libs,scopencl,\
+        -framework OpenCL \
+))
+endif
+
 # vim: set noet sw=4 ts=4:
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index bc51148..50bb0d1 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -41,7 +41,7 @@
         fprintf(stderr,"[OCL_ERROR] %s\n",str);
 
 #define OPENCL_DLL_NAME "OpenCL.dll"
-#else
+#elif !defined(MACOSX)
 #define OPENCL_DLL_NAME "libOpenCL.so"
 #endif
 
@@ -2609,9 +2609,11 @@ bool createPlatformInfo(cl_platform_id nPlatformId, OpenclPlatformInfo& rPlatfor
 
 size_t getOpenCLPlatformCount()
 {
+#ifndef MACOSX
     int status = clewInit(OPENCL_DLL_NAME);
     if (status < 0)
         return 0;
+#endif
 
     cl_uint nPlatforms;
     cl_int nState = clGetPlatformIDs(0, NULL, &nPlatforms);
@@ -2628,9 +2630,11 @@ const std::vector<OpenclPlatformInfo>& fillOpenCLInfo()
     if(!aPlatforms.empty())
         return aPlatforms;
 
+#ifndef MACOSX
     int status = clewInit(OPENCL_DLL_NAME);
     if (status < 0)
         return aPlatforms;
+#endif
 
     cl_uint nPlatforms;
     cl_int nState = clGetPlatformIDs(0, NULL, &nPlatforms);
diff --git a/sc/source/core/opencl/openclwrapper.hxx b/sc/source/core/opencl/openclwrapper.hxx
index c81c313..5fd3991 100644
--- a/sc/source/core/opencl/openclwrapper.hxx
+++ b/sc/source/core/opencl/openclwrapper.hxx
@@ -21,8 +21,16 @@
 
 #include <rtl/string.hxx>
 
+#ifdef MACOSX
+
+#include <OpenCL/cl.h>
+
+#else
+
 #include "clcc/clew.h"
 
+#endif
+
 // CL_MAP_WRITE_INVALIDATE_REGION is new in OpenCL 1.2.
 
 // When compiling against an older OpenCL, use CL_MAP_WRITE.


More information about the Libreoffice-commits mailing list