[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 19 + sc/source/core/tool/formulagroup.cxx | 62 ++- 2 files changed, 54 insertions(+), 27 deletions(-) New commits: commit 0b28477226793fca61edee5156c34d4879d7f0e3 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Wed Sep 11 12:33:02 2013 -0400 Dynamically load the opencl group interpreter code at run time. Change-Id: I0e2b393ecf068b57bfe653663be0a788caa22a36 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index dada7e0..d958b1b 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -27,9 +27,6 @@ namespace sc { namespace opencl { -// A single public entry point for a factory function: -extern sc::FormulaGroupInterpreter *createFormulaGroupInterpreter(); - /time test dbg double getTimeDiff(const TimeValue t1, const TimeValue t2) { @@ -1067,21 +1064,25 @@ bool FormulaGroupInterpreterGroundwater::interpret(ScDocument rDoc, const ScAdd #endif -sc::FormulaGroupInterpreter *createFormulaGroupInterpreter() +} // namespace opencl + +} // namespace sc + +extern C { + +SAL_DLLPUBLIC_EXPORT sc::FormulaGroupInterpreter* SAL_CALL createFormulaGroupOpenCLInterpreter() { if (getenv(SC_SOFTWARE)) return NULL; #if USE_GROUNDWATER_INTERPRETER if (getenv(SC_GROUNDWATER)) -return new FormulaGroupInterpreterGroundwater(); +return new sc::opencl::FormulaGroupInterpreterGroundwater(); #endif -return new FormulaGroupInterpreterOpenCL(); +return new sc::opencl::FormulaGroupInterpreterOpenCL(); } -} // namespace opencl - -} // namespace sc +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 98ef4a9..3b929fa 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -27,6 +27,12 @@ #include cstdio #endif +#ifdef DISABLE_DYNLOADING + +extern sc::FormulaGroupInterpreter* SAL_CALL createFormulaGroupOpenCLInterpreter(); + +#endif + namespace sc { rtl_uString* FormulaGroupContext::intern( const OUString rStr ) @@ -128,15 +134,6 @@ void fillMatrix( ScMatrix rMat, size_t nCol, rtl_uString** pStrs, size_t nLen ) } -class FormulaGroupInterpreterOpenCLMissing : public FormulaGroupInterpreter -{ -public: -FormulaGroupInterpreterOpenCLMissing() : FormulaGroupInterpreter() {} -virtual ~FormulaGroupInterpreterOpenCLMissing() {} -virtual ScMatrixRef inverseMatrix(const ScMatrix) { return ScMatrixRef(); } -virtual bool interpret(ScDocument, const ScAddress, const ScFormulaCellGroupRef, ScTokenArray) { return false; } -}; - ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix /*rMat*/) { return ScMatrixRef(); @@ -278,12 +275,6 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const ScAddres return true; } -// TODO: load module, hook symbol out, check it works, UI on failure etc. -namespace opencl { -extern sc::FormulaGroupInterpreter *createFormulaGroupInterpreter(); -} -FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL; - #if USE_DUMMY_INTERPRETER class FormulaGroupInterpreterDummy : public FormulaGroupInterpreter { @@ -322,8 +313,28 @@ public: return true; } }; + #endif +#ifndef DISABLE_DYNLOADING + +class FormulaGroupInterpreterOpenCLMissing : public FormulaGroupInterpreter +{ +public: +FormulaGroupInterpreterOpenCLMissing() : FormulaGroupInterpreter() {} +virtual ~FormulaGroupInterpreterOpenCLMissing() {} +virtual ScMatrixRef inverseMatrix(const ScMatrix) { return ScMatrixRef(); } +virtual bool interpret(ScDocument, const ScAddress, const ScFormulaCellGroupRef, ScTokenArray) { return false; } +}; + +static void SAL_CALL thisModule() {} + +typedef FormulaGroupInterpreter* (*LoaderFn)(void); + +#endif + +FormulaGroupInterpreter *FormulaGroupInterpreter::msInstance = NULL; + /// load and/or configure the correct formula group interpreter FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic() { @@ -351,10 +362,25 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic() if ( ScInterpreter::GetGlobalConfig().mbOpenCLEnabled ) { #ifdef DISABLE_DYNLOADING -msInstance = sc::opencl::createFormulaGroupInterpreter(); +msInstance = createFormulaGroupOpenCLInterpreter(); #else -// TODO : Dynamically load scopencl shared object, and instantiate the opencl interpreter. -msInstance = new sc::FormulaGroupInterpreterOpenCLMissing(); +// Dynamically load scopencl shared object, and instantiate the opencl interpreter. + +OUString aLibName(SVLIBRARY(scopencl)); +static osl::Module aModule; +bool bLoaded = aModule.loadRelative(thisModule, aLibName); +if
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/filter/excel/excform.cxx | 26 +- sc/source/filter/excel/excimp8.cxx |2 +- sc/source/filter/excel/impop.cxx | 11 ++- sc/source/filter/excel/read.cxx |5 - sc/source/filter/excel/xicontent.cxx | 19 ++- sc/source/filter/excel/xihelper.cxx | 13 ++--- sc/source/filter/excel/xipivot.cxx | 32 +--- sc/source/filter/excel/xiroot.cxx|7 +++ sc/source/filter/inc/xicontent.hxx |2 +- sc/source/filter/inc/xihelper.hxx|2 +- sc/source/filter/inc/xipivot.hxx |8 sc/source/filter/inc/xiroot.hxx |6 ++ 12 files changed, 72 insertions(+), 61 deletions(-) New commits: commit 863c51e4985ce3faf1909a989331f80ef062d6b7 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Wed Sep 11 22:04:20 2013 -0400 Use ScDocumentImport to populate cell storage during xls import. Change-Id: I205c5b7c1202862ea7129fbd61d54e48cd37b06e diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 82a3ae5..c99f67a 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -34,6 +34,7 @@ #include xihelper.hxx #include xilink.hxx #include xiname.hxx +#include documentimport.hxx using ::std::vector; @@ -110,6 +111,7 @@ void ImportExcel::Formula( const ScTokenArray* pResult = NULL; pFormConv-Reset( aScPos ); +ScDocumentImport rDoc = GetDocImport(); if (bShrFmla) { @@ -119,16 +121,11 @@ void ImportExcel::Formula( { if (xGroup-mnStart == aScPos.Row()) // Generate code for the top cell only. -xGroup-compileCode(*pD, aScPos, formula::FormulaGrammar::GRAM_DEFAULT); +xGroup-compileCode(rDoc.getDoc(), aScPos, formula::FormulaGrammar::GRAM_DEFAULT); ScFormulaCell* pCell = new ScFormulaCell(pD, aScPos, xGroup); -pD-EnsureTable(aScPos.Tab()); -bool bInserted = pD-SetGroupFormulaCell(aScPos, pCell); -if (!bInserted) -{ -delete pCell; -return; -} +rDoc.getDoc().EnsureTable(aScPos.Tab()); +rDoc.setFormulaCell(aScPos, pCell); xGroup-mnLength = aScPos.Row() - xGroup-mnStart + 1; pCell-SetNeedNumberFormat(false); if (!rtl::math::isNan(fCurVal)) @@ -145,18 +142,13 @@ void ImportExcel::Formula( if (pResult) { -pCell = new ScFormulaCell( pD, aScPos, pResult ); -pD-EnsureTable(aScPos.Tab()); -bool bInserted = pD-SetGroupFormulaCell(aScPos, pCell); -if (!bInserted) -{ -delete pCell; -return; -} +pCell = new ScFormulaCell(rDoc.getDoc(), aScPos, pResult); +rDoc.getDoc().EnsureTable(aScPos.Tab()); +rDoc.setFormulaCell(aScPos, pCell); } else { -pCell = pD-GetFormulaCell(aScPos); +pCell = rDoc.getDoc().GetFormulaCell(aScPos); if (pCell) pCell-AddRecalcMode( RECALCMODE_ONLOAD_ONCE ); } diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index 5b849be..92c3cfb 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -297,7 +297,7 @@ void ImportExcel8::Labelsst( void ) GetXFRangeBuffer().SetXF( aScPos, nXF ); const XclImpString* pXclStr = GetSst().GetString(nSst); if (pXclStr) -XclImpStringHelper::SetToDocument(GetDoc(), aScPos, *this, *pXclStr, nXF); +XclImpStringHelper::SetToDocument(GetDocImport(), aScPos, *this, *pXclStr, nXF); } } diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx index 28ddd9f..e03980b 100644 --- a/sc/source/filter/excel/impop.cxx +++ b/sc/source/filter/excel/impop.cxx @@ -75,6 +75,7 @@ #include excimp8.hxx #include excform.hxx +#include documentimport.hxx #if defined( WNT ) #include math.h @@ -308,7 +309,7 @@ void ImportExcel::ReadNumber() maStrm fValue; GetXFRangeBuffer().SetXF( aScPos, nXFIdx ); -GetDoc().SetValue(aScPos, fValue); +GetDocImport().setNumericCell(aScPos, fValue); } } @@ -338,7 +339,7 @@ void ImportExcel::ReadLabel() SetTextEncoding( eOldTextEnc ); GetXFRangeBuffer().SetXF( aScPos, nXFIdx ); -XclImpStringHelper::SetToDocument(GetDoc(), aScPos, GetRoot(), aString, nXFIdx); +XclImpStringHelper::SetToDocument(GetDocImport(), aScPos, GetRoot(), aString, nXFIdx); } } @@ -380,7 +381,7 @@ void ImportExcel::ReadRk() maStrm nRk; GetXFRangeBuffer().SetXF( aScPos, nXFIdx ); -GetDoc().SetValue(aScPos, XclTools::GetDoubleFromRK(nRk)); +GetDocImport().setNumericCell(aScPos, XclTools::GetDoubleFromRK(nRk)); } } @@ -853,7 +854,7 @@ void
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/data/document.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 3a4b281ee1b5078430df81ead2eedd60aa714f74 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Sep 10 09:17:12 2013 -0400 Oops I forgot a return statement. Change-Id: Ifdea804b178ccf5c25ef21fba2642f31a90e4061 diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index d161910..7bda1da 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1024,7 +1024,7 @@ SCROW ScDocument::GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2 ) const if (!pTab) return -1; -pTab-GetLastDataRow(nCol1, nCol2); +return pTab-GetLastDataRow(nCol1, nCol2); } // connected area ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 14 + sc/source/core/opencl/oclkernels.hxx |5 + sc/source/core/opencl/openclwrapper.cxx | 39 -- sc/source/core/opencl/openclwrapper.hxx | 84 +++ sc/source/core/tool/formulagroup.cxx |2 5 files changed, 75 insertions(+), 69 deletions(-) New commits: commit ef1cd0c12eaddc6f1f30e73c37cf301c1fbe430d Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Sep 10 17:01:15 2013 -0400 Put all opencl related code inside sc::opencl namespace. Change-Id: Ia6c1fd88ed08022347c60af33a8620b9cf278c12 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 279ac2d..62d70de 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -7,7 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include config_features.h #include formulagroup.hxx #include document.hxx #include formulacell.hxx @@ -23,12 +22,11 @@ #define SINGLEARRAYLEN 100 #define DOUBLEARRAYLEN 100 #define SVDOUBLELEN 100 -namespace sc { + +namespace sc { namespace opencl { // A single public entry point for a factory function: -namespace opencl { -extern sc::FormulaGroupInterpreter *createFormulaGroupInterpreter(); -} +extern sc::FormulaGroupInterpreter *createFormulaGroupInterpreter(); /time test dbg double getTimeDiff(const TimeValue t1, const TimeValue t2) @@ -1063,17 +1061,15 @@ bool FormulaGroupInterpreterGroundwater::interpret(ScDocument rDoc, const ScAdd return true; } -namespace opencl { - sc::FormulaGroupInterpreter *createFormulaGroupInterpreter() { if (getenv(SC_SOFTWARE)) return NULL; if (getenv(SC_GROUNDWATER)) -return new sc::FormulaGroupInterpreterGroundwater(); +return new FormulaGroupInterpreterGroundwater(); -return new sc::FormulaGroupInterpreterOpenCL(); +return new FormulaGroupInterpreterOpenCL(); } } // namespace opencl diff --git a/sc/source/core/opencl/oclkernels.hxx b/sc/source/core/opencl/oclkernels.hxx index 53917b3..3e0af5b 100644 --- a/sc/source/core/opencl/oclkernels.hxx +++ b/sc/source/core/opencl/oclkernels.hxx @@ -12,6 +12,9 @@ #ifndef USE_EXTERNAL_KERNEL #define KERNEL( ... )# __VA_ARGS__ + +namespace sc { namespace opencl { + // Double precision is a default of spreadsheets // cl_khr_fp64: Khronos extension // cl_amd_fp64: AMD extension @@ -380,6 +383,8 @@ __kernel void oclSub( fp_t ltData, __global fp_t *rtData, __global fp_t *outData } ); +}} + #endif // USE_EXTERNAL_KERNEL #endif //_OCL_KERNEL_H_ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx index 6db498b..75e991b 100644 --- a/sc/source/core/opencl/openclwrapper.cxx +++ b/sc/source/core/opencl/openclwrapper.cxx @@ -7,24 +7,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include stdio.h -#include stdlib.h -#include string.h -#include cmath +#include openclwrapper.hxx + #include sal/config.h #include random.hxx -#include openclwrapper.hxx #include oclkernels.hxx -#ifdef SAL_WIN32 -#include Windows.h -#endif -//#define USE_MAP_BUFFER -using namespace std; -GPUEnv OpenclDevice::gpuEnv; -int OpenclDevice::isInited =0; +#include stdio.h +#include stdlib.h +#include string.h +#include cmath -#ifdef SAL_WIN32 +#ifdef WIN32 +#include Windows.h #define OPENCL_DLL_NAME opencllo.dll #define OCLERR -1 @@ -40,6 +35,16 @@ int OpenclDevice::isInited =0; #define OCL_CHECK(value1,value2,str) \ if(value1!=value2) \ fprintf(stderr,[OCL_ERROR] %s\n,str); +#endif + +using namespace std; + +namespace sc { namespace opencl { + +GPUEnv OpenclDevice::gpuEnv; +int OpenclDevice::isInited =0; + +#ifdef WIN32 HINSTANCE HOpenclDll = NULL; void * OpenclDll = NULL; @@ -69,7 +74,7 @@ void OpenclDevice::freeOpenclDll() int OpenclDevice::initEnv() { -#ifdef SAL_WIN32 +#ifdef WIN32 while( 1 ) { if( 1 == loadOpencl() ) @@ -83,14 +88,14 @@ int OpenclDevice::initEnv() int OpenclDevice::releaseOpenclRunEnv() { releaseOpenclEnv( gpuEnv ); -#ifdef SAL_WIN32 +#ifdef WIN32 freeOpenclDll(); #endif return 1; } /// /// -inline int OpenclDevice::addKernelConfig( int kCount, const char *kName ) +int OpenclDevice::addKernelConfig( int kCount, const char *kName ) { if ( kCount 1 ) fprintf(stderr,Error: ( KCount 1 ) SAL_DETAIL_WHERE addKernelConfig\n ); @@ -2660,4 +2665,6 @@ int OclCalc::oclHostMatrixInverse32Bits( const char* aKernelName, float *fpOclMa return 0; } +}} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/openclwrapper.hxx b/sc/source/core/opencl/openclwrapper.hxx index cf3b4f1..d1e8925
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |8 sc/source/core/tool/formulagroup.cxx |2 +- 2 files changed, 9 insertions(+), 1 deletion(-) New commits: commit 9e4a6760a5a2045696f86bdf26913d26699e4ac3 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Sep 10 17:10:15 2013 -0400 Disable dummy and groundwater interpreters from the default build. They are of no use in the default build. Change-Id: Ie3b874a5c78123436736318357fa48baafd991f3 diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 62d70de..dada7e0 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -18,6 +18,8 @@ #include openclwrapper.hxx +#define USE_GROUNDWATER_INTERPRETER 0 + #define SRCDATASIZE 100 #define SINGLEARRAYLEN 100 #define DOUBLEARRAYLEN 100 @@ -947,6 +949,8 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument rDoc, const ScAddress return false; } +#if USE_GROUNDWATER_INTERPRETER + /// Special case of formula compiler for groundwatering class FormulaGroupInterpreterGroundwater : public FormulaGroupInterpreterSoftware { @@ -1061,13 +1065,17 @@ bool FormulaGroupInterpreterGroundwater::interpret(ScDocument rDoc, const ScAdd return true; } +#endif + sc::FormulaGroupInterpreter *createFormulaGroupInterpreter() { if (getenv(SC_SOFTWARE)) return NULL; +#if USE_GROUNDWATER_INTERPRETER if (getenv(SC_GROUNDWATER)) return new FormulaGroupInterpreterGroundwater(); +#endif return new FormulaGroupInterpreterOpenCL(); } diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index d8ba564..04bec4f 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -21,7 +21,7 @@ #include vector #include boost/unordered_map.hpp -#define USE_DUMMY_INTERPRETER 1 +#define USE_DUMMY_INTERPRETER 0 #if USE_DUMMY_INTERPRETER #include cstdio ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/opencl/formulagroupcl.cxx | 24 sc/source/core/tool/formulagroup.cxx |3 +++ 2 files changed, 15 insertions(+), 12 deletions(-) New commits: commit d718f08f18da1fbee08e60fb8c6013abae1c7126 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Mon Sep 9 10:52:42 2013 -0400 Instantiate the software fallback outside of opencl code. Change-Id: I7ec7a951492616abd3c7327b85f09c1e913208ca diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 0ae58e8..0f8b46f 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1063,18 +1063,18 @@ bool FormulaGroupInterpreterGroundwater::interpret(ScDocument rDoc, const ScAdd } namespace opencl { -sc::FormulaGroupInterpreter *createFormulaGroupInterpreter() -{ -if (getenv(SC_SOFTWARE)) -{ -fprintf(stderr, Create S/W interp\n); -return new sc::FormulaGroupInterpreterSoftware(); -} -if (getenv(SC_GROUNDWATER)) -return new sc::FormulaGroupInterpreterGroundwater(); -else -return new sc::FormulaGroupInterpreterOpenCL(); -} + +sc::FormulaGroupInterpreter *createFormulaGroupInterpreter() +{ +if (getenv(SC_SOFTWARE)) +return NULL; + +if (getenv(SC_GROUNDWATER)) +return new sc::FormulaGroupInterpreterGroundwater(); + +return new sc::FormulaGroupInterpreterOpenCL(); +} + } // namespace opencl } // namespace sc diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 2ea09c4..6c930e5 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -216,7 +216,10 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic() msInstance = sc::opencl::createFormulaGroupInterpreter(); #endif if ( !msInstance ) // software fallback +{ +fprintf(stderr, Create S/W interp\n); msInstance = new sc::FormulaGroupInterpreterSoftware(); +} } return msInstance; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/opencl/formulagroupcl.cxx |9 + 1 file changed, 5 insertions(+), 4 deletions(-) New commits: commit 8b7b76cfeead4c77af0c34d64eb17b0bd476e20a Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Mon Sep 9 11:05:03 2013 -0400 The OpenCL interpreter doesn't have to be a child class of the S/W one. Change-Id: Idcc28b98fceaffdc8947410fef5fadbae462450b diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 0f8b46f..279ac2d 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -104,7 +104,7 @@ public: }; -class FormulaGroupInterpreterOpenCL : public FormulaGroupInterpreterSoftware +class FormulaGroupInterpreterOpenCL : public FormulaGroupInterpreter { SourceData *mSrcDataStack[SRCDATASIZE]; unsigned int mnStackPointer,mnDoublePtrCount; @@ -124,7 +124,7 @@ class FormulaGroupInterpreterOpenCL : public FormulaGroupInterpreterSoftware size_t mnRowSize; public: FormulaGroupInterpreterOpenCL() : -FormulaGroupInterpreterSoftware() +FormulaGroupInterpreter() { mnStackPointer = 0; mnpOclEndPos = NULL; @@ -952,6 +952,9 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument rDoc, const ScAddress /// Special case of formula compiler for groundwatering class FormulaGroupInterpreterGroundwater : public FormulaGroupInterpreterSoftware { +bool interpretCL(ScDocument rDoc, const ScAddress rTopPos, + const ScFormulaCellGroupRef xGroup, ScTokenArray rCode); + public: FormulaGroupInterpreterGroundwater() : FormulaGroupInterpreterSoftware() @@ -965,8 +968,6 @@ public: } virtual ScMatrixRef inverseMatrix(const ScMatrix /* rMat */) { return ScMatrixRef(); } -virtual bool interpretCL(ScDocument rDoc, const ScAddress rTopPos, - const ScFormulaCellGroupRef xGroup, ScTokenArray rCode); virtual bool interpret(ScDocument rDoc, const ScAddress rTopPos, const ScFormulaCellGroupRef xGroup, ScTokenArray rCode); }; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/data/column2.cxx |9 ++--- sc/source/core/tool/formulagroup.cxx | 14 +- sc/source/core/tool/interpr6.cxx |2 +- 3 files changed, 20 insertions(+), 5 deletions(-) New commits: commit 7611a40ef8d2a92bcc2f080a3725cccb7ffe871f Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Mon Sep 9 14:24:10 2013 -0400 Correctly handle empty cells in group calculation (software interpreter). Store NaN's to represent empty cells rather than storing 0's. Storing 0's would mess up COUNT(), for example. Change-Id: I8e350e1fe31358b844dd44451ed8659172fda1cb diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 9d0130c..5f7f843 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2055,6 +2055,9 @@ bool appendDouble( sc::CellStoreType::iterator it, const sc::CellStoreType::iterator itEnd ) { size_t nLenRemain = nLen; +double fNan; +rtl::math::setNan(fNan); + for (; it != itEnd; ++it) { switch (it-type) @@ -2119,15 +2122,15 @@ bool appendDouble( break; case sc::element_type_empty: { -// Fill it with 0's. +// Fill it with NaN's. if (nLenRemain = it-size) { -rArray.resize(rArray.size() + it-size, 0); +rArray.resize(rArray.size() + it-size, fNan); nLenRemain -= it-size; } else { -rArray.resize(rArray.size() + nLenRemain, 0); +rArray.resize(rArray.size() + nLenRemain, fNan); nLenRemain = 0; } } diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 6c930e5..ca888dc 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -50,6 +50,9 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const ScAddres aResults.reserve(xGroup-mnLength); CachedTokensType aCachedTokens; +double fNan; +rtl::math::setNan(fNan); + for (SCROW i = 0; i xGroup-mnLength; ++i, aTmpPos.IncRow()) { ScTokenArray aCode2; @@ -70,7 +73,16 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const ScAddres const formula::SingleVectorRefToken* p2 = static_castconst formula::SingleVectorRefToken*(p); const formula::VectorRefArray rArray = p2-GetArray(); if (rArray.mbNumeric) -aCode2.AddDouble(static_castsize_t(i) p2-GetArrayLength() ? rArray.mpNumericArray[i] : 0.0); +{ +double fVal = fNan; +if (static_castsize_t(i) p2-GetArrayLength()) +fVal = rArray.mpNumericArray[i]; + +if (rtl::math::isNan(fVal)) +aCode2.AddToken(ScEmptyCellToken(false, false)); +else +aCode2.AddDouble(fVal); +} else aCode2.AddString(static_castsize_t(i) p2-GetArrayLength() ? rArray.mpStringArray[i] : OUString()); } diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx index 4dbbf1d..470c8d8 100644 --- a/sc/source/core/tool/interpr6.cxx +++ b/sc/source/core/tool/interpr6.cxx @@ -880,7 +880,7 @@ void ScInterpreter::ScCount() while (nParamCount-- 0) { -switch (GetStackType()) +switch (GetRawStackType()) { case svString: { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/data/column2.cxx |6 +++- sc/source/core/tool/formulagroup.cxx | 44 +-- 2 files changed, 46 insertions(+), 4 deletions(-) New commits: commit 21567d48e49bb91f4dd2610f21630a68108218fc Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Mon Sep 9 15:32:25 2013 -0400 Do the same for range vector tokens. Change-Id: Id80f76dbe575fc6b279dafbfc524a9230755ddc8 diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 5f7f843..34ecbb2 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -2268,8 +2268,10 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( sc::FormulaGroupContext { if (nLenRequested = nLen) { -// Fill the whole length with zero. -rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(nLenRequested, 0.0)); +// Fill the whole length with NaN's. +double fNan; +rtl::math::setNan(fNan); +rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(nLenRequested, fNan)); return formula::VectorRefArray(rCxt.maNumArrays.back()[0]); } diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index ca888dc..f6a1dff 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -29,6 +29,46 @@ namespace sc { +namespace { + +/** + * Input double array consists of segments of NaN's and normal values. + * Insert only the normal values into the matrix while skipping the NaN's. + */ +void fillMatrix( ScMatrix rMat, size_t nCol, const double* pNums, size_t nLen ) +{ +const double* p = pNums; +const double* pEnd = p + nLen; +const double* pHead = NULL; +for (; p != pEnd; ++p) +{ +if (!rtl::math::isNan(*p)) +{ +if (!pHead) +// Store the first non-NaN position. +pHead = p; + +continue; +} + +if (pHead) +{ +// Flush this non-NaN segment to the matrix. +rMat.PutDouble(pHead, p - pHead, nCol, pHead - pNums); +pHead = NULL; +} +} + +if (pHead) +{ +// Flush last non-NaN segment to the matrix. +rMat.PutDouble(pHead, p - pHead, nCol, pHead - pNums); +pHead = NULL; +} +} + +} + ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix /*rMat*/) { return ScMatrixRef(); @@ -97,7 +137,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const ScAddres if (!p2-IsEndFixed()) nRowEnd += i; size_t nRowSize = nRowEnd - nRowStart + 1; -ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize, 0.0)); +ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize)); for (size_t nCol = 0; nCol nColSize; ++nCol) { const formula::VectorRefArray rArray = rArrays[nCol]; @@ -105,7 +145,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const ScAddres { const double* pNums = rArray.mpNumericArray; pNums += nRowStart; -pMat-PutDouble(pNums, nRowSize, nCol, 0); +fillMatrix(*pMat, nCol, pNums, nRowSize); } else { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
sc/source/core/data/formulacell.cxx |6 +++--- sc/source/core/tool/formulagroup.cxx | 11 --- 2 files changed, 11 insertions(+), 6 deletions(-) New commits: commit d087e58d0787584f2829f3cf854d4d6b217e0c05 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Sep 10 00:11:13 2013 -0400 Fix several logic errors in required array size calculation. Change-Id: Ife05e21583d14c873d38c09d78e964cdb3817d6c diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 7e8a975..fe27177 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3437,7 +3437,7 @@ public: case svDoubleRef: { ScComplexRefData aRef = pToken-GetDoubleRef(); -ScRange aAbs = aRef.toAbs(mrCell.aPos); +ScRange aAbs = aRef.toAbs(mrPos); // Check for self reference. if (aRef.Ref1.IsRowRel()) @@ -3463,12 +3463,12 @@ public: size_t nCols = aAbs.aEnd.Col() - aAbs.aStart.Col() + 1; std::vectorformula::VectorRefArray aArrays; aArrays.reserve(nCols); -SCROW nArrayLength = nLen; SCROW nRefRowSize = aAbs.aEnd.Row() - aAbs.aStart.Row() + 1; +SCROW nArrayLength = nRefRowSize; if (!bAbsLast) { // range end position is relative. Extend the array length. -nArrayLength += nRefRowSize - 1; +nArrayLength += nLen - 1; } // Trim trailing empty rows. diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 5dff3d9..1dbe5bd 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -204,9 +204,14 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const ScAddres nRowEnd += i; size_t nRowSize = nRowEnd - nRowStart + 1; ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize)); -if (p2-GetArrayLength() nRowSize) -// Data array is shorter than the row size of the reference. Truncate it. -nRowSize = p2-GetArrayLength(); + +size_t nDataRowEnd = p2-GetArrayLength() - 1; +if (nRowStart nDataRowEnd) +// Referenced rows are all empty. +nRowSize = 0; +else if (nRowEnd nDataRowEnd) +// Data array is shorter than the row size of the reference. Truncate it to the data. +nRowSize -= nRowEnd - nDataRowEnd; for (size_t nCol = 0; nCol nColSize; ++nCol) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/kohei/formula-opencl-work' - sc/source
Rebased ref, commits from common ancestor: commit b44aca7cfc0c7b73f6213ee3f5d4c5f3b2fc8e95 Author: Kohei Yoshida kohei.yosh...@collabora.com Date: Tue Sep 10 00:11:13 2013 -0400 Fix several logic errors in required array size calculation. Change-Id: Ife05e21583d14c873d38c09d78e964cdb3817d6c diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 7e8a975..91e91dc 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -3437,7 +3437,7 @@ public: case svDoubleRef: { ScComplexRefData aRef = pToken-GetDoubleRef(); -ScRange aAbs = aRef.toAbs(mrCell.aPos); +ScRange aAbs = aRef.toAbs(mrPos); // Check for self reference. if (aRef.Ref1.IsRowRel()) @@ -3463,12 +3463,16 @@ public: size_t nCols = aAbs.aEnd.Col() - aAbs.aStart.Col() + 1; std::vectorformula::VectorRefArray aArrays; aArrays.reserve(nCols); -SCROW nArrayLength = nLen; SCROW nRefRowSize = aAbs.aEnd.Row() - aAbs.aStart.Row() + 1; +SCROW nArrayLength = nRefRowSize; if (!bAbsLast) { // range end position is relative. Extend the array length. -nArrayLength += nRefRowSize - 1; +SCROW nLastRefRowOffset = aAbs.aEnd.Row() - mrPos.Row(); +SCROW nLastRefRow = mrPos.Row() + nLen - 1 + nLastRefRowOffset; +SCROW nNewLength = nLastRefRow - aAbs.aStart.Row() + 1; +if (nNewLength nArrayLength) +nArrayLength = nNewLength; } // Trim trailing empty rows. diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 5dff3d9..1dbe5bd 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -204,9 +204,14 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument rDoc, const ScAddres nRowEnd += i; size_t nRowSize = nRowEnd - nRowStart + 1; ScMatrixRef pMat(new ScMatrix(nColSize, nRowSize)); -if (p2-GetArrayLength() nRowSize) -// Data array is shorter than the row size of the reference. Truncate it. -nRowSize = p2-GetArrayLength(); + +size_t nDataRowEnd = p2-GetArrayLength() - 1; +if (nRowStart nDataRowEnd) +// Referenced rows are all empty. +nRowSize = 0; +else if (nRowEnd nDataRowEnd) +// Data array is shorter than the row size of the reference. Truncate it to the data. +nRowSize -= nRowEnd - nDataRowEnd; for (size_t nCol = 0; nCol nColSize; ++nCol) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits