summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2013-09-28 23:20:34 +0200
committerTor Lillqvist <tml@collabora.com>2013-09-28 23:27:32 +0200
commitd0fdae78797979949ec7ead20ad52b901c8c7e9a (patch)
tree761e1d397b7a68b3e294f5b6e33b32c105bebfa4
parent9ab2ecd0c6b941b388a69c647c9caed97eb72cca (diff)
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
-rw-r--r--sc/Library_scopencl.mk9
-rw-r--r--sc/source/core/opencl/openclwrapper.cxx6
-rw-r--r--sc/source/core/opencl/openclwrapper.hxx8
3 files changed, 21 insertions, 2 deletions
diff --git a/sc/Library_scopencl.mk b/sc/Library_scopencl.mk
index 2942e4709f68..c2ca1f397189 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 bc51148c5ce7..50bb0d1602e1 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 c81c313dd96d..5fd39916211c 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.