diff options
author | Kohei <kohei.yoshida@collabora.com> | 2017-04-27 22:32:04 -0400 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2017-04-30 03:06:08 +0200 |
commit | 3264a7a924c6522d39185508bd3d94b99ff0a615 (patch) | |
tree | 0be464ca3b65e757716a1273919c2e48f34151ec /sc | |
parent | bbe579a47845e56caf05ae7ab9fdf49319f5647c (diff) |
More fine-grained disabled vector states.
Useful for group formula logging.
Change-Id: I40a02f0aa88d7c63a641f2a79956236d0db39f15
Reviewed-on: https://gerrit.libreoffice.org/37088
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/tokenarray.hxx | 1 | ||||
-rw-r--r-- | sc/inc/types.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 17 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 38 |
5 files changed, 53 insertions, 14 deletions
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx index f91205ac5f36..d817d3b13019 100644 --- a/sc/inc/tokenarray.hxx +++ b/sc/inc/tokenarray.hxx @@ -66,6 +66,7 @@ public: ScFormulaVectorState GetVectorState() const { return meVectorState;} void ResetVectorState() { meVectorState = FormulaVectorEnabled; } + bool IsFormulaVectorDisabled() const; /** * If the array contains at least one relative row reference or named diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx index 4777c00860f9..fb86ec361c3d 100644 --- a/sc/inc/types.hxx +++ b/sc/inc/types.hxx @@ -57,7 +57,12 @@ typedef ::boost::intrusive_ptr<ScFormulaCellGroup> ScFormulaCellGroupRef; */ enum ScFormulaVectorState { - FormulaVectorDisabled = 0, + FormulaVectorDisabled, + FormulaVectorDisabledNotInSubSet, + FormulaVectorDisabledNotInSoftwareSubset, + FormulaVectorDisabledByOpCode, + FormulaVectorDisabledByStackVariable, + FormulaVectorEnabled, FormulaVectorCheckReference, FormulaVectorUnknown diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 7a6b57ae673c..824fdca25921 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2682,11 +2682,11 @@ public: void operator() (size_t /*nRow*/, ScFormulaCell* p) { ScTokenArray* pCode = p->GetCode(); - if (pCode != nullptr && pCode->GetVectorState() == FormulaVectorDisabled) + if (pCode && pCode->IsFormulaVectorDisabled()) { pCode->ResetVectorState(); FormulaToken* pFT = pCode->First(); - while (pFT != nullptr) + while (pFT) { pCode->CheckToken(*pFT); pFT = pCode->Next(); diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 6e27d845d053..2088b007df7c 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -4105,11 +4105,24 @@ bool ScFormulaCell::InterpretFormulaGroup() case FormulaVectorCheckReference: // Good. break; + + // Not good. + case FormulaVectorDisabledByOpCode: + aScope.addMessage("group calc disabled due to vector state (non-vector-supporting opcode)"); + return false; + case FormulaVectorDisabledNotInSoftwareSubset: + aScope.addMessage("group calc disabled due to vector state (opcode not in software subset)"); + return false; + case FormulaVectorDisabledByStackVariable: + aScope.addMessage("group calc disabled due to vector state (non-vector-supporting stack variable)"); + return false; + case FormulaVectorDisabledNotInSubSet: + aScope.addMessage("group calc disabled due to vector state (opcode not in subset)"); + return false; case FormulaVectorDisabled: case FormulaVectorUnknown: default: - // Not good. - aScope.addMessage("group calc disabled due to vector state"); + aScope.addMessage("group calc disabled due to vector state (unknown)"); return false; } diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 75ef12c08299..e511d98de1aa 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1326,7 +1326,7 @@ bool ScTokenArray::AddFormulaToken( void ScTokenArray::CheckToken( const FormulaToken& r ) { - if (meVectorState == FormulaVectorDisabled) + if (IsFormulaVectorDisabled()) // It's already disabled. No more checking needed. return; @@ -1334,19 +1334,22 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) if (SC_OPCODE_START_FUNCTION <= eOp && eOp < SC_OPCODE_STOP_FUNCTION) { - if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end()) + if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && + ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end()) { SAL_INFO("sc.opencl", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp) << " disables vectorisation for formula group"); - meVectorState = FormulaVectorDisabled; + meVectorState = FormulaVectorDisabledNotInSubSet; return; } // test for OpenCL interpreter first - the assumption is that S/W // interpreter blacklist is more strict than the OpenCL one - if (ScCalcConfig::isSwInterpreterEnabled() && (dynamic_cast<sc::FormulaGroupInterpreterSoftware*>(sc::FormulaGroupInterpreter::getStatic()) != nullptr) && ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end()) + if (ScCalcConfig::isSwInterpreterEnabled() && + (dynamic_cast<sc::FormulaGroupInterpreterSoftware*>(sc::FormulaGroupInterpreter::getStatic()) != nullptr) && + ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end()) { SAL_INFO("sc.core.formulagroup", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp) << " disables S/W interpreter for formula group"); - meVectorState = FormulaVectorDisabled; + meVectorState = FormulaVectorDisabledNotInSoftwareSubset; return; } @@ -1535,7 +1538,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) break; default: SAL_INFO("sc.opencl", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp) << " disables vectorisation for formula group"); - meVectorState = FormulaVectorDisabled; + meVectorState = FormulaVectorDisabledByOpCode; } } else if (eOp == ocPush) @@ -1573,7 +1576,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) case svUnknown: // We don't support vectorization on these. SAL_INFO("sc.opencl", "opcode ocPush: variable type " << StackVarEnumToString(r.GetType()) << " disables vectorisation for formula group"); - meVectorState = FormulaVectorDisabled; + meVectorState = FormulaVectorDisabledByStackVariable; break; default: ; @@ -1584,7 +1587,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end()) { SAL_INFO("sc.opencl", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp) << " disables vectorisation for formula group"); - meVectorState = FormulaVectorDisabled; + meVectorState = FormulaVectorDisabledNotInSubSet; } // only when openCL interpreter is not enabled - the assumption is that // the S/W interpreter blacklist is more strict @@ -1594,7 +1597,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end()) { SAL_INFO("sc.core.formulagroup", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp) << " disables S/W interpreter for formula group"); - meVectorState = FormulaVectorDisabled; + meVectorState = FormulaVectorDisabledNotInSoftwareSubset; } } @@ -1713,6 +1716,23 @@ void ScTokenArray::GenHash() mnHashValue = nHash; } +bool ScTokenArray::IsFormulaVectorDisabled() const +{ + switch (meVectorState) + { + case FormulaVectorDisabled: + case FormulaVectorDisabledByOpCode: + case FormulaVectorDisabledNotInSoftwareSubset: + case FormulaVectorDisabledByStackVariable: + case FormulaVectorDisabledNotInSubSet: + return true; + default: + ; + } + + return false; +} + bool ScTokenArray::IsInvariant() const { FormulaToken** p = pCode; |