[Libreoffice-commits] core.git: Branch 'private/kendy/testcl' - 3 commits - desktop/Library_sofficeapp.mk desktop/source opencl/source sc/Module_sc.mk sc/Package_opencl.mk

Jan Holesovsky kendy at collabora.com
Mon Jul 11 18:42:40 UTC 2016


 desktop/Library_sofficeapp.mk   |    1 
 desktop/source/app/app.cxx      |   78 ++++++++++++++++++++++++++++++++++++++++
 opencl/source/openclwrapper.cxx |    2 -
 sc/Module_sc.mk                 |    1 
 sc/Package_opencl.mk            |   16 ++++++++
 5 files changed, 97 insertions(+), 1 deletion(-)

New commits:
commit 0bf3eac65602dae1cd6c6df77d22c53b5c37a1a2
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Jul 11 19:16:47 2016 +0200

    Make this conditional.
    
    Change-Id: I93adf7c2acdc8fab8bbe0c92d841b81455caf89a

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 046da38..3154a7b 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -57,7 +57,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
     deploymentmisc \
     editeng \
     i18nlangtag \
-    opencl \
+    $(if $(filter OPENCL,$(BUILD_TYPE)),opencl) \
     sal \
     salhelper \
     sb \
commit e392afd0842b091190f6c6e0707ea0b72c69f467
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Jul 11 17:43:51 2016 +0200

    Install the cl-test.ods to program/opencl and use it for the test.
    
    Change-Id: I1ee619a8ac3eee92912d37b47bb82d4550e4c42b

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index b5fe0ca..cc05d74 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1351,8 +1351,10 @@ void testOpenCLCompute(const Reference< XDesktop2 > &xDesktop)
         aArgs[0].Name = "Hidden";
         aArgs[0].Value = makeAny(true);
 
-        xComponent.set(xLoader->loadComponentFromURL("file:///tmp/cl-test.ods",
-                                                     "_blank", 0, aArgs));
+        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);
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 9c331bb..392fbe0 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_Module_add_targets,sc,\
 	Library_scd \
 	Library_scfilt \
 	$(call gb_Helper_optional,DESKTOP,Library_scui) \
+	$(call gb_Helper_optional,OPENCL,Package_opencl) \
 ))
 
 $(eval $(call gb_Module_add_l10n_targets,sc,\
diff --git a/sc/Package_opencl.mk b/sc/Package_opencl.mk
new file mode 100644
index 0000000..ef1579f
--- /dev/null
+++ b/sc/Package_opencl.mk
@@ -0,0 +1,16 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Package_Package,sc_opencl_runtimetest,$(SRCDIR)/sc/source/core/opencl))
+
+$(eval $(call gb_Package_add_files,sc_opencl_runtimetest,$(LIBO_ETC_FOLDER)/opencl,\
+	cl-test.ods \
+))
+
+# vim: set noet sw=4 ts=4:
commit cbd73306dd02aa65329d98160210160f6fef1ad1
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Jul 11 15:12:38 2016 +0100

    First cut of startup test OpenCL compute ...
    
    Change-Id: I4c42585f8b9553c39265a4d73568ce51114ea396
    FIXME: needs to:
       a) only do this on driver / version change.
       b) actually work ;-)

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 04bc491..046da38 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -57,6 +57,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
     deploymentmisc \
     editeng \
     i18nlangtag \
+    opencl \
     sal \
     salhelper \
     sb \
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index fab48e1..b5fe0ca 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -75,6 +75,12 @@
 #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>
@@ -109,6 +115,7 @@
 #include <svtools/accessibilityoptions.hxx>
 #include <svtools/apearcfg.hxx>
 #include <vcl/graphicfilter.hxx>
+#include <opencl/OpenCLZone.hxx>
 
 #include "langselect.hxx"
 
@@ -1326,6 +1333,70 @@ 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);
+
+        xComponent.set(xLoader->loadComponentFromURL("file:///tmp/cl-test.ods",
+                                                     "_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();
@@ -1605,6 +1676,11 @@ int Desktop::Main()
             FatalError( MakeStartupErrorMessage(e.Message) );
         }
 
+        // FIXME: move this somewhere sensible.
+#if HAVE_FEATURE_OPENCL
+        testOpenCLCompute(xDesktop);
+#endif
+
         // Release solar mutex just before we wait for our client to connect
         {
             SolarMutexReleaser aReleaser;
diff --git a/opencl/source/openclwrapper.cxx b/opencl/source/openclwrapper.cxx
index db6c7e5..9f31bf4a 100644
--- a/opencl/source/openclwrapper.cxx
+++ b/opencl/source/openclwrapper.cxx
@@ -701,7 +701,7 @@ void findDeviceInfoFromDeviceId(cl_device_id aDeviceId, size_t& rDeviceId, size_
 
 bool switchOpenCLDevice(const OUString* pDevice, bool bAutoSelect, bool bForceEvaluation, OUString& rOutSelectedDeviceVersionIDString)
 {
-    if(fillOpenCLInfo().empty())
+    if(fillOpenCLInfo().empty() || getenv("SAL_DISABLE_OPENCL"))
         return false;
 
     cl_device_id pDeviceId = nullptr;


More information about the Libreoffice-commits mailing list