diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2015-01-02 12:04:09 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2015-01-02 19:36:01 -0500 |
commit | e26f57446179a10a621b31a77446424a8ce14f7b (patch) | |
tree | f757448899ddf4cd4ac27fb0d41d0880fd8c3183 /sc | |
parent | c942ed153fb2d11fd31ee5e5465499a38709e804 (diff) |
Ensure that we don't block on kernel when launching it.
By switching from clFinish, which blocks until the kernel executes, to
clFlush which does not. We instead will call clFinish before fetching
the results to make sure all the kernels have completed their executionn
before getting their results.
Change-Id: I157a05d5a5caf1f3e88935371144f1d52a57a313
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 8ac79d851d0b..b6d32a78be92 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3564,7 +3564,7 @@ void DynamicKernel::Launch( size_t nr ) global_work_size, NULL, 0, NULL, NULL); if (CL_SUCCESS != err) throw OpenCLError(err, __FILE__, __LINE__); - err = clFinish(kEnv.mpkCmdQueue); + err = clFlush(kEnv.mpkCmdQueue); if (CL_SUCCESS != err) throw OpenCLError(err, __FILE__, __LINE__); } @@ -3698,7 +3698,7 @@ public: bool isValid() const { return mpKernel != NULL; } - void waitForResult() + void fetchResultFromKernel() { if (!isValid()) return; @@ -3848,6 +3848,16 @@ void genRPNTokens( ScDocument& rDoc, const ScAddress& rTopPos, ScTokenArray& rCo aComp.CompileTokenArray(); // Regenerate RPN tokens. } +bool waitForResults() +{ + // Obtain cl context + ::opencl::KernelEnv kEnv; + ::opencl::setKernelEnv(&kEnv); + + cl_int err = clFinish(kEnv.mpkCmdQueue); + return err == CL_SUCCESS; +} + } bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, @@ -3864,7 +3874,10 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, if (!aRes.isValid()) return false; - aRes.waitForResult(); + if (!waitForResults()) + return false; + + aRes.fetchResultFromKernel(); return aRes.pushResultToDocument(rDoc, rTopPos); } |