diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-07-13 22:54:17 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-07-14 09:27:55 +0300 |
commit | 46894ec48eb33dc99dab807c9fcaf0caa7c6cd84 (patch) | |
tree | 1373cf49bcd8d7e173ed87e3853bbc575a7e117b /sc | |
parent | 542b45af44cae091735d9c2e11756a928e230261 (diff) |
Use CL_MAP_WRITE_INVALIDATE_REGION only if defined (in OpenCL 1.2)
Can again turn on OpenCL by default for OS X then, hopefully.
Change-Id: Id84b2c17c8431080261be45923d8c153f3822e8b
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/openclwrapper.cxx | 16 | ||||
-rw-r--r-- | sc/source/core/opencl/openclwrapper.hxx | 14 |
2 files changed, 22 insertions, 8 deletions
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx index f7674795837b..584d533baabc 100644 --- a/sc/source/core/opencl/openclwrapper.cxx +++ b/sc/source/core/opencl/openclwrapper.cxx @@ -1115,9 +1115,9 @@ int OclCalc::OclHostFormulaAverage(double *srcData,int *start,int *end,double *o cl_mem outputCl = clCreateBuffer(kEnv.mpkContext, (cl_mem_flags) (CL_MEM_READ_WRITE), size* sizeof(float), NULL, &ret); - float * hostMapSrc = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,inputCl,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,alignSize * sizeof(float),0,NULL,NULL,NULL); - int * hostMapStart = (int *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,startCl,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,size * sizeof(unsigned int),0,NULL,NULL,NULL); - int * hostMapEnd = (int *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,endCl,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,size * sizeof(unsigned int),0,NULL,NULL,NULL); + float * hostMapSrc = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,inputCl,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,alignSize * sizeof(float),0,NULL,NULL,NULL); + int * hostMapStart = (int *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,startCl,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,size * sizeof(unsigned int),0,NULL,NULL,NULL); + int * hostMapEnd = (int *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,endCl,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,size * sizeof(unsigned int),0,NULL,NULL,NULL); #if 1 for(int i=0;i<size;i++) { @@ -1440,11 +1440,11 @@ int OclCalc::CreateBuffer(float *&fpSrcData,uint *&npStartPos,uint *&npEndPos,in nBufferSize * sizeof(unsigned int), NULL, &clStatus); CHECK_OPENCL(clStatus); - fpSrcData = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemSrcData,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,nBufferSize * sizeof(float),0,NULL,NULL,&clStatus); + fpSrcData = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemSrcData,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,nBufferSize * sizeof(float),0,NULL,NULL,&clStatus); CHECK_OPENCL(clStatus); - npStartPos = (uint *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemStartPos,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,nBufferSize * sizeof(uint),0,NULL,NULL,&clStatus); + npStartPos = (uint *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemStartPos,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,nBufferSize * sizeof(uint),0,NULL,NULL,&clStatus); CHECK_OPENCL(clStatus); - npEndPos = (uint *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemEndPos,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,nBufferSize * sizeof(uint),0,NULL,NULL,&clStatus); + npEndPos = (uint *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemEndPos,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,nBufferSize * sizeof(uint),0,NULL,NULL,&clStatus); CHECK_OPENCL(clStatus); //printf("In CreateBuffer, pptrr is %d,%d,%d\n",fpSrcData,npStartPos,npEndPos); return 0; @@ -1461,9 +1461,9 @@ int OclCalc::CreateBuffer(float *&fpLeftData,float *&fpRightData,int nBufferSize mpClmemRightData = clCreateBuffer(kEnv.mpkContext, (cl_mem_flags) (CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR), nBufferSize * sizeof(unsigned int), NULL, &clStatus); CHECK_OPENCL(clStatus); - fpLeftData = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemLeftData,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,nBufferSize * sizeof(float),0,NULL,NULL,&clStatus); + fpLeftData = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemLeftData,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,nBufferSize * sizeof(float),0,NULL,NULL,&clStatus); CHECK_OPENCL(clStatus); - fpRightData = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemRightData,CL_TRUE,CL_MAP_WRITE_INVALIDATE_REGION,0,nBufferSize * sizeof(float),0,NULL,NULL,&clStatus); + fpRightData = (float *)clEnqueueMapBuffer(kEnv.mpkCmdQueue,mpClmemRightData,CL_TRUE,OPENCLWRAPPER_CL_MAP_WRITE_FLAG,0,nBufferSize * sizeof(float),0,NULL,NULL,&clStatus); CHECK_OPENCL(clStatus); //printf("In CreateBuffer, pptrr is %d,%d,%d\n",fpSrcData,npStartPos,npEndPos); return 0; diff --git a/sc/source/core/opencl/openclwrapper.hxx b/sc/source/core/opencl/openclwrapper.hxx index d83b7c8f535c..1c798f172964 100644 --- a/sc/source/core/opencl/openclwrapper.hxx +++ b/sc/source/core/opencl/openclwrapper.hxx @@ -20,6 +20,20 @@ #include <CL/cl.h> #endif +// CL_MAP_WRITE_INVALIDATE_REGION is new in OpenCL 1.2. + +// When compiling against an older OpenCL, use CL_MAP_WRITE. + +// FIXME: But what if this code has been compiled against OpenCL 1.2 +// headers but then runs against an OpenCL 1.1 implementation? +// Probably the code should check at run-time the version of the +// OpenCL implementation and choose which flag to use based on that. +#ifdef CL_MAP_WRITE_INVALIDATE_REGION +#define OPENCLWRAPPER_CL_MAP_WRITE_FLAG CL_MAP_WRITE_INVALIDATE_REGION +#else +#define OPENCLWRAPPER_CL_MAP_WRITE_FLAG CL_MAP_WRITE +#endif + #if defined(_MSC_VER) #ifndef strcasecmp #define strcasecmp strcmp |