[Libreoffice-commits] core.git: Branch 'private/tml/opencl-background-compilation' - 2 commits - sc/Module_sc.mk sc/source

Tor Lillqvist tml at collabora.com
Mon Nov 18 11:00:46 PST 2013


 sc/Module_sc.mk                     |    4 --
 sc/source/core/data/formulacell.cxx |   49 ++++++++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 16 deletions(-)

New commits:
commit 5783999465fe01fac923d2d5d764a0334bbe195c
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Nov 18 20:43:09 2013 +0200

    Enable sc_opencl_test again
    
    Change-Id: I28079dbda04529b1d9a63aca04a1a6b95ca4aa14

diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index c4a38ee..2ca7ad2 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -47,13 +47,11 @@ $(eval $(call gb_Module_add_targets,sc,\
 
 endif
 
-# Disabled because fails on too many machines in
-# the OpenCL compiler
-# CppunitTest_sc_opencl_test \
 $(eval $(call gb_Module_add_check_targets,sc,\
     CppunitTest_sc_ucalc \
     CppunitTest_sc_filters_test \
     CppunitTest_sc_rangelst_test \
+    CppunitTest_sc_opencl_test \
 ))
 
 $(eval $(call gb_Module_add_slowcheck_targets,sc, \
commit 389570d1133d7307f02f8a7b2f899d453511d5b3
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Nov 18 20:27:48 2013 +0200

    Try to make the background OpenCL compilation conditional at run-time
    
    Change-Id: I2366465f4e786f905c32b17a15c16486c4c21d38

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index cf4516d..8a7d644 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -18,6 +18,7 @@
  */
 
 #include "formulacell.hxx"
+#include "grouptokenconverter.hxx"
 
 #include "compiler.hxx"
 #include "document.hxx"
@@ -414,14 +415,18 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
     mbSubTotal(false),
     meCalcState(sc::GroupCalcEnabled)
 {
-    if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
+    static bool bBackgroundCompilation = getenv("SC_BACKGROUND_COMPILATION") != NULL;
+    if (bBackgroundCompilation)
     {
-        osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
-        if (mnCount++ == 0)
+        if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
         {
-            assert(!mxCLKernelThread.is());
-            mxCLKernelThread.set(new sc::CLBuildKernelThread);
-            mxCLKernelThread->launch();
+            osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
+            if (mnCount++ == 0)
+            {
+                assert(!mxCLKernelThread.is());
+                mxCLKernelThread.set(new sc::CLBuildKernelThread);
+                mxCLKernelThread->launch();
+            }
         }
     }
 }
@@ -431,7 +436,7 @@ ScFormulaCellGroup::~ScFormulaCellGroup()
     if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
     {
         osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
-        if (--mnCount == 0)
+        if (--mnCount == 0 && mxCLKernelThread.is())
             {
                 assert(mxCLKernelThread.is());
                 mxCLKernelThread->finish();
@@ -3480,17 +3485,35 @@ bool ScFormulaCell::InterpretFormulaGroup()
     if (mxGroup->mbInvariant && false)
         return InterpretInvariantFormulaGroup();
 
-    ScTokenArray aDummy;
     if (mxGroup->meCalcState == sc::GroupCalcEnabled)
+    {
+        ScTokenArray aCode;
+        ScAddress aTopPos = aPos;
+        aTopPos.SetRow(mxGroup->mpTopCell->aPos.Row());
+        ScGroupTokenConverter aConverter(aCode, *pDocument, *this, mxGroup->mpTopCell->aPos);
+        if (!aConverter.convert(*pCode))
+            {
+                mxGroup->meCalcState = sc::GroupCalcDisabled;
+                return false;
+            }
         mxGroup->meCalcState = sc::GroupCalcRunning;
-    if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aDummy))
+        if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aCode))
+        {
+            mxGroup->meCalcState = sc::GroupCalcDisabled;
+            return false;
+        }
+        mxGroup->meCalcState = sc::GroupCalcEnabled;
+    }
+    else
     {
-        mxGroup->meCalcState = sc::GroupCalcDisabled;
-        return false;
+        ScTokenArray aDummy;
+        if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aDummy))
+            {
+                mxGroup->meCalcState = sc::GroupCalcDisabled;
+                return false;
+            }
     }
 
-    if (mxGroup->meCalcState == sc::GroupCalcRunning)
-        mxGroup->meCalcState = sc::GroupCalcEnabled;
     return true;
 }
 


More information about the Libreoffice-commits mailing list