[Libreoffice-commits] core.git: configure.ac sc/source

Tor Lillqvist tml at iki.fi
Sat Jul 13 23:29:41 PDT 2013


 configure.ac                            |   17 ++++++++---------
 sc/source/core/opencl/openclwrapper.cxx |   16 ++++++++--------
 sc/source/core/opencl/openclwrapper.hxx |   14 ++++++++++++++
 3 files changed, 30 insertions(+), 17 deletions(-)

New commits:
commit 46894ec48eb33dc99dab807c9fcaf0caa7c6cd84
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sat Jul 13 22:54:17 2013 +0300

    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

diff --git a/configure.ac b/configure.ac
index 6f5fe8dd..cc439e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9811,15 +9811,14 @@ OPENCL_LIBS=
 OPENCL_CFLAGS=
 ENABLE_OPENCL=
 AC_MSG_CHECKING([OpenCL])
-dnl if test \( -z "$with_opencl_sdk" -o "$with_opencl_sdk" = yes \) -a $_os = Darwin; then
-dnl    # OS X
-dnl    AC_MSG_RESULT([yes, always on OS X])
-dnl    ENABLE_OPENCL=TRUE
-dnl    OPENCL_CFLAGS=
-dnl    OPENCL_LIBS="-framework OpenCL"
-dnl    AC_DEFINE(HAVE_FEATURE_OPENCL)
-dnl
-if test -z "$with_opencl_sdk" -o "$with_opencl_sdk" = no; then
+if test \( -z "$with_opencl_sdk" -o "$with_opencl_sdk" = yes \) -a $_os = Darwin; then
+   # OS X
+   AC_MSG_RESULT([yes, always on OS X])
+   ENABLE_OPENCL=TRUE
+   OPENCL_CFLAGS=
+   OPENCL_LIBS="-framework OpenCL"
+   AC_DEFINE(HAVE_FEATURE_OPENCL)
+elif test -z "$with_opencl_sdk" -o "$with_opencl_sdk" = no; then
     AC_MSG_RESULT([no])
 else
     if test -d "$with_opencl_sdk/include"; then
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index f767479..584d533 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 d83b7c8..1c798f1 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


More information about the Libreoffice-commits mailing list