Kaydet (Commit) 89b9969d authored tarafından Luboš Luňák's avatar Luboš Luňák

fix svDoubleRef handling in OpenCL

Basically just adjust it based on svSingleRef handling, as that one
seems sane, while the svDoubleRef case, as a comment puts it, is
"such crack". It didn't seem to make much sense written that way,
and it didn't handle correctly e.g. COUNT() with only strings,
OpCount says it doesn't take strings, but the code passed the arguments
to it anyway, in the "other case".
It'd be better to merge the code into one shared function, but sadly
there are small differencies, so at least this way for now.

Change-Id: Ia5f6ce60dae54b1d5a97e049600503aaa9be3bf0
Reviewed-on: https://gerrit.libreoffice.org/65478
Tested-by: Jenkins
Reviewed-by: 's avatarLuboš Luňák <l.lunak@collabora.com>
üst c706f61c
...@@ -2735,47 +2735,68 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config, ...@@ -2735,47 +2735,68 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
" takeNumeric=" << (pCodeGen->takeNumeric()?"YES":"NO") << " takeNumeric=" << (pCodeGen->takeNumeric()?"YES":"NO") <<
" takeString=" << (pCodeGen->takeString()?"YES":"NO")); " takeString=" << (pCodeGen->takeString()?"YES":"NO"));
if (pDVR->GetArrays()[j].mpNumericArray ||
(pDVR->GetArrays()[j].mpNumericArray == nullptr &&
pDVR->GetArrays()[j].mpStringArray == nullptr))
{
if (pDVR->GetArrays()[j].mpNumericArray && if (pDVR->GetArrays()[j].mpNumericArray &&
pCodeGen->takeNumeric() && pCodeGen->takeNumeric() &&
pDVR->GetArrays()[j].mpStringArray && pDVR->GetArrays()[j].mpStringArray &&
pCodeGen->takeString()) pCodeGen->takeString())
{ {
// Function takes numbers or strings, there are both // Function takes numbers or strings, there are both
SAL_INFO("sc.opencl", "Numbers and strings and that is OK"); SAL_INFO("sc.opencl", "Numbers and strings");
mvSubArguments.push_back( mvSubArguments.push_back(
DynamicKernelArgumentRef( DynamicKernelArgumentRef(
new DynamicKernelMixedSlidingArgument(mCalcConfig, new DynamicKernelMixedSlidingArgument(mCalcConfig,
ts, ft->Children[i], mpCodeGen, j))); ts, ft->Children[i], mpCodeGen, j)));
} }
else if (!AllStringsAreNull(pDVR->GetArrays()[j].mpStringArray, pDVR->GetArrayLength()) && else if (pDVR->GetArrays()[j].mpNumericArray &&
!pCodeGen->takeString()) pCodeGen->takeNumeric() &&
(AllStringsAreNull(pDVR->GetArrays()[j].mpStringArray, pDVR->GetArrayLength()) || mCalcConfig.meStringConversion == ScCalcConfig::StringConversion::ZERO))
{ {
// Can't handle // Function takes numbers, and either there
SAL_INFO("sc.opencl", "Strings but can't do that."); // are no strings, or there are strings but
throw UnhandledToken(("unhandled operand " + StackVarEnumToString(pChild->GetType()) + " for ocPush").c_str(), __FILE__, __LINE__); // they are to be treated as zero
SAL_INFO("sc.opencl", "Numbers (no strings or strings treated as zero)");
mvSubArguments.push_back(
DynamicKernelArgumentRef(VectorRefFactory<VectorRef>(mCalcConfig,
ts, ft->Children[i], mpCodeGen, j)));
} }
else else if (pDVR->GetArrays()[j].mpNumericArray == nullptr &&
pCodeGen->takeNumeric() &&
pDVR->GetArrays()[j].mpStringArray &&
mCalcConfig.meStringConversion == ScCalcConfig::StringConversion::ZERO)
{ {
// Not sure I can figure out what case this exactly is;) // Function takes numbers, and there are only
SAL_INFO("sc.opencl", "The other case"); // strings, but they are to be treated as zero
SAL_INFO("sc.opencl", "Only strings even if want numbers but should be treated as zero");
mvSubArguments.push_back( mvSubArguments.push_back(
DynamicKernelArgumentRef(VectorRefFactory<VectorRef>(mCalcConfig, DynamicKernelArgumentRef(VectorRefFactory<VectorRef>(mCalcConfig,
ts, ft->Children[i], mpCodeGen, j))); ts, ft->Children[i], mpCodeGen, j)));
} }
} else if (pDVR->GetArrays()[j].mpStringArray &&
else pCodeGen->takeString())
{ {
// Ditto here. This is such crack. // There are strings, and the function takes strings.
SAL_INFO("sc.opencl", "The outer other case (can't figure out what it exactly means)"); SAL_INFO("sc.opencl", "Strings only");
mvSubArguments.push_back( mvSubArguments.push_back(
DynamicKernelArgumentRef(VectorRefFactory DynamicKernelArgumentRef(VectorRefFactory
<DynamicKernelStringArgument>(mCalcConfig, <DynamicKernelStringArgument>(mCalcConfig,
ts, ft->Children[i], mpCodeGen, j))); ts, ft->Children[i], mpCodeGen, j)));
} }
else if (AllStringsAreNull(pDVR->GetArrays()[j].mpStringArray, pDVR->GetArrayLength()) &&
pDVR->GetArrays()[j].mpNumericArray == nullptr)
{
// There are only empty cells. Push as an
// array of NANs
SAL_INFO("sc.opencl", "Only empty cells");
mvSubArguments.push_back(
DynamicKernelArgumentRef(VectorRefFactory<VectorRef>(mCalcConfig,
ts, ft->Children[i], mpCodeGen, j)));
}
else
{
SAL_INFO("sc.opencl", "Unhandled case, rejecting for OpenCL");
throw UnhandledToken(("Unhandled numbers/strings combination for '"
+ pCodeGen->BinFuncName() + "'").c_str(), __FILE__, __LINE__);
}
} }
} }
else if (pChild->GetType() == formula::svSingleVectorRef) else if (pChild->GetType() == formula::svSingleVectorRef)
...@@ -2796,7 +2817,7 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config, ...@@ -2796,7 +2817,7 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
pCodeGen->takeString()) pCodeGen->takeString())
{ {
// Function takes numbers or strings, there are both // Function takes numbers or strings, there are both
SAL_INFO("sc.opencl", "Numbers and strings and that is OK"); SAL_INFO("sc.opencl", "Numbers and strings");
mvSubArguments.push_back( mvSubArguments.push_back(
DynamicKernelArgumentRef(new DynamicKernelMixedArgument(mCalcConfig, DynamicKernelArgumentRef(new DynamicKernelMixedArgument(mCalcConfig,
ts, ft->Children[i]))); ts, ft->Children[i])));
...@@ -2808,7 +2829,7 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config, ...@@ -2808,7 +2829,7 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
// Function takes numbers, and either there // Function takes numbers, and either there
// are no strings, or there are strings but // are no strings, or there are strings but
// they are to be treated as zero // they are to be treated as zero
SAL_INFO("sc.opencl", "Maybe strings even if want numbers but should be treated as zero"); SAL_INFO("sc.opencl", "Numbers (no strings or strings treated as zero)");
mvSubArguments.push_back( mvSubArguments.push_back(
DynamicKernelArgumentRef(new VectorRef(mCalcConfig, ts, DynamicKernelArgumentRef(new VectorRef(mCalcConfig, ts,
ft->Children[i]))); ft->Children[i])));
...@@ -2846,13 +2867,14 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config, ...@@ -2846,13 +2867,14 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
} }
else else
{ {
SAL_INFO("sc.opencl", "Fallback case, rejecting for OpenCL"); SAL_INFO("sc.opencl", "Unhandled case, rejecting for OpenCL");
throw UnhandledToken("Got unhandled case here", __FILE__, __LINE__); throw UnhandledToken(("Unhandled numbers/strings combination for '"
+ pCodeGen->BinFuncName() + "'").c_str(), __FILE__, __LINE__);
} }
} }
else if (pChild->GetType() == formula::svDouble) else if (pChild->GetType() == formula::svDouble)
{ {
SAL_INFO("sc.opencl", "Constant number (?) case"); SAL_INFO("sc.opencl", "Constant number case");
mvSubArguments.push_back( mvSubArguments.push_back(
DynamicKernelArgumentRef(new DynamicKernelConstantArgument(mCalcConfig, ts, DynamicKernelArgumentRef(new DynamicKernelConstantArgument(mCalcConfig, ts,
ft->Children[i]))); ft->Children[i])));
...@@ -2860,14 +2882,14 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config, ...@@ -2860,14 +2882,14 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
else if (pChild->GetType() == formula::svString else if (pChild->GetType() == formula::svString
&& pCodeGen->takeString()) && pCodeGen->takeString())
{ {
SAL_INFO("sc.opencl", "Constant string (?) case"); SAL_INFO("sc.opencl", "Constant string case");
mvSubArguments.push_back( mvSubArguments.push_back(
DynamicKernelArgumentRef(new ConstStringArgument(mCalcConfig, ts, DynamicKernelArgumentRef(new ConstStringArgument(mCalcConfig, ts,
ft->Children[i]))); ft->Children[i])));
} }
else else
{ {
SAL_INFO("sc.opencl", "Fallback case, rejecting for OpenCL"); SAL_INFO("sc.opencl", "Unhandled operand, rejecting for OpenCL");
throw UnhandledToken(("unhandled operand " + StackVarEnumToString(pChild->GetType()) + " for ocPush").c_str(), __FILE__, __LINE__); throw UnhandledToken(("unhandled operand " + StackVarEnumToString(pChild->GetType()) + " for ocPush").c_str(), __FILE__, __LINE__);
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment