Kaydet (Commit) d0fdae78 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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
üst 9ab2ecd0
...@@ -36,7 +36,8 @@ $(eval $(call gb_Library_use_libraries,scopencl,\ ...@@ -36,7 +36,8 @@ $(eval $(call gb_Library_use_libraries,scopencl,\
$(eval $(call gb_Library_add_exception_objects,scopencl,\ $(eval $(call gb_Library_add_exception_objects,scopencl,\
sc/source/core/opencl/formulagroupcl \ sc/source/core/opencl/formulagroupcl \
sc/source/core/opencl/openclwrapper \ 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) ifeq ($(OS),LINUX)
...@@ -45,4 +46,10 @@ $(eval $(call gb_Library_add_libs,scopencl,\ ...@@ -45,4 +46,10 @@ $(eval $(call gb_Library_add_libs,scopencl,\
)) ))
endif endif
ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_add_libs,scopencl,\
-framework OpenCL \
))
endif
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
fprintf(stderr,"[OCL_ERROR] %s\n",str); fprintf(stderr,"[OCL_ERROR] %s\n",str);
#define OPENCL_DLL_NAME "OpenCL.dll" #define OPENCL_DLL_NAME "OpenCL.dll"
#else #elif !defined(MACOSX)
#define OPENCL_DLL_NAME "libOpenCL.so" #define OPENCL_DLL_NAME "libOpenCL.so"
#endif #endif
...@@ -2609,9 +2609,11 @@ bool createPlatformInfo(cl_platform_id nPlatformId, OpenclPlatformInfo& rPlatfor ...@@ -2609,9 +2609,11 @@ bool createPlatformInfo(cl_platform_id nPlatformId, OpenclPlatformInfo& rPlatfor
size_t getOpenCLPlatformCount() size_t getOpenCLPlatformCount()
{ {
#ifndef MACOSX
int status = clewInit(OPENCL_DLL_NAME); int status = clewInit(OPENCL_DLL_NAME);
if (status < 0) if (status < 0)
return 0; return 0;
#endif
cl_uint nPlatforms; cl_uint nPlatforms;
cl_int nState = clGetPlatformIDs(0, NULL, &nPlatforms); cl_int nState = clGetPlatformIDs(0, NULL, &nPlatforms);
...@@ -2628,9 +2630,11 @@ const std::vector<OpenclPlatformInfo>& fillOpenCLInfo() ...@@ -2628,9 +2630,11 @@ const std::vector<OpenclPlatformInfo>& fillOpenCLInfo()
if(!aPlatforms.empty()) if(!aPlatforms.empty())
return aPlatforms; return aPlatforms;
#ifndef MACOSX
int status = clewInit(OPENCL_DLL_NAME); int status = clewInit(OPENCL_DLL_NAME);
if (status < 0) if (status < 0)
return aPlatforms; return aPlatforms;
#endif
cl_uint nPlatforms; cl_uint nPlatforms;
cl_int nState = clGetPlatformIDs(0, NULL, &nPlatforms); cl_int nState = clGetPlatformIDs(0, NULL, &nPlatforms);
......
...@@ -21,8 +21,16 @@ ...@@ -21,8 +21,16 @@
#include <rtl/string.hxx> #include <rtl/string.hxx>
#ifdef MACOSX
#include <OpenCL/cl.h>
#else
#include "clcc/clew.h" #include "clcc/clew.h"
#endif
// CL_MAP_WRITE_INVALIDATE_REGION is new in OpenCL 1.2. // CL_MAP_WRITE_INVALIDATE_REGION is new in OpenCL 1.2.
// When compiling against an older OpenCL, use CL_MAP_WRITE. // When compiling against an older OpenCL, use CL_MAP_WRITE.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment