[Libreoffice-commits] core.git: offapi/com sc/inc sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Nov 25 13:15:26 PST 2013


 offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl |   11 ++++++++
 sc/inc/docuno.hxx                                     |    6 ++++
 sc/inc/formulagroup.hxx                               |    2 -
 sc/source/core/opencl/formulagroupcl.cxx              |    5 ++-
 sc/source/core/opencl/openclwrapper.cxx               |    4 +--
 sc/source/core/opencl/openclwrapper.hxx               |    3 +-
 sc/source/core/tool/formulagroup.cxx                  |   10 +++----
 sc/source/ui/unoobj/docuno.cxx                        |   23 ++++++++++++++++++
 8 files changed, 53 insertions(+), 11 deletions(-)

New commits:
commit b5d4d946e0355d2c2496d61625a9abb06dab6929
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 25 22:13:32 2013 +0100

    add methods to enable and disable automatic device selection
    
    Change-Id: I7136ad48ad3f20c60b77838225ce6c927514acff

diff --git a/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl b/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
index 26ab328..994867e 100644
--- a/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
+++ b/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
@@ -25,6 +25,17 @@ interface XOpenCLSelection : com::sun::star::uno::XInterface
     void enableOpenCL( [in] boolean enable );
 
     /**
+     * Enables automatic OpenCL Device Selection
+     * @param force forces a new evaluation of the best device
+     */
+    void enableAutomaticDeviceSelection( [in] boolean force );
+
+    /**
+     * Disbales automatic OpenCL Device Selection
+     */
+    void disableAutomaticDeviceSelection();
+
+    /**
      * Set the OpenCL device with the platform ID and device ID
      * Uses the ID of the platform and the device
      */
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 1228afe..a8b6b26 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -326,6 +326,12 @@ public:
     virtual void SAL_CALL enableOpenCL(sal_Bool bEnable)
                                 throw(::com::sun::star::uno::RuntimeException);
 
+    virtual void SAL_CALL enableAutomaticDeviceSelection(sal_Bool bForce)
+                                throw(::com::sun::star::uno::RuntimeException);
+
+    virtual void SAL_CALL disableAutomaticDeviceSelection()
+                                throw(::com::sun::star::uno::RuntimeException);
+
     virtual void SAL_CALL selectOpenCLDevice( sal_Int32 platform, sal_Int32 device )
                                 throw(::com::sun::star::uno::RuntimeException);
 
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 17f00d1..3834e49 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -95,7 +95,7 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
  public:
     static FormulaGroupInterpreter *getStatic();
     static void fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rPlatforms);
-    static bool switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect);
+    static bool switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation = false);
     static void enableOpenCL(bool bEnable);
     static void getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId);
 
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 8e4c5be..c87badc 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2889,9 +2889,10 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL fillOpenCLInfo(
 }
 
 SAL_DLLPUBLIC_EXPORT bool SAL_CALL switchOpenClDevice(
-                       const OUString* pDeviceId, bool bAutoSelect)
+                       const OUString* pDeviceId, bool bAutoSelect,
+                       bool bForceEvaluation)
 {
-    return sc::opencl::switchOpenclDevice(pDeviceId, bAutoSelect);
+    return sc::opencl::switchOpenclDevice(pDeviceId, bAutoSelect, bForceEvaluation);
 }
 
 SAL_DLLPUBLIC_EXPORT void SAL_CALL getOpenCLDeviceInfo(size_t* pDeviceId, size_t* pPlatformId)
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index 54d997d..cf74a4be 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -920,7 +920,7 @@ void findDeviceInfoFromDeviceId(cl_device_id aDeviceId, size_t& rDeviceId, size_
 
 }
 
-bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect)
+bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEvaluation)
 {
     cl_device_id pDeviceId = NULL;
     if(pDevice)
@@ -937,7 +937,7 @@ bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect)
         OUString path;
         osl::FileBase::getSystemPathFromFileURL(url,path);
         OString dsFileName = rtl::OUStringToOString(path, RTL_TEXTENCODING_UTF8);
-        ds_device pSelectedDevice = sc::OpenCLDevice::getDeviceSelection(dsFileName.getStr());
+        ds_device pSelectedDevice = sc::OpenCLDevice::getDeviceSelection(dsFileName.getStr(), bForceEvaluation);
         pDeviceId = pSelectedDevice.oclDeviceID;
 
     }
diff --git a/sc/source/core/opencl/openclwrapper.hxx b/sc/source/core/opencl/openclwrapper.hxx
index 073ce1a..97b3e91 100644
--- a/sc/source/core/opencl/openclwrapper.hxx
+++ b/sc/source/core/opencl/openclwrapper.hxx
@@ -183,7 +183,8 @@ const std::vector<OpenclPlatformInfo>& fillOpenCLInfo();
  *
  * @return returns true if there is a valid opencl device that has been set up
  */
-bool switchOpenclDevice(const OUString* pDeviceId, bool bAutoSelect);
+bool switchOpenclDevice(const OUString* pDeviceId, bool bAutoSelect,
+        bool bForceEvaluation);
 
 void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId);
 
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index c225820..aa6e8e7 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -31,7 +31,7 @@
 
 extern "C" size_t getOpenCLPlatformCount(void);
 extern "C" void fillOpenCLInfo(sc::OpenclPlatformInfo*, size_t);
-extern "C" bool switchOpenClDevice(const OUString*, bool);
+extern "C" bool switchOpenClDevice(const OUString*, bool, bool);
 extern "C" sc::FormulaGroupInterpreter* createFormulaGroupOpenCLInterpreter();
 extern "C" void getOpenCLDeviceInfo(size_t*, size_t*);
 
@@ -504,7 +504,7 @@ static void SAL_CALL thisModule() {}
 typedef FormulaGroupInterpreter* (*__createFormulaGroupOpenCLInterpreter)(void);
 typedef size_t (*__getOpenCLPlatformCount)(void);
 typedef void (*__fillOpenCLInfo)(OpenclPlatformInfo*, size_t);
-typedef bool (*__switchOpenClDevice)(const OUString*, bool);
+typedef bool (*__switchOpenClDevice)(const OUString*, bool, bool);
 typedef void (*__getOpenCLDeviceInfo)(size_t*, size_t*);
 
 #endif
@@ -587,7 +587,7 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rP
 #endif
 }
 
-bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect)
+bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation)
 {
     bool bOpenCLEnabled = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled;
     if(!bOpenCLEnabled || rDeviceId == "Software")
@@ -614,11 +614,11 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
     if (!fn)
         return false;
 
-    bool bSuccess = reinterpret_cast<__switchOpenClDevice>(fn)(&rDeviceId, bAutoSelect);
+    bool bSuccess = reinterpret_cast<__switchOpenClDevice>(fn)(&rDeviceId, bAutoSelect, bForceEvaluation);
     if(!bSuccess)
         return false;
 #else
-    bool bSuccess = switchOpenClDevice(&rDeviceId, bAutoSelect);
+    bool bSuccess = switchOpenClDevice(&rDeviceId, bAutoSelect, bForceEvaluation);
     if(!bSuccess)
         return false;
 #endif
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b78f8b8..2b4d3e2 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -2307,6 +2307,29 @@ void ScModelObj::enableOpenCL(sal_Bool bEnable)
     ScInterpreter::SetGlobalConfig(aConfig);
 }
 
+void ScModelObj::enableAutomaticDeviceSelection(sal_Bool bForce)
+    throw (uno::RuntimeException)
+{
+    ScCalcConfig aConfig = ScInterpreter::GetGlobalConfig();
+    aConfig.mbOpenCLAutoSelect = true;
+    ScInterpreter::SetGlobalConfig(aConfig);
+    ScFormulaOptions aOptions = SC_MOD()->GetFormulaOptions();
+    aOptions.SetCalcConfig(aConfig);
+    SC_MOD()->SetFormulaOptions(aOptions);
+    sc::FormulaGroupInterpreter::switchOpenCLDevice(OUString(), true, bForce);
+}
+
+void ScModelObj::disableAutomaticDeviceSelection()
+    throw (uno::RuntimeException)
+{
+    ScCalcConfig aConfig = ScInterpreter::GetGlobalConfig();
+    aConfig.mbOpenCLAutoSelect = false;
+    ScInterpreter::SetGlobalConfig(aConfig);
+    ScFormulaOptions aOptions = SC_MOD()->GetFormulaOptions();
+    aOptions.SetCalcConfig(aConfig);
+    SC_MOD()->SetFormulaOptions(aOptions);
+}
+
 void ScModelObj::selectOpenCLDevice( sal_Int32 nPlatform, sal_Int32 nDevice )
     throw (uno::RuntimeException)
 {


More information about the Libreoffice-commits mailing list