diff options
author | haochen <haochen@multicorewareinc.com> | 2013-11-30 10:51:49 +0800 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-12-10 09:48:40 +0000 |
commit | ffc0181c840b90b3ee48bdd31f5787669a233cff (patch) | |
tree | fd411e6e3bf9a3ba9ce97d33e09dc2323ca73eb3 | |
parent | 0f8c2106579a43da8f5c888ecdc9928d10f3086c (diff) |
GPU Calc: cache more once compiled program in memorylibreoffice-4-2-milestone-4
Change-Id: Iab34567806e069d819c86b52f93d88355272416f
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 0804dcb0fd22..724f6753bbcd 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -2677,21 +2677,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)) { @@ -2710,8 +2716,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) |