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

haochen haochen at multicorewareinc.com
Tue Dec 10 01:47:42 PST 2013


 sc/source/core/opencl/formulagroupcl.cxx |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

New commits:
commit 445299be76934c6c593793aae2d7630f8a42562b
Author: haochen <haochen at multicorewareinc.com>
Date:   Sat Nov 30 10:51:49 2013 +0800

    GPU Calc: cache more once compiled program in memory
    
    Change-Id: Iab34567806e069d819c86b52f93d88355272416f

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 1c79f36..b73b32a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2675,21 +2675,27 @@ void DynamicKernel::CreateKernel(void)
     KernelEnv kEnv;
     OpenclDevice::setKernelEnv(&kEnv);
     const char *src = mFullProgramSrc.c_str();
-    static std::string lastKernelHash = "";
-    static cl_program lastProgram = NULL;
+    static std::string lastOneKernelHash = "";
+    static std::string lastSecondKernelHash = "";
+    static cl_program lastOneProgram = NULL;
+    static cl_program lastSecondProgram = NULL;
     std::string KernelHash = mKernelSignature+GetMD5();
-    if (lastKernelHash == KernelHash && lastProgram)
+    if (lastOneKernelHash == KernelHash && lastOneProgram)
     {
         std::cerr<<"cl_program cache hit: "<< KernelHash << "\n";
-        mpProgram = lastProgram;
+        mpProgram = lastOneProgram;
+    }
+    else if(lastSecondKernelHash == KernelHash && lastSecondProgram)
+    {
+        std::cerr<<"cl_program cache hit: "<< KernelHash << "\n";
+        mpProgram = lastSecondProgram;
     }
     else
     {   // doesn't match the last compiled formula.
 
-        if (lastProgram) {
-            std::cerr<<"Freeing last program: "<< GetMD5() << "\n";
-            clReleaseProgram(lastProgram);
-            lastProgram = NULL;
+        if (lastSecondProgram) {
+            std::cerr<<"Freeing lastsecond program: "<< GetMD5() << "\n";
+            clReleaseProgram(lastSecondProgram);
         }
         if (OpenclDevice::buildProgramFromBinary("",
                     &OpenclDevice::gpuEnv, KernelHash.c_str(), 0)) {
@@ -2754,8 +2760,10 @@ void DynamicKernel::CreateKernel(void)
             OpenclDevice::generatBinFromKernelSource(mpProgram,
                     (mKernelSignature+GetMD5()).c_str());
         }
-        lastKernelHash = KernelHash;
-        lastProgram = mpProgram;
+        lastSecondKernelHash = lastOneKernelHash;
+        lastSecondProgram = lastOneProgram;
+        lastOneKernelHash = KernelHash;
+        lastOneProgram = mpProgram;
     }
     mpKernel = clCreateKernel(mpProgram, kname.c_str(), &err);
     if (err != CL_SUCCESS)


More information about the Libreoffice-commits mailing list