[Libreoffice-commits] core.git: Branch 'feature/fixes7' - 6 commits - officecfg/registry sc/source

Tor Lillqvist tml at collabora.com
Tue Aug 25 21:42:51 PDT 2015


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |    2 
 sc/source/core/opencl/formulagroupcl.cxx                 |   49 ++++-
 sc/source/core/opencl/op_spreadsheet.cxx                 |  145 ++++++---------
 sc/source/core/opencl/op_spreadsheet.hxx                 |    1 
 sc/source/core/tool/calcconfig.cxx                       |    1 
 5 files changed, 104 insertions(+), 94 deletions(-)

New commits:
commit ed4640b957b4dbe0341e97dbf38945359944bc5b
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Aug 25 21:41:43 2015 +0300

    Don't claim we support strings arguments in the OpenCL VLOOKUP
    
    The string support certainly isn't complete or correct
    anyway. Partially revert c3383aafa18ef9d03b04b2a4719e71fdfabc14eb.
    
    Change-Id: Ica86f39daf864a1a62d92f8d8300d75d020c0ee0

diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx
index 6697f4c..10ce77e 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -162,28 +162,9 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
                 ss << " == ";
                 ss << j+1;
                 ss << ")\n";
-                if (!(vSubArguments[1+j]->IsMixedArgument()))
-                {
-                    ss << "        {\n";
-                    ss << "            tmp = ";
-                    vSubArguments[1+j]->GenDeclRef(ss);
-                    ss << "[rowNum];\n";
-                    ss << "        }\n";
-
-                }
-                else
-                {
-                    ss << "        {\n";
-                    ss << "            tmp = !isNan(";
-                    vSubArguments[1+j]->GenNumDeclRef(ss);
-                    ss << "[rowNum])?";
-                    vSubArguments[1+j]->GenNumDeclRef(ss);
-                    ss << "[rowNum]:";
-                    vSubArguments[1+j]->GenStringDeclRef(ss);
-                    ss << "[rowNum];\n";
-                    ss << "        }\n";
-
-                }
+                ss << "            tmp = ";
+                vSubArguments[1+j]->GenDeclRef(ss);
+                ss << "[rowNum];\n";
             }
             ss << "        return tmp;\n";
             ss << "    }\n";
@@ -250,23 +231,9 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
                 ss << " == ";
                 ss << j+1;
                 ss << ")\n";
-                ///Add MixedArguments for string support in Vlookup.
-                if (!(vSubArguments[1+j]->IsMixedArgument()))
-                {
-                    ss << "            tmp = ";
-                    vSubArguments[1+j]->GenDeclRef(ss);
-                    ss << "[rowNum];\n";
-                }
-                else
-                {
-                    ss << "            tmp = !isNan(";
-                    vSubArguments[1+j]->GenNumDeclRef(ss);
-                    ss << "[rowNum])?";
-                    vSubArguments[1+j]->GenNumDeclRef(ss);
-                    ss << "[rowNum]:";
-                    vSubArguments[1+j]->GenStringDeclRef(ss);
-                    ss << "[rowNum];\n";
-                }
+                ss << "            tmp = ";
+                vSubArguments[1+j]->GenDeclRef(ss);
+                ss << "[rowNum];\n";
             }
             ss << "        return tmp;\n";
             ss << "    }\n";
diff --git a/sc/source/core/opencl/op_spreadsheet.hxx b/sc/source/core/opencl/op_spreadsheet.hxx
index e787bda..190ab1d 100644
--- a/sc/source/core/opencl/op_spreadsheet.hxx
+++ b/sc/source/core/opencl/op_spreadsheet.hxx
@@ -20,7 +20,6 @@ public:
     virtual void GenSlidingWindowFunction(std::stringstream &ss,
             const std::string &sSymName, SubArguments &vSubArguments) SAL_OVERRIDE;
     virtual std::string BinFuncName() const SAL_OVERRIDE { return "VLookup"; }
-    virtual bool takeString() const SAL_OVERRIDE { return true; }
 };
 
 }}
commit 1960668dda6b89f80a2d8bf05a1978109b541f62
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Aug 25 18:33:45 2015 +0300

    Add VLOOKUP to the set of opcodes that we trust the OpenCL implementation for
    
    Change-Id: I937ec900044bbc6027ff8d4ae37f2f275dde974f

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index bb74d74..c3fa523 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1373,7 +1373,7 @@
             true, and a formula contains only these operators and
             functions, it might be calculated using OpenCL.</desc>
           </info>
-          <value>+;-;*;/;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSDIST;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;VAR;NORMDIST;CORREL;COVAR;PEARSON;SLOPE;SUMIFS</value>
+          <value>+;-;*;/;RAND;SIN;COS;TAN;ATAN;EXP;LN;SQRT;NORMSDIST;NORMSINV;ROUND;POWER;SUMPRODUCT;MIN;MAX;SUM;PRODUCT;AVERAGE;COUNT;VAR;NORMDIST;VLOOKUP;CORREL;COVAR;PEARSON;SLOPE;SUMIFS</value>
         </prop>
         <prop oor:name="OpenCLAutoSelect" oor:type="xs:boolean" oor:nillable="false">
           <!-- UIHints: Tools - Options  Spreadsheet  Formula -->
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 6fd4345..cffae31 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -66,6 +66,7 @@ void ScCalcConfig::setOpenCLConfigToDefault()
     maOpenCLSubsetOpCodes.insert(ocCount);
     maOpenCLSubsetOpCodes.insert(ocVar);
     maOpenCLSubsetOpCodes.insert(ocNormDist);
+    maOpenCLSubsetOpCodes.insert(ocVLookup);
     maOpenCLSubsetOpCodes.insert(ocCorrel);
     maOpenCLSubsetOpCodes.insert(ocCovar);
     maOpenCLSubsetOpCodes.insert(ocPearson);
commit e84eff9568d3176ada04482f1a980c6723e000f9
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Aug 25 19:33:36 2015 +0300

    Produce the expected N/A error code in the OpenCL VLOOKUP implementation
    
    Instead of a bare NaN.
    
    Change-Id: I170c540478315eedd23f5851d54c30175d21ef96

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 0eb2aa5..e5324cd 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -40,6 +40,7 @@ static const char* publicFunc =
  "#define errIllegalFPOperation 503 // #NUM!\n"
  "#define errNoValue 519 // #VALUE!\n"
  "#define errDivisionByZero 532 // #DIV/0!\n"
+ "#define NOTAVAILABLE 0x7fff // #N/A\n"
  "\n"
  "double CreateDoubleError(ulong nErr)\n"
  "{\n"
diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx
index 86c8414..6697f4c 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -35,7 +35,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
     }
     ss << ")\n    {\n";
     ss << "    int gid0=get_global_id(0);\n";
-    ss << "    double tmp = NAN;\n";
+    ss << "    double tmp = CreateDoubleError(NOTAVAILABLE);\n";
     ss << "    double intermediate = DBL_MAX;\n";
     ss << "    int singleIndex = gid0;\n";
     ss << "    int rowNum = -1;\n";
commit 6744d89677fbe9352b8b9e9a1120814abca5c590
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Aug 25 18:25:47 2015 +0300

    Return correct value from the OpenCL VLOOKUP implementation
    
    The commit c3383aafa18ef9d03b04b2a4719e71fdfabc14eb was missing an !
    operator in two places where it checks whether a cell is a numeric or
    string one, resulting in it always using the string value, which for
    NULL (the case I was looking at, only numeric cells in the array)
    meant zero was returned.
    
    As such I am not sure if it is entirely correct to do the check
    whether a cell is a numeric or string value in the order the generated
    OpenCL code does here (and all over the place perhaps). The
    documentation in <formula/vectortoken.hxx> says:
    
     * Single unit of vector reference consists of two physical arrays.
     *
     * If the whole data array consists of only numeric values, mpStringArray
     * will be NULL, and NaN values in the numeric array represent empty
     * cells.
     *
     * If the whole data array consists of only string values, mpNumericArray
     * will be NULL, and NULL values in the string array represent empty
     * cells.
     *
     * If the data array consists of numeric and string values, then both
     * mpNumericArray and mpStringArray will be non-NULL, and a string cell will
     * be represented by a non-NULL pointer value in the string array.  If the
     * string value is NULL, check the corresponding value in the numeric array.
     * If the value in the numeric array is NaN, it's an empty cell, otherwise
     * it's a numeric cell.
    
    Note how that implies one should first check whether the value in the
    string array is NULL or not, and only if it is NULL, look at the vale
    in the numeric array. The code in the generated OpenCL VLOOKUP
    implementation does it backwards. Scary. But probably equivalent for
    the subset of cases we actually handle in OpenCL, which (I think) are
    those where no string cells are involved.
    
    More bug fixes for the OpenCL VLOOKUP will follow.
    
    Change-Id: Id567c245a0700267584be6032320863a4a66df83

diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx
index 37ec46f..86c8414 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -174,7 +174,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
                 else
                 {
                     ss << "        {\n";
-                    ss << "            tmp = isNan(";
+                    ss << "            tmp = !isNan(";
                     vSubArguments[1+j]->GenNumDeclRef(ss);
                     ss << "[rowNum])?";
                     vSubArguments[1+j]->GenNumDeclRef(ss);
@@ -259,7 +259,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
                 }
                 else
                 {
-                    ss << "            tmp = isNan(";
+                    ss << "            tmp = !isNan(";
                     vSubArguments[1+j]->GenNumDeclRef(ss);
                     ss << "[rowNum])?";
                     vSubArguments[1+j]->GenNumDeclRef(ss);
commit 55de132678bf41a5e6bc3ac2f5dd6f5a4c35859a
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Aug 25 15:38:58 2015 +0300

    Cosmetics
    
    Try to use some sane consistent formatting in this function. No semantic
    change.
    
    Change-Id: Ic9e4625c910f826246451e8ff9e18d6131c04a78

diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx
index d9809ef..37ec46f 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -39,21 +39,23 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    double intermediate = DBL_MAX;\n";
     ss << "    int singleIndex = gid0;\n";
     ss << "    int rowNum = -1;\n";
+
     GenTmpVariables(ss,vSubArguments);
     int arg=0;
     CheckSubArgumentIsNan(ss,vSubArguments,arg++);
     int secondParaWidth = 1;
-    if(vSubArguments[1]->GetFormulaToken()->GetType() ==
-    formula::svDoubleVectorRef)
+
+    if (vSubArguments[1]->GetFormulaToken()->GetType() == formula::svDoubleVectorRef)
     {
         FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken();
-        const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
-            formula::DoubleVectorRefToken *>(tmpCur);
+        const formula::DoubleVectorRefToken*pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
         secondParaWidth = pCurDVR->GetArrays().size();
     }
-    arg+=secondParaWidth;
+
+    arg += secondParaWidth;
     CheckSubArgumentIsNan(ss,vSubArguments,arg++);
-    if(vSubArguments.size() == (unsigned int)(3+(secondParaWidth-1)))
+
+    if (vSubArguments.size() == (unsigned int)(3+(secondParaWidth-1)))
     {
         ss << "    double tmp";
         ss << 3+(secondParaWidth-1);
@@ -64,53 +66,57 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
         CheckSubArgumentIsNan(ss,vSubArguments,arg++);
     }
 
-    if(vSubArguments[1]->GetFormulaToken()->GetType() ==
-    formula::svDoubleVectorRef)
+    if (vSubArguments[1]->GetFormulaToken()->GetType() == formula::svDoubleVectorRef)
     {
         FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken();
-        const formula::DoubleVectorRefToken*pCurDVR= static_cast<const
-            formula::DoubleVectorRefToken *>(tmpCur);
-        size_t nCurWindowSize = pCurDVR->GetArrayLength() <
-        pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength():
-        pCurDVR->GetRefRowSize() ;
+        const formula::DoubleVectorRefToken*pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
+        size_t nCurWindowSize = pCurDVR->GetArrayLength() < pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength() : pCurDVR->GetRefRowSize() ;
         int unrollSize = 8;
         ss << "    int loop;\n";
-        if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
+        if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed())
+        {
             ss << "    loop = ("<<nCurWindowSize<<" - gid0)/";
             ss << unrollSize<<";\n";
 
-        } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
+        }
+        else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+        {
             ss << "    loop = ("<<nCurWindowSize<<" + gid0)/";
             ss << unrollSize<<";\n";
 
-        } else {
+        }
+        else
+        {
             ss << "    loop = "<<nCurWindowSize<<"/"<< unrollSize<<";\n";
         }
 
-        for(int i=0;i<secondParaWidth;i++)
+        for (int i = 0; i < secondParaWidth; i++)
         {
-
             ss << "    for ( int j = 0;j< loop; j++)\n";
             ss << "    {\n";
             ss << "        int i = ";
-            if (!pCurDVR->IsStartFixed()&& pCurDVR->IsEndFixed()) {
-               ss << "gid0 + j * "<< unrollSize <<";\n";
-            }else {
-               ss << "j * "<< unrollSize <<";\n";
+            if (!pCurDVR->IsStartFixed()&& pCurDVR->IsEndFixed())
+            {
+                ss << "gid0 + j * "<< unrollSize <<";\n";
             }
-            if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+            else
             {
-               ss << "        int doubleIndex = i+gid0;\n";
-            }else
+                ss << "j * "<< unrollSize <<";\n";
+            }
+            if (!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
             {
-               ss << "        int doubleIndex = i;\n";
+                ss << "        int doubleIndex = i+gid0;\n";
+            }
+            else
+            {
+                ss << "        int doubleIndex = i;\n";
             }
             ss << "        if(tmp";
             ss << 3+(secondParaWidth-1);
             ss << " == 1)\n";
             ss << "        {\n";
 
-            for(int j =0;j < unrollSize;j++)
+            for (int j = 0;j < unrollSize; j++)
             {
                 CheckSubArgumentIsNan(ss,vSubArguments,1+i);
 
@@ -131,7 +137,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
 
             ss << "        }else\n";
             ss << "        {\n";
-            for(int j =0;j < unrollSize;j++)
+            for (int j = 0; j < unrollSize; j++)
             {
                 CheckSubArgumentIsNan(ss,vSubArguments,1+i);
 
@@ -149,15 +155,14 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "    }\n";
             ss << "    if(rowNum!=-1)\n";
             ss << "    {\n";
-            for(int j=0;j< secondParaWidth; j++)
+            for (int j = 0; j < secondParaWidth; j++)
             {
-
                 ss << "        if(tmp";
                 ss << 2+(secondParaWidth-1);
                 ss << " == ";
                 ss << j+1;
                 ss << ")\n";
-                if( !(vSubArguments[1+j]->IsMixedArgument()))
+                if (!(vSubArguments[1+j]->IsMixedArgument()))
                 {
                     ss << "        {\n";
                     ss << "            tmp = ";
@@ -183,21 +188,27 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "        return tmp;\n";
             ss << "    }\n";
             ss << "    for (int i = ";
-            if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
-               ss << "gid0 + loop *"<<unrollSize<<"; i < ";
-               ss << nCurWindowSize <<"; i++)\n";
-            } else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed()) {
-               ss << "0 + loop *"<<unrollSize<<"; i < gid0+";
-               ss << nCurWindowSize <<"; i++)\n";
-            } else {
-               ss << "0 + loop *"<<unrollSize<<"; i < ";
-               ss << nCurWindowSize <<"; i++)\n";
+            if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed())
+            {
+                ss << "gid0 + loop *"<<unrollSize<<"; i < ";
+                ss << nCurWindowSize <<"; i++)\n";
+            }
+            else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+            {
+                ss << "0 + loop *"<<unrollSize<<"; i < gid0+";
+                ss << nCurWindowSize <<"; i++)\n";
+            }
+            else
+            {
+                ss << "0 + loop *"<<unrollSize<<"; i < ";
+                ss << nCurWindowSize <<"; i++)\n";
             }
             ss << "    {\n";
-            if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+            if (!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
             {
                ss << "        int doubleIndex = i+gid0;\n";
-            }else
+            }
+            else
             {
                ss << "        int doubleIndex = i;\n";
             }
@@ -232,16 +243,15 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
             ss << "    if(rowNum!=-1)\n";
             ss << "    {\n";
 
-            for(int j=0;j< secondParaWidth; j++)
+            for (int j = 0; j < secondParaWidth; j++)
             {
-
                 ss << "        if(tmp";
                 ss << 2+(secondParaWidth-1);
                 ss << " == ";
                 ss << j+1;
                 ss << ")\n";
                 ///Add MixedArguments for string support in Vlookup.
-                if( !(vSubArguments[1+j]->IsMixedArgument()))
+                if (!(vSubArguments[1+j]->IsMixedArgument()))
                 {
                     ss << "            tmp = ";
                     vSubArguments[1+j]->GenDeclRef(ss);
@@ -257,13 +267,11 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
                     vSubArguments[1+j]->GenStringDeclRef(ss);
                     ss << "[rowNum];\n";
                 }
-
             }
             ss << "        return tmp;\n";
             ss << "    }\n";
 
         }
-
     }
     else
     {
commit 3fe7a1755daae87d22f2297238a93680677a33fb
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Aug 25 15:11:54 2015 +0300

    Treat an array of null string pointers as no strings for OpenCL
    
    For some reason, at least in the case of the "Test OpenCL" thing, we get here
    an mpStringArray that is non-null but where all the elements (rtl_uString
    pointers) in it are null. Treat that case as if the mpStringArray was null.
    
    This makes the tests "Test OpenCL" actually use OpenCL. Maybe it has other
    useful effects, too. (But for normal spreadsheet use, the mpStringArray that
    gets handled here *is* null when all the cells used by a formula group are
    numbers. At least it seemed so in a simple test.)
    
    Also add more useful (?) SAL_INFO calls in the area.
    
    Change-Id: I1388786a3a0765af6eb01a63da31e5b83c7a616d

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 368c525..0eb2aa5 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -152,6 +152,19 @@ std::string linenumberify(const std::string& s)
 }
 #endif
 
+bool AllStringsAreNull(const rtl_uString* const* pStringArray, size_t nLength)
+{
+    if (pStringArray == nullptr)
+        return true;
+
+    for (size_t i = 0; i < nLength; i++)
+        if (pStringArray[i] != nullptr)
+            return false;
+
+    return true;
+}
+
+
 } // anonymous namespace
 
 /// Map the buffer used by an argument and do necessary argument setting
@@ -2615,8 +2628,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
 
                     for (size_t j = 0; j < pDVR->GetArrays().size(); ++j)
                     {
-                        SAL_INFO("sc.opencl", "j=" << j << " mpNumericArray=" << pDVR->GetArrays()[j].mpNumericArray <<
+                        SAL_INFO("sc.opencl", "i=" << i << " j=" << j <<
+                                 " mpNumericArray=" << pDVR->GetArrays()[j].mpNumericArray <<
                                  " mpStringArray=" << pDVR->GetArrays()[j].mpStringArray <<
+                                 " allStringsAreNull=" << (AllStringsAreNull(pDVR->GetArrays()[j].mpStringArray, pDVR->GetArrayLength())?"YES":"NO") <<
                                  " takeNumeric=" << (pCodeGen->takeNumeric()?"YES":"NO") <<
                                  " takeString=" << (pCodeGen->takeString()?"YES":"NO"));
 
@@ -2629,6 +2644,8 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                                 pDVR->GetArrays()[j].mpStringArray &&
                                 pCodeGen->takeString())
                             {
+                                // Function takes numbers or strings, there are both
+                                SAL_INFO("sc.opencl", "Numbers and strings and that is OK");
                                 mvSubArguments.push_back(
                                     DynamicKernelArgumentRef(
                                         new DynamicKernelMixedSlidingArgument(mCalcConfig,
@@ -2636,16 +2653,22 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                             }
                             else
                             {
+                                // Not sure I can figure out what case this exactly is;)
+                                SAL_INFO("sc.opencl", "The other case");
                                 mvSubArguments.push_back(
                                     DynamicKernelArgumentRef(VectorRefFactory<VectorRef>(mCalcConfig,
                                             ts, ft->Children[i], mpCodeGen, j)));
                             }
                         }
                         else
+                        {
+                            // Ditto here. This is such crack.
+                            SAL_INFO("sc.opencl", "The outer other case (can't figure out what it exactly means)");
                             mvSubArguments.push_back(
                                 DynamicKernelArgumentRef(VectorRefFactory
                                     <DynamicKernelStringArgument>(mCalcConfig,
                                         ts, ft->Children[i], mpCodeGen, j)));
+                        }
                     }
                 }
                 else if (pChild->GetType() == formula::svSingleVectorRef)
@@ -2653,8 +2676,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                     const formula::SingleVectorRefToken* pSVR =
                         static_cast<const formula::SingleVectorRefToken*>(pChild);
 
-                    SAL_INFO("sc.opencl", "mpNumericArray=" << pSVR->GetArray().mpNumericArray <<
+                    SAL_INFO("sc.opencl", "i=" << i <<
+                             " mpNumericArray=" << pSVR->GetArray().mpNumericArray <<
                              " mpStringArray=" << pSVR->GetArray().mpStringArray <<
+                             " allStringsAreNull=" << (AllStringsAreNull(pSVR->GetArray().mpStringArray, pSVR->GetArrayLength())?"YES":"NO") <<
                              " takeNumeric=" << (pCodeGen->takeNumeric()?"YES":"NO") <<
                              " takeString=" << (pCodeGen->takeString()?"YES":"NO"));
 
@@ -2664,17 +2689,19 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                         pCodeGen->takeString())
                     {
                         // Function takes numbers or strings, there are both
+                        SAL_INFO("sc.opencl", "Numbers and strings and that is OK");
                         mvSubArguments.push_back(
                             DynamicKernelArgumentRef(new DynamicKernelMixedArgument(mCalcConfig,
                                     ts, ft->Children[i])));
                     }
                     else if (pSVR->GetArray().mpNumericArray &&
                         pCodeGen->takeNumeric() &&
-                        (pSVR->GetArray().mpStringArray == NULL || mCalcConfig.meStringConversion == ScCalcConfig::StringConversion::ZERO))
+                             (AllStringsAreNull(pSVR->GetArray().mpStringArray, pSVR->GetArrayLength()) || mCalcConfig.meStringConversion == ScCalcConfig::StringConversion::ZERO))
                     {
                         // Function takes numbers, and either there
                         // are no strings, or there are strings but
                         // they are to be treated as zero
+                        SAL_INFO("sc.opencl", "Maybe strings even if want numbers but should be treated as zero");
                         mvSubArguments.push_back(
                             DynamicKernelArgumentRef(new VectorRef(mCalcConfig, ts,
                                     ft->Children[i])));
@@ -2686,6 +2713,7 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                     {
                         // Function takes numbers, and there are only
                         // 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(
                             DynamicKernelArgumentRef(new VectorRef(mCalcConfig, ts,
                                     ft->Children[i])));
@@ -2693,28 +2721,32 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                     else if (pSVR->GetArray().mpStringArray &&
                         pCodeGen->takeString())
                     {
-                        // There are strings, and the function takes
-                        // strings.
-
+                        // There are strings, and the function takes strings.
+                        SAL_INFO("sc.opencl", "Strings only");
                         mvSubArguments.push_back(
                             DynamicKernelArgumentRef(new DynamicKernelStringArgument(mCalcConfig,
                                     ts, ft->Children[i])));
                     }
-                    else if (pSVR->GetArray().mpStringArray == NULL &&
+                    else if (AllStringsAreNull(pSVR->GetArray().mpStringArray, pSVR->GetArrayLength()) &&
                         pSVR->GetArray().mpNumericArray == NULL)
                     {
                         // There are only empty cells. Push as an
                         // array of NANs
+                        SAL_INFO("sc.opencl", "Only empty cells");
                         mvSubArguments.push_back(
                             DynamicKernelArgumentRef(new VectorRef(mCalcConfig, ts,
                                     ft->Children[i])));
                     }
                     else
+                    {
+                        SAL_INFO("sc.opencl", "Fallback case, rejecting for OpenCL");
                         throw UnhandledToken(pChild,
                             "Got unhandled case here", __FILE__, __LINE__);
+                    }
                 }
                 else if (pChild->GetType() == formula::svDouble)
                 {
+                    SAL_INFO("sc.opencl", "Constant number (?) case");
                     mvSubArguments.push_back(
                         DynamicKernelArgumentRef(new DynamicKernelConstantArgument(mCalcConfig, ts,
                                 ft->Children[i])));
@@ -2722,12 +2754,14 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(const ScCalcConfig& config,
                 else if (pChild->GetType() == formula::svString
                     && pCodeGen->takeString())
                 {
+                    SAL_INFO("sc.opencl", "Constant string (?) case");
                     mvSubArguments.push_back(
                         DynamicKernelArgumentRef(new ConstStringArgument(mCalcConfig, ts,
                                 ft->Children[i])));
                 }
                 else
                 {
+                    SAL_INFO("sc.opencl", "Fallback case, rejecting for OpenCL");
                     throw UnhandledToken(pChild, ("unhandled operand " + StackVarEnumToString(pChild->GetType()) + " for ocPush").c_str());
                 }
                 break;


More information about the Libreoffice-commits mailing list