diff options
-rw-r--r-- | offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl | 11 | ||||
-rw-r--r-- | sc/inc/docuno.hxx | 6 | ||||
-rw-r--r-- | sc/inc/formulagroup.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/opencl/openclwrapper.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/opencl/openclwrapper.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 23 |
8 files changed, 53 insertions, 11 deletions
diff --git a/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl b/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl index 26ab32885ac7..994867e6a069 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 1228afe10a47..a8b6b261f9cd 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 17f00d1708bb..3834e49bd9d2 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 8e4c5be4f2f3..c87badc4c6cf 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 54d997db4cce..cf74a4be7418 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 073ce1aa3548..97b3e9170dc9 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 c2258205fe1c..aa6e8e7d5bf7 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 b78f8b8dd1fe..2b4d3e25ad70 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) { |