summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2016-07-08 22:16:27 +0900
committerMichael Meeks <michael.meeks@collabora.com>2016-07-12 08:56:47 +0000
commitb535d0ae52089bc7e28024b76a3380ab91574466 (patch)
tree14329c062e9c77f3d48a4d201ccc7cf581b9f26b /include
parent1bb21a08054d6909725ac46be8a4d6d7e5141d7c (diff)
opencl: OpenCLZone, detect CL device change and disable CL on crash
Guard OpenCL calls with OpenCLZone, so if a OpenCL call crashes we detect this and disable OpenCL so next time the user doesn't encounter the crash at the same calculation because he has a broken OpenCL drivers. Similar has been implemented for OpenGL with good results. Additionaly we persistently remember a known good OpenCL device ID and driver version so we can match this and perform calculation tests when they change. This is to ensure that the selected OpenCL device performs as we expect. In this commit the calculation tests aren't included yet. Remove complex static initializer in opencl wrapper library. Change-Id: I1a8b81ee31298731efcf63dc6a476955afc035e9 Reviewed-on: https://gerrit.libreoffice.org/27064 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit f41eb66302208f384a475fb20c98b6d1b0676cb6) Reviewed-on: https://gerrit.libreoffice.org/27099 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'include')
-rw-r--r--include/opencl/OpenCLZone.hxx52
-rw-r--r--include/opencl/openclwrapper.hxx4
2 files changed, 55 insertions, 1 deletions
diff --git a/include/opencl/OpenCLZone.hxx b/include/opencl/OpenCLZone.hxx
new file mode 100644
index 000000000000..1fbc666f4df0
--- /dev/null
+++ b/include/opencl/OpenCLZone.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_OPENCL_INC_OPENCL_ZONE_HXX
+#define INCLUDED_OPENCL_INC_OPENCL_ZONE_HXX
+
+#include <opencl/opencldllapi.h>
+
+// FIXME: post back-port, templatize me and share with OpenGLZone.
+class OPENCL_DLLPUBLIC OpenCLZone
+{
+ /// how many times have we entered a CL zone
+ static volatile sal_uInt64 gnEnterCount;
+ /// how many times have we left a new CL zone
+ static volatile sal_uInt64 gnLeaveCount;
+
+ static void enter()
+ {
+ gnEnterCount++;
+ }
+ static void leave()
+ {
+ gnLeaveCount--;
+ }
+public:
+ OpenCLZone()
+ {
+ gnEnterCount++;
+ }
+
+ ~OpenCLZone()
+ {
+ gnLeaveCount++;
+ }
+
+ static bool isInZone()
+ {
+ return gnEnterCount != gnLeaveCount;
+ }
+
+ static void hardDisable();
+};
+
+#endif // INCLUDED_OPENCL_INC_OPENCL_ZONE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/opencl/openclwrapper.hxx b/include/opencl/openclwrapper.hxx
index b83c1fc2ff00..b173d89ba2f3 100644
--- a/include/opencl/openclwrapper.hxx
+++ b/include/opencl/openclwrapper.hxx
@@ -64,11 +64,13 @@ OPENCL_DLLPUBLIC const std::vector<OpenCLPlatformInfo>& fillOpenCLInfo();
*
* @param pDeviceId the id of the opencl device of type cl_device_id, NULL means use software calculation
* @param bAutoSelect use the algorithm to select the best OpenCL device
+ * @param rOutSelectedDeviceVersionIDString returns the selected device's version string.
*
* @return returns true if there is a valid opencl device that has been set up
*/
OPENCL_DLLPUBLIC bool switchOpenCLDevice(const OUString* pDeviceId, bool bAutoSelect,
- bool bForceEvaluation);
+ bool bForceEvaluation,
+ OUString& rOutSelectedDeviceVersionIDString);
OPENCL_DLLPUBLIC void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId);