diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-12-15 19:22:07 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-12-15 21:21:05 -0500 |
commit | c56091868cb970f44145629f8f1995c2f5036e43 (patch) | |
tree | d1633c38ad79560034c346c1825813e2d5039d1e /sc | |
parent | d94b8cabeaa46089dbc5b34e29923f058f89f349 (diff) |
Let's try to only surround code that may throw with try-catch block.
While leave the rest outside it.
Change-Id: I17f5b935dba8535f2bbfdd86b1037a95f2324174
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 9127617cb967..dc280b093967 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3690,27 +3690,14 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, if (!pKernel) return false; + // Obtain cl context + ::opencl::KernelEnv kEnv; + ::opencl::setKernelEnv(&kEnv); + try { - // Obtain cl context - ::opencl::KernelEnv kEnv; - ::opencl::setKernelEnv(&kEnv); // Run the kernel. pKernel->Launch(xGroup->mnLength); - // Map results back - cl_mem res = pKernel->GetResultBuffer(); - cl_int err; - double* resbuf = (double*)clEnqueueMapBuffer(kEnv.mpkCmdQueue, - res, - CL_TRUE, CL_MAP_READ, 0, - xGroup->mnLength * sizeof(double), 0, NULL, NULL, - &err); - if (err != CL_SUCCESS) - throw OpenCLError(err, __FILE__, __LINE__); - rDoc.SetFormulaResults(rTopPos, resbuf, xGroup->mnLength); - err = clEnqueueUnmapMemObject(kEnv.mpkCmdQueue, res, resbuf, 0, NULL, NULL); - if (err != CL_SUCCESS) - throw OpenCLError(err, __FILE__, __LINE__); } catch (const UnhandledToken& ut) { @@ -3752,6 +3739,25 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, return false; #endif } + + // Map results back + cl_mem res = pKernel->GetResultBuffer(); + cl_int err; + double* resbuf = (double*)clEnqueueMapBuffer(kEnv.mpkCmdQueue, + res, + CL_TRUE, CL_MAP_READ, 0, + xGroup->mnLength * sizeof(double), 0, NULL, NULL, + &err); + if (err != CL_SUCCESS) + throw OpenCLError(err, __FILE__, __LINE__); + rDoc.SetFormulaResults(rTopPos, resbuf, xGroup->mnLength); + err = clEnqueueUnmapMemObject(kEnv.mpkCmdQueue, res, resbuf, 0, NULL, NULL); + if (err != CL_SUCCESS) + { + SAL_WARN("sc.opencl", "Dynamic formula compiler: OpenCL error: " << err << " at " << __FILE__ << ":" << __LINE__); + return false; + } + return true; } |