desktop/Library_sofficeapp.mk | 2 desktop/inc/app.hxx | 1 desktop/source/app/app.cxx | 75 ----------------------------------- opencl/inc/opencl_device.hxx | 3 + opencl/source/OpenCLZone.cxx | 4 + opencl/source/openclwrapper.cxx | 6 ++ sc/source/core/tool/formulagroup.cxx | 10 ---- 7 files changed, 16 insertions(+), 85 deletions(-)
New commits: commit 624df9d568b78a792b247b3f6daf5b51d479a25e Author: Michael Meeks <michael.me...@collabora.com> Date: Mon Jul 11 23:20:27 2016 +0100 Re-work opencl / desktop testing pieces. Split opencl validation pieces into their own module to avoid cl header spread. Use app version, and CL driver version to trigger re-testing the device. Hard disable, should cleanup existing CL device too. Change-Id: I3893351b6f3845538c74b3b5bf46724cd9bde62d diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk index 3154a7b..a5cf82b 100644 --- a/desktop/Library_sofficeapp.mk +++ b/desktop/Library_sofficeapp.mk @@ -24,6 +24,7 @@ $(eval $(call gb_Library_add_libs,sofficeapp,\ )) $(eval $(call gb_Library_use_externals,sofficeapp, \ + $(if $(filter OPENCL,$(BUILD_TYPE)),clew) \ boost_headers \ dbus \ )) @@ -103,6 +104,7 @@ $(eval $(call gb_Library_add_exception_objects,sofficeapp,\ desktop/source/app/langselect \ desktop/source/app/lockfile2 \ desktop/source/app/officeipcthread \ + desktop/source/app/opencl \ desktop/source/app/sofficemain \ desktop/source/app/userinstall \ desktop/source/migration/migration \ diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 1905cf0..c90bfdb 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -84,6 +84,7 @@ class Desktop : public Application static void OpenClients(); static void OpenDefault(); + static void CheckOpenCLCompute(const css::uno::Reference<css::frame::XDesktop2> &); DECL_STATIC_LINK_TYPED( Desktop, EnableAcceptors_Impl, void*, void); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index cc05d74..7628c7a 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -75,12 +75,6 @@ #include <com/sun/star/frame/thePopupMenuControllerFactory.hpp> #include <com/sun/star/office/Quickstart.hpp> -#include <com/sun/star/table/XCell2.hpp> -#include <com/sun/star/sheet/XCalculatable.hpp> -#include <com/sun/star/sheet/XSpreadsheet.hpp> -#include <com/sun/star/sheet/XSpreadsheets.hpp> -#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> - #include <desktop/exithelper.h> #include <sal/log.hxx> #include <toolkit/helper/vclunohelper.hxx> @@ -115,7 +109,6 @@ #include <svtools/accessibilityoptions.hxx> #include <svtools/apearcfg.hxx> #include <vcl/graphicfilter.hxx> -#include <opencl/OpenCLZone.hxx> #include "langselect.hxx" @@ -1333,72 +1326,6 @@ void Desktop::DoExecute() #endif } -#if HAVE_FEATURE_OPENCL -void testOpenCLCompute(const Reference< XDesktop2 > &xDesktop) -{ - if (getenv("SAL_DISABLE_OPENCL")) - return; - - css::uno::Reference< css::lang::XComponent > xComponent; - - SAL_INFO("opencl", "Initiating test of OpenCL device"); - try { - OpenCLZone aZone; - css::uno::Reference< css::frame::XComponentLoader > xLoader(xDesktop, css::uno::UNO_QUERY_THROW); - - // FIXME: invisible, read-only etc. - css::uno::Sequence< css::beans::PropertyValue > aArgs(1); - aArgs[0].Name = "Hidden"; - aArgs[0].Value = makeAny(true); - - OUString aUrl("$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/opencl/cl-test.ods"); - rtl::Bootstrap::expandMacros(aUrl); - - xComponent.set(xLoader->loadComponentFromURL(aUrl, "_blank", 0, aArgs)); - - // What an unpleasant API to use. - css::uno::Reference< css::sheet::XCalculatable > xCalculatable( xComponent, css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::sheet::XSpreadsheetDocument > xSpreadDoc( xComponent, css::uno::UNO_QUERY_THROW ); - css::uno::Reference< css::sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), css::uno::UNO_QUERY_THROW ); - css::uno::Reference< css::container::XIndexAccess > xIndex( xSheets, css::uno::UNO_QUERY_THROW ); - css::uno::Reference< css::sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), css::uno::UNO_QUERY_THROW); - - // So we insert our MAX call at the end on a named range. - css::uno::Reference< css::table::XCell2 > xThresh( xSheet->getCellByPosition(1,1), css::uno::UNO_QUERY_THROW ); // B2 - double fThreshold = xThresh->getValue(); - - // We need pure OCL formulae all the way through the - // dependency chain, or we fall-back. - xCalculatable->calculateAll(); - - // So we insert our MAX call at the end on a named range. - css::uno::Reference< css::table::XCell2 > xCell( xSheet->getCellByPosition(1,0), css::uno::UNO_QUERY_THROW ); - xCell->setFormula("=MAX(results)"); - double fResult = xCell->getValue(); - - // Ensure the maximum variance is below our tolerance. - if (fResult > fThreshold) - { - SAL_WARN("opencl", "OpenCL results unstable - disabling; result: " - << fResult << " vs. " << fThreshold); - OpenCLZone::hardDisable(); - } - else - { - SAL_INFO("opencl", "calculating smoothly; result: " << fResult); - } - } - catch (const css::uno::Exception &e) - { - SAL_WARN("opencl", "OpenCL testing failed - disabling."); - OpenCLZone::hardDisable(); - } - - if (xComponent.is()) - xComponent->dispose(); -} -#endif // HAVE_FEATURE_OPENCL - int Desktop::Main() { pExecGlobals = new ExecuteGlobals(); @@ -1680,7 +1607,7 @@ int Desktop::Main() // FIXME: move this somewhere sensible. #if HAVE_FEATURE_OPENCL - testOpenCLCompute(xDesktop); + CheckOpenCLCompute(xDesktop); #endif // Release solar mutex just before we wait for our client to connect diff --git a/opencl/inc/opencl_device.hxx b/opencl/inc/opencl_device.hxx index 0963304..216af72 100644 --- a/opencl/inc/opencl_device.hxx +++ b/opencl/inc/opencl_device.hxx @@ -16,6 +16,9 @@ namespace opencl { ds_device getDeviceSelection(OUString const & pFileName, bool bForceSelection = false); +struct GPUEnv; +void releaseOpenCLEnv( GPUEnv *gpuInfo ); + } #endif diff --git a/opencl/source/OpenCLZone.cxx b/opencl/source/OpenCLZone.cxx index dc3a952..03521a2 100644 --- a/opencl/source/OpenCLZone.cxx +++ b/opencl/source/OpenCLZone.cxx @@ -7,7 +7,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <opencl/openclwrapper.hxx> #include <opencl/OpenCLZone.hxx> +#include "opencl_device.hxx" #include <memory> @@ -40,6 +42,8 @@ void OpenCLZone::hardDisable() auto xConfProvider = css::configuration::theDefaultProvider::get(comphelper::getProcessComponentContext()); css::uno::Reference<css::util::XFlushable> xFlushable(xConfProvider, css::uno::UNO_QUERY_THROW); xFlushable->flush(); + + releaseOpenCLEnv(&opencl::gpuEnv); } } diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx index 9f31bf4a..2aecdde 100644 --- a/opencl/source/openclwrapper.cxx +++ b/opencl/source/openclwrapper.cxx @@ -268,6 +268,8 @@ bool initOpenCLAttr( OpenCLEnv * env ) return false; } +} + void releaseOpenCLEnv( GPUEnv *gpuInfo ) { OpenCLZone zone; @@ -298,6 +300,8 @@ void releaseOpenCLEnv( GPUEnv *gpuInfo ) return; } +namespace { + bool buildProgram(const char* buildOption, GPUEnv* gpuInfo, int idx) { cl_int clStatus; @@ -884,7 +888,7 @@ const char* errorString(cl_int nError) bool GPUEnv::isOpenCLEnabled() { - return gpuEnv.mpDevID; + return gpuEnv.mpDevID && gpuEnv.mpContext; } } diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 4941504..15ce590 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -336,16 +336,6 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool delete msInstance; msInstance = new sc::opencl::FormulaGroupInterpreterOpenCL(); - if (aSelectedCLDeviceVersionID != officecfg::Office::Common::Misc::SelectedOpenCLDeviceIdentifier::get()) - { - // perform OpenCL calculation tests - - // save the device - std::shared_ptr<comphelper::ConfigurationChanges> xBatch(comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Misc::SelectedOpenCLDeviceIdentifier::set(aSelectedCLDeviceVersionID, xBatch); - xBatch->commit(); - } - return true; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits