diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2018-11-27 21:40:22 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2018-12-04 17:44:31 +0100 |
commit | a7ef1795314de8c9e98a47716562e3c1b85e38c4 (patch) | |
tree | 9ceb4ca3ca55d0b149247d2e6e20b77fb5a7de6b /sc | |
parent | e28b719ee82354d6cef0847d9dd601d1a0423460 (diff) |
fix OpenCL PRODUCT when there are actually no values
PRODUCT() when there are no arguments (or all cells are empty) is 0.
Change-Id: I4bcb9afe84d08833526255da0c61f6847d68ea36
Reviewed-on: https://gerrit.libreoffice.org/64232
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit 353bc9db255ca802c70b15e4d5d2e2fcbcee4fe8)
Reviewed-on: https://gerrit.libreoffice.org/64461
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/op_math.cxx | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx index 040c0afc4a55..45306aee893e 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -2711,7 +2711,8 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss, ss << ") {\n"; ss << " int gid0 = get_global_id(0);\n"; ss << " int i = 0;\n"; - ss << " double product=1.0;\n\n"; + ss << " double product=1.0;\n"; + ss << " int count = 0;\n\n"; for (DynamicKernelArgumentRef & rArg : vSubArguments) { FormulaToken *pCur = rArg->GetFormulaToken(); @@ -2747,25 +2748,35 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss, ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n"; ss << " {\n"; } - ss << "if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n"; - ss << "product = product*"; + ss << " if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n"; + ss << " {\n"; + ss << " product = product*"; ss << rArg->GenSlidingWindowDeclRef()<<";\n"; + ss << " ++count;\n"; + ss << " }\n"; ss << " }\n"; } else if (pCur->GetType() == formula::svSingleVectorRef) { - ss << "if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n"; - ss << "product = product*"; + ss << " if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n"; + ss << " {\n"; + ss << " product = product*"; ss << rArg->GenSlidingWindowDeclRef()<<";\n"; - + ss << " ++count;\n"; + ss << " }\n"; } else { - ss << "if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n"; - ss << "product = product*"; + ss << " if(!isnan("<<rArg->GenSlidingWindowDeclRef()<<"))\n"; + ss << " {\n"; + ss << " product = product*"; ss << rArg->GenSlidingWindowDeclRef()<<";\n"; + ss << " ++count;\n"; + ss << " }\n"; } } + ss << " if(count == 0)\n"; + ss << " return 0;\n"; ss << " return product;\n"; ss << "}"; } |