[Libreoffice-commits] core.git: 3 commits - include/opencl opencl/inc opencl/source sc/source

Tor Lillqvist tml at collabora.com
Thu Nov 27 10:39:35 PST 2014


 include/opencl/openclwrapper.hxx         |   35 +------
 opencl/inc/opencl_device.hxx             |    2 
 opencl/source/opencl_device.cxx          |    3 
 opencl/source/openclwrapper.cxx          |  141 ++++++++++++++++---------------
 sc/source/core/opencl/formulagroupcl.cxx |   58 ++++++------
 5 files changed, 110 insertions(+), 129 deletions(-)

New commits:
commit abeef65da71732d8fd401fce52cc37a364aa7781
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Nov 27 18:03:35 2014 +0200

    Put the KernelEnv struct inside the opencl namespace, too
    
    Change-Id: I33d51b0e30445c34c792210e7c656c1d48159019

diff --git a/include/opencl/openclwrapper.hxx b/include/opencl/openclwrapper.hxx
index 6e520a7..5fd76ea 100644
--- a/include/opencl/openclwrapper.hxx
+++ b/include/opencl/openclwrapper.hxx
@@ -36,6 +36,8 @@ if( status != CL_SUCCESS )    \
 
 #include <cstdio>
 
+namespace opencl {
+
 struct KernelEnv
 {
     cl_context mpkContext;
@@ -43,8 +45,6 @@ struct KernelEnv
     cl_program mpkProgram;
 };
 
-namespace opencl {
-
 struct GPUEnv
 {
     //share vb in all modules in hb library
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 6ac2a5f..4fa3c5f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -113,7 +113,7 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program )
         throw Unhandled();
     }
     // Obtain cl context
-    KernelEnv kEnv;
+    ::opencl::KernelEnv kEnv;
     ::opencl::setKernelEnv(&kEnv);
     cl_int err;
     if (pHostBuffer)
@@ -204,7 +204,7 @@ public:
         }
         // marshaling
         // Obtain cl context
-        KernelEnv kEnv;
+        ::opencl::KernelEnv kEnv;
         ::opencl::setKernelEnv(&kEnv);
         // Pass the scalar result back to the rest of the formula kernel
         cl_int err = clSetKernelArg(k, argno, sizeof(cl_uint), (void*)&hashCode);
@@ -388,7 +388,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro
 {
     FormulaToken* ref = mFormulaTree->GetFormulaToken();
     // Obtain cl context
-    KernelEnv kEnv;
+    ::opencl::KernelEnv kEnv;
     ::opencl::setKernelEnv(&kEnv);
     cl_int err;
     formula::VectorRefArray vRef;
@@ -1131,7 +1131,7 @@ public:
     {
         assert(Base::mpClmem == NULL);
         // Obtain cl context
-        KernelEnv kEnv;
+        ::opencl::KernelEnv kEnv;
         ::opencl::setKernelEnv(&kEnv);
         cl_int err;
         size_t nInput = mpDVR->GetArrayLength();
@@ -1912,7 +1912,7 @@ public:
         if (OpGeoMean* OpSumCodeGen = dynamic_cast<OpGeoMean*>(mpCodeGen.get()))
         {
             // Obtain cl context
-            KernelEnv kEnv;
+            ::opencl::KernelEnv kEnv;
             ::opencl::setKernelEnv(&kEnv);
             cl_int err;
             cl_mem pClmem2;
@@ -1970,7 +1970,7 @@ public:
         if (OpSumIfs* OpSumCodeGen = dynamic_cast<OpSumIfs*>(mpCodeGen.get()))
         {
             // Obtain cl context
-            KernelEnv kEnv;
+            ::opencl::KernelEnv kEnv;
             ::opencl::setKernelEnv(&kEnv);
             cl_int err;
             DynamicKernelArgument* Arg = mvSubArguments[0].get();
@@ -3354,7 +3354,7 @@ public:
     void Launch( size_t nr )
     {
         // Obtain cl context
-        KernelEnv kEnv;
+        ::opencl::KernelEnv kEnv;
         ::opencl::setKernelEnv(&kEnv);
         cl_int err;
         // The results
@@ -3416,7 +3416,7 @@ void DynamicKernel::CreateKernel()
     std::string kname = "DynamicKernel" + mKernelSignature;
     // Compile kernel here!!!
     // Obtain cl context
-    KernelEnv kEnv;
+    ::opencl::KernelEnv kEnv;
     ::opencl::setKernelEnv(&kEnv);
     const char* src = mFullProgramSrc.c_str();
     static std::string lastOneKernelHash = "";
@@ -3667,7 +3667,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
     try
     {
         // Obtain cl context
-        KernelEnv kEnv;
+        ::opencl::KernelEnv kEnv;
         ::opencl::setKernelEnv(&kEnv);
         // Run the kernel.
         pKernel->Launch(xGroup->mnLength);
commit 52f9606ed0af7acdf330eb70b84d7c9bd6abdd52
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Nov 27 17:56:21 2014 +0200

    The OpenCLEnv struct is used only inside openclwrapper.cxx
    
    Change-Id: I95fbee302213e6ced469dd7a2a1c254178159357

diff --git a/include/opencl/openclwrapper.hxx b/include/opencl/openclwrapper.hxx
index 1a392e5..6e520a7 100644
--- a/include/opencl/openclwrapper.hxx
+++ b/include/opencl/openclwrapper.hxx
@@ -45,14 +45,6 @@ struct KernelEnv
 
 namespace opencl {
 
-struct OpenCLEnv
-{
-    cl_platform_id mpOclPlatformID;
-    cl_context mpOclContext;
-    cl_device_id mpOclDevsID;
-    cl_command_queue mpOclCmdQueue;
-};
-
 struct GPUEnv
 {
     //share vb in all modules in hb library
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index b181375..9ce2481 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -254,6 +254,14 @@ bool generatBinFromKernelSource( cl_program program, const char * clFileName )
 
 namespace {
 
+struct OpenCLEnv
+{
+    cl_platform_id mpOclPlatformID;
+    cl_context mpOclContext;
+    cl_device_id mpOclDevsID;
+    cl_command_queue mpOclCmdQueue;
+};
+
 bool initOpenCLAttr( OpenCLEnv * env )
 {
     if ( gpuEnv.mnIsUserCreated )
commit 598f25c85793aab78b5ecce733c65a66860d0c5c
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Nov 27 17:43:55 2014 +0200

    Clean up confusing OpenCL code a bit
    
    Get rid of the silly OpenCLDevice class that had only static members. We can
    as well just use namespacing. Remove functions only used internally in
    openclwrapper.cxx from the now public openclwrapper.hxx header.
    
    Change-Id: If7336edd262c772564dc13e64113d72d0b52428c

diff --git a/include/opencl/openclwrapper.hxx b/include/opencl/openclwrapper.hxx
index ba7aada..1a392e5 100644
--- a/include/opencl/openclwrapper.hxx
+++ b/include/opencl/openclwrapper.hxx
@@ -68,25 +68,10 @@ struct GPUEnv
     bool mnAmdFp64Flag;
 };
 
-class OPENCL_DLLPUBLIC OpenCLDevice
-{
-public:
-    static GPUEnv gpuEnv;
-    static bool bIsInited;
-    static OString maCacheFolder;
-
-    static bool initOpenCLRunEnv( GPUEnv *gpu );
-    static void releaseOpenCLEnv( GPUEnv *gpuInfo );
-    static bool initOpenCLRunEnv( int argc );
-    static bool generatBinFromKernelSource( cl_program program, const char * clFileName );
-    static bool writeBinaryToFile( const OString& rName, const char* birary, size_t numBytes );
-    static std::vector<boost::shared_ptr<osl::File> > binaryGenerated( const char * clFileName, cl_context context);
-    static bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuEnv, const char* filename, int idx);
-
-    static bool initOpenCLAttr( OpenCLEnv * env );
-    static void setKernelEnv( KernelEnv *envInfo );
-};
-
+extern OPENCL_DLLPUBLIC GPUEnv gpuEnv;
+OPENCL_DLLPUBLIC bool generatBinFromKernelSource( cl_program program, const char * clFileName );
+OPENCL_DLLPUBLIC bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuEnv, const char* filename, int idx);
+OPENCL_DLLPUBLIC void setKernelEnv( KernelEnv *envInfo );
 OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& fillOpenCLInfo();
 
 /**
diff --git a/opencl/inc/opencl_device.hxx b/opencl/inc/opencl_device.hxx
index 7435879..057e2f4 100644
--- a/opencl/inc/opencl_device.hxx
+++ b/opencl/inc/opencl_device.hxx
@@ -12,7 +12,7 @@
 
 #include "opencl_device_selection.h"
 
-namespace OpenCLDevice {
+namespace opencl {
 
 ds_device getDeviceSelection(const char* pFileName, bool bForceSelection = false);
 bool selectedDeviceIsOpenCL(ds_device device);
diff --git a/opencl/source/opencl_device.cxx b/opencl/source/opencl_device.cxx
index 204ab34..14eb703 100644
--- a/opencl/source/opencl_device.cxx
+++ b/opencl/source/opencl_device.cxx
@@ -44,9 +44,8 @@
     SAL_INFO("opencl.device", "Error code is " << status << " at " name); \
     }
 
-namespace OpenCLDevice {
+namespace opencl {
 
-bool bIsInited = false;
 bool bIsDeviceSelected = false;
 ds_device selectedDevice;
 
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index 86ba6cd..b181375 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -48,11 +48,12 @@ using namespace std;
 
 namespace opencl {
 
-GPUEnv OpenCLDevice::gpuEnv;
-bool OpenCLDevice::bIsInited = false;
+GPUEnv gpuEnv;
 
 namespace {
 
+bool bIsInited = false;
+
 OString generateMD5(const void* pData, size_t length)
 {
     sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_MD5];
@@ -81,11 +82,11 @@ OString getCacheFolder()
     return rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8);
 }
 
-}
+OString maCacheFolder = getCacheFolder();
 
-OString OpenCLDevice::maCacheFolder = getCacheFolder();
+}
 
-void OpenCLDevice::setKernelEnv( KernelEnv *envInfo )
+void setKernelEnv( KernelEnv *envInfo )
 {
     envInfo->mpkContext = gpuEnv.mpContext;
     envInfo->mpkCmdQueue = gpuEnv.mpCmdQueue;
@@ -121,13 +122,11 @@ OString createFileName(cl_device_id deviceId, const char* clFileName)
     OString aString = OString(deviceName) + driverVersion + platformVersion;
     OString aHash = generateMD5(aString.getStr(), aString.getLength());
 
-    return OpenCLDevice::maCacheFolder + fileName + "-" +
+    return maCacheFolder + fileName + "-" +
         aHash + ".bin";
 }
 
-}
-
-std::vector<boost::shared_ptr<osl::File> > OpenCLDevice::binaryGenerated( const char * clFileName, cl_context context )
+std::vector<boost::shared_ptr<osl::File> > binaryGenerated( const char * clFileName, cl_context context )
 {
     size_t numDevices=0;
 
@@ -170,7 +169,7 @@ std::vector<boost::shared_ptr<osl::File> > OpenCLDevice::binaryGenerated( const
     return aGeneratedFiles;
 }
 
-bool OpenCLDevice::writeBinaryToFile( const OString& rFileName, const char* binary, size_t numBytes )
+bool writeBinaryToFile( const OString& rFileName, const char* binary, size_t numBytes )
 {
     osl::File file(rtl::OStringToOUString(rFileName, RTL_TEXTENCODING_UTF8));
     osl::FileBase::RC status = file.open(
@@ -187,7 +186,9 @@ bool OpenCLDevice::writeBinaryToFile( const OString& rFileName, const char* bina
     return true;
 }
 
-bool OpenCLDevice::generatBinFromKernelSource( cl_program program, const char * clFileName )
+}
+
+bool generatBinFromKernelSource( cl_program program, const char * clFileName )
 {
     cl_uint numDevices;
 
@@ -251,7 +252,9 @@ bool OpenCLDevice::generatBinFromKernelSource( cl_program program, const char *
     return true;
 }
 
-bool OpenCLDevice::initOpenCLAttr( OpenCLEnv * env )
+namespace {
+
+bool initOpenCLAttr( OpenCLEnv * env )
 {
     if ( gpuEnv.mnIsUserCreated )
         return true;
@@ -266,7 +269,7 @@ bool OpenCLDevice::initOpenCLAttr( OpenCLEnv * env )
     return false;
 }
 
-void OpenCLDevice::releaseOpenCLEnv( GPUEnv *gpuInfo )
+void releaseOpenCLEnv( GPUEnv *gpuInfo )
 {
     if ( !bIsInited )
     {
@@ -290,8 +293,6 @@ void OpenCLDevice::releaseOpenCLEnv( GPUEnv *gpuInfo )
     return;
 }
 
-namespace {
-
 bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx)
 {
     cl_int clStatus;
@@ -342,7 +343,7 @@ bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx)
             return false;
         }
 
-        OString aBuildLogFileURL = OpenCLDevice::maCacheFolder + "kernel-build.log";
+        OString aBuildLogFileURL = maCacheFolder + "kernel-build.log";
         osl::File aBuildLogFile(rtl::OStringToOUString(aBuildLogFileURL, RTL_TEXTENCODING_UTF8));
         osl::FileBase::RC status = aBuildLogFile.open(
                 osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
@@ -361,7 +362,7 @@ bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx)
 
 }
 
-bool OpenCLDevice::buildProgramFromBinary(const char* buildOption, GPUEnv* gpuInfo, const char* filename, int idx)
+bool buildProgramFromBinary(const char* buildOption, GPUEnv* gpuInfo, const char* filename, int idx)
 {
     size_t numDevices;
     cl_int clStatus = clGetContextInfo( gpuInfo->mpContext, CL_CONTEXT_DEVICES,
@@ -428,45 +429,6 @@ bool OpenCLDevice::buildProgramFromBinary(const char* buildOption, GPUEnv* gpuIn
     return buildProgram(buildOption, gpuInfo, idx);
 }
 
-bool OpenCLDevice::initOpenCLRunEnv( int argc )
-{
-    if ( ( argc > MAX_CLFILE_NUM ) || ( argc < 0 ) )
-        return true;
-
-    if ( !bIsInited )
-    {
-        if ( !gpuEnv.mnIsUserCreated )
-            memset( &gpuEnv, 0, sizeof(gpuEnv) );
-
-        //initialize devices, context, command_queue
-        bool status = initOpenCLRunEnv( &gpuEnv );
-        if ( status )
-        {
-            return true;
-        }
-        //initialize program, kernelName, kernelCount
-        if( getenv( "SC_FLOAT" ) )
-        {
-            gpuEnv.mnKhrFp64Flag = false;
-            gpuEnv.mnAmdFp64Flag = false;
-        }
-        if( gpuEnv.mnKhrFp64Flag )
-        {
-            SAL_INFO("opencl", "Use Khr double");
-        }
-        else if( gpuEnv.mnAmdFp64Flag )
-        {
-            SAL_INFO("opencl", "Use AMD double type");
-        }
-        else
-        {
-            SAL_INFO("opencl", "USE float type");
-        }
-        bIsInited = true;
-    }
-    return false;
-}
-
 namespace {
 
 void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bAmdFp64)
@@ -501,9 +463,7 @@ void checkDeviceForDoubleSupport(cl_device_id deviceId, bool& bKhrFp64, bool& bA
     }
 }
 
-}
-
-bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo )
+bool initOpenCLRunEnv( GPUEnv *gpuInfo )
 {
     bool bKhrFp64 = false;
     bool bAmdFp64 = false;
@@ -516,7 +476,44 @@ bool OpenCLDevice::initOpenCLRunEnv( GPUEnv *gpuInfo )
     return false;
 }
 
-namespace {
+bool initOpenCLRunEnv( int argc )
+{
+    if ( ( argc > MAX_CLFILE_NUM ) || ( argc < 0 ) )
+        return true;
+
+    if ( !bIsInited )
+    {
+        if ( !gpuEnv.mnIsUserCreated )
+            memset( &gpuEnv, 0, sizeof(gpuEnv) );
+
+        //initialize devices, context, command_queue
+        bool status = initOpenCLRunEnv( &gpuEnv );
+        if ( status )
+        {
+            return true;
+        }
+        //initialize program, kernelName, kernelCount
+        if( getenv( "SC_FLOAT" ) )
+        {
+            gpuEnv.mnKhrFp64Flag = false;
+            gpuEnv.mnAmdFp64Flag = false;
+        }
+        if( gpuEnv.mnKhrFp64Flag )
+        {
+            SAL_INFO("opencl", "Use Khr double");
+        }
+        else if( gpuEnv.mnAmdFp64Flag )
+        {
+            SAL_INFO("opencl", "Use AMD double type");
+        }
+        else
+        {
+            SAL_INFO("opencl", "USE float type");
+        }
+        bIsInited = true;
+    }
+    return false;
+}
 
 // based on crashes and hanging during kernel compilation
 void createDeviceInfo(cl_device_id aDeviceId, OpenCLPlatformInfo& rPlatformInfo)
@@ -725,12 +722,12 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
         OUString path;
         osl::FileBase::getSystemPathFromFileURL(url,path);
         OString dsFileName = rtl::OUStringToOString(path, RTL_TEXTENCODING_UTF8);
-        ds_device pSelectedDevice = ::OpenCLDevice::getDeviceSelection(dsFileName.getStr(), bForceEvaluation);
+        ds_device pSelectedDevice = getDeviceSelection(dsFileName.getStr(), bForceEvaluation);
         pDeviceId = pSelectedDevice.oclDeviceID;
 
     }
 
-    if(OpenCLDevice::gpuEnv.mpDevID == pDeviceId)
+    if(gpuEnv.mpDevID == pDeviceId)
     {
         // we don't need to change anything
         // still the same device
@@ -769,13 +766,13 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
         return false;
     }
 
-    OpenCLDevice::releaseOpenCLEnv(&OpenCLDevice::gpuEnv);
+    releaseOpenCLEnv(&gpuEnv);
     OpenCLEnv env;
     env.mpOclPlatformID = platformId;
     env.mpOclContext = context;
     env.mpOclDevsID = pDeviceId;
     env.mpOclCmdQueue = command_queue;
-    OpenCLDevice::initOpenCLAttr(&env);
+    initOpenCLAttr(&env);
 
     // why do we need this at all?
 
@@ -783,10 +780,10 @@ bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEv
     // initialisation below.) Because otherwise the code crashes in
     // initOpenCLRunEnv(). Confused? You should be.
 
-    OpenCLDevice::gpuEnv.mpArryDevsID = (cl_device_id*) malloc( sizeof(cl_device_id) );
-    OpenCLDevice::gpuEnv.mpArryDevsID[0] = pDeviceId;
+    gpuEnv.mpArryDevsID = (cl_device_id*) malloc( sizeof(cl_device_id) );
+    gpuEnv.mpArryDevsID[0] = pDeviceId;
 
-    return !OpenCLDevice::initOpenCLRunEnv(0);
+    return !initOpenCLRunEnv(0);
 }
 
 void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId)
@@ -795,7 +792,7 @@ void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId)
     if (status < 0)
         return;
 
-    cl_device_id id = OpenCLDevice::gpuEnv.mpDevID;
+    cl_device_id id = gpuEnv.mpDevID;
     findDeviceInfoFromDeviceId(id, rDeviceId, rPlatformId);
 }
 
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 0615410..6ac2a5f 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -114,7 +114,7 @@ size_t VectorRef::Marshal( cl_kernel k, int argno, int, cl_program )
     }
     // Obtain cl context
     KernelEnv kEnv;
-    ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+    ::opencl::setKernelEnv(&kEnv);
     cl_int err;
     if (pHostBuffer)
     {
@@ -205,7 +205,7 @@ public:
         // marshaling
         // Obtain cl context
         KernelEnv kEnv;
-        ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+        ::opencl::setKernelEnv(&kEnv);
         // Pass the scalar result back to the rest of the formula kernel
         cl_int err = clSetKernelArg(k, argno, sizeof(cl_uint), (void*)&hashCode);
         if (CL_SUCCESS != err)
@@ -389,7 +389,7 @@ size_t DynamicKernelStringArgument::Marshal( cl_kernel k, int argno, int, cl_pro
     FormulaToken* ref = mFormulaTree->GetFormulaToken();
     // Obtain cl context
     KernelEnv kEnv;
-    ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+    ::opencl::setKernelEnv(&kEnv);
     cl_int err;
     formula::VectorRefArray vRef;
     size_t nStrings = 0;
@@ -1132,7 +1132,7 @@ public:
         assert(Base::mpClmem == NULL);
         // Obtain cl context
         KernelEnv kEnv;
-        ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+        ::opencl::setKernelEnv(&kEnv);
         cl_int err;
         size_t nInput = mpDVR->GetArrayLength();
         size_t nCurWindowSize = mpDVR->GetRefRowSize();
@@ -1913,7 +1913,7 @@ public:
         {
             // Obtain cl context
             KernelEnv kEnv;
-            ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+            ::opencl::setKernelEnv(&kEnv);
             cl_int err;
             cl_mem pClmem2;
 
@@ -1971,7 +1971,7 @@ public:
         {
             // Obtain cl context
             KernelEnv kEnv;
-            ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+            ::opencl::setKernelEnv(&kEnv);
             cl_int err;
             DynamicKernelArgument* Arg = mvSubArguments[0].get();
             DynamicKernelSlidingArgument<VectorRef>* slidingArgPtr =
@@ -3282,11 +3282,11 @@ public:
                                                                DynamicKernelSoPArguments>(mpRoot, new OpNop);
 
         std::stringstream decl;
-        if (::opencl::OpenCLDevice::gpuEnv.mnKhrFp64Flag)
+        if (::opencl::gpuEnv.mnKhrFp64Flag)
         {
             decl << "#pragma OPENCL EXTENSION cl_khr_fp64: enable\n";
         }
-        else if (::opencl::OpenCLDevice::gpuEnv.mnAmdFp64Flag)
+        else if (::opencl::gpuEnv.mnAmdFp64Flag)
         {
             decl << "#pragma OPENCL EXTENSION cl_amd_fp64: enable\n";
         }
@@ -3355,7 +3355,7 @@ public:
     {
         // Obtain cl context
         KernelEnv kEnv;
-        ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+        ::opencl::setKernelEnv(&kEnv);
         cl_int err;
         // The results
         mpResClmem = clCreateBuffer(kEnv.mpkContext,
@@ -3417,7 +3417,7 @@ void DynamicKernel::CreateKernel()
     // Compile kernel here!!!
     // Obtain cl context
     KernelEnv kEnv;
-    ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+    ::opencl::setKernelEnv(&kEnv);
     const char* src = mFullProgramSrc.c_str();
     static std::string lastOneKernelHash = "";
     static std::string lastSecondKernelHash = "";
@@ -3439,11 +3439,11 @@ void DynamicKernel::CreateKernel()
         {
             clReleaseProgram(lastSecondProgram);
         }
-        if (::opencl::OpenCLDevice::buildProgramFromBinary("",
-                &::opencl::OpenCLDevice::gpuEnv, KernelHash.c_str(), 0))
+        if (::opencl::buildProgramFromBinary("",
+                &::opencl::gpuEnv, KernelHash.c_str(), 0))
         {
-            mpProgram = ::opencl::OpenCLDevice::gpuEnv.mpArryPrograms[0];
-            ::opencl::OpenCLDevice::gpuEnv.mpArryPrograms[0] = NULL;
+            mpProgram = ::opencl::gpuEnv.mpArryPrograms[0];
+            ::opencl::gpuEnv.mpArryPrograms[0] = NULL;
         }
         else
         {
@@ -3452,7 +3452,7 @@ void DynamicKernel::CreateKernel()
             if (err != CL_SUCCESS)
                 throw OpenCLError(err, __FILE__, __LINE__);
             err = clBuildProgram(mpProgram, 1,
-                ::opencl::OpenCLDevice::gpuEnv.mpArryDevsID, "", NULL, NULL);
+                ::opencl::gpuEnv.mpArryDevsID, "", NULL, NULL);
             if (err != CL_SUCCESS)
             {
 #if OSL_DEBUG_LEVEL > 0
@@ -3460,7 +3460,7 @@ void DynamicKernel::CreateKernel()
                 {
                     cl_build_status stat;
                     cl_int e = clGetProgramBuildInfo(
-                        mpProgram, ::opencl::OpenCLDevice::gpuEnv.mpArryDevsID[0],
+                        mpProgram, ::opencl::gpuEnv.mpArryDevsID[0],
                         CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status),
                         &stat, 0);
                     SAL_WARN_IF(
@@ -3472,7 +3472,7 @@ void DynamicKernel::CreateKernel()
                     {
                         size_t n;
                         e = clGetProgramBuildInfo(
-                            mpProgram, ::opencl::OpenCLDevice::gpuEnv.mpArryDevsID[0],
+                            mpProgram, ::opencl::gpuEnv.mpArryDevsID[0],
                             CL_PROGRAM_BUILD_LOG, 0, 0, &n);
                         SAL_WARN_IF(
                             e != CL_SUCCESS || n == 0, "sc.opencl",
@@ -3483,7 +3483,7 @@ void DynamicKernel::CreateKernel()
                         {
                             std::vector<char> log(n);
                             e = clGetProgramBuildInfo(
-                                mpProgram, ::opencl::OpenCLDevice::gpuEnv.mpArryDevsID[0],
+                                mpProgram, ::opencl::gpuEnv.mpArryDevsID[0],
                                 CL_PROGRAM_BUILD_LOG, n, &log[0], 0);
                             SAL_WARN_IF(
                                 e != CL_SUCCESS || n == 0, "sc.opencl",
@@ -3502,7 +3502,7 @@ void DynamicKernel::CreateKernel()
                 throw OpenCLError(err, __FILE__, __LINE__);
             }
             // Generate binary out of compiled kernel.
-            ::opencl::OpenCLDevice::generatBinFromKernelSource(mpProgram,
+            ::opencl::generatBinFromKernelSource(mpProgram,
                 (mKernelSignature + GetMD5()).c_str());
         }
         lastSecondKernelHash = lastOneKernelHash;
@@ -3668,7 +3668,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
     {
         // Obtain cl context
         KernelEnv kEnv;
-        ::opencl::OpenCLDevice::setKernelEnv(&kEnv);
+        ::opencl::setKernelEnv(&kEnv);
         // Run the kernel.
         pKernel->Launch(xGroup->mnLength);
         // Map results back


More information about the Libreoffice-commits mailing list