diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-09-17 14:43:59 -0400 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-09-19 17:03:23 +0200 |
commit | 58e62a7954dc04f1174f8143ed81828a476e8b62 (patch) | |
tree | ca686a0e77e166ea788489d6f68b1c6dcf47a6cf /sc | |
parent | deed1ca901896744a9cf859d390a5a592ba37041 (diff) |
Compile kernels for real.
Change-Id: I7c5e6707e6f733b26d5bb6d6b0d48b0f338625bc
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/opencl/openclwrapper.cxx | 27 | ||||
-rw-r--r-- | sc/source/core/opencl/openclwrapper.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 7 |
4 files changed, 33 insertions, 7 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 4c29223777e2..5697b1b1cf62 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1096,9 +1096,9 @@ SAL_DLLPUBLIC_EXPORT bool SAL_CALL switchOpenClDevice(const OUString* pDeviceId, return sc::opencl::switchOpenclDevice(pDeviceId, bAutoSelect); } -SAL_DLLPUBLIC_EXPORT void compileKernels() +SAL_DLLPUBLIC_EXPORT void compileKernels(const OUString* pDeviceId) { - sc::opencl::compileKernels(); + sc::opencl::compileKernels(pDeviceId); } } diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx index a0c1e7a49fb7..c46866955291 100644 --- a/sc/source/core/opencl/openclwrapper.cxx +++ b/sc/source/core/opencl/openclwrapper.cxx @@ -2851,8 +2851,33 @@ bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect) return !OpenclDevice::initOpenclRunEnv(0); } -void compileKernels() +void compileKernels(const OUString* pDeviceId) { + if (!pDeviceId) + return; + + if (pDeviceId->isEmpty()) + return; + + if (!switchOpenclDevice(pDeviceId, false)) + return; + + cl_program pProgram = OpenclDevice::gpuEnv.mpArryPrograms[0]; + if (!pProgram) + return; + + cl_int nStatus; + for (size_t i = 0, n = OpenclDevice::gpuEnv.maKernels.size(); i < n; ++i) + { + Kernel& r = OpenclDevice::gpuEnv.maKernels[i]; + if (r.mpKernel) + continue; + + r.mpKernel = clCreateKernel(pProgram, r.mpName, &nStatus); + if (nStatus != CL_SUCCESS) + r.mpKernel = NULL; + } + } }} diff --git a/sc/source/core/opencl/openclwrapper.hxx b/sc/source/core/opencl/openclwrapper.hxx index 30e38386c771..bf76e519918b 100644 --- a/sc/source/core/opencl/openclwrapper.hxx +++ b/sc/source/core/opencl/openclwrapper.hxx @@ -266,7 +266,7 @@ const std::vector<OpenclPlatformInfo>& fillOpenCLInfo(); */ bool switchOpenclDevice(const OUString* pDeviceId, bool bAutoSelect); -void compileKernels(); +void compileKernels(const OUString* pDeviceId); }} diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index c07d280c57a2..6a20a0c6b041 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -338,7 +338,7 @@ typedef FormulaGroupInterpreter* (*__createFormulaGroupOpenCLInterpreter)(void); typedef size_t (*__getOpenCLPlatformCount)(void); typedef void (*__fillOpenCLInfo)(OpenclPlatformInfo*, size_t); typedef bool (*__switchOpenClDevice)(const OUString*, bool); -typedef void (*__compileKernels)(void); +typedef void (*__compileKernels)(const OUString*); #endif @@ -460,7 +460,8 @@ void FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool void FormulaGroupInterpreter::compileKernels() { - if (!ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) + const ScCalcConfig& rConfig = ScInterpreter::GetGlobalConfig(); + if (!rConfig.mbOpenCLEnabled) // OpenCL is not enabled. return; @@ -472,7 +473,7 @@ void FormulaGroupInterpreter::compileKernels() if (!fn) return; - reinterpret_cast<__compileKernels>(fn)(); + reinterpret_cast<__compileKernels>(fn)(&rConfig.maOpenCLDevice); } void FormulaGroupInterpreter::generateRPNCode(ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rCode) |