Initialize OpenCL device on the main thread when pre-compiling kernels.
Else it would cause extremely hard-to-debug random crashes when interpreting
formulas with OpenCL.
And let's re-enable kernel pre-compilation with this fix.
Change-Id: Ib104bfdc3f56a02c052c837eb4bf3ecc95d562e0
(cherry picked from commit 6e24c789572aba5b6ee95e894f6d778777b1df58)
Reviewed-on: https://gerrit.libreoffice.org/8498
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 9407fbd..aff135a 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -54,7 +54,7 @@
#include <boost/scoped_ptr.hpp>
#define ENABLE_THREADED_OPENCL_KERNEL_COMPILATION 0
#define ENABLE_THREADED_OPENCL_KERNEL_COMPILATION 1
using namespace formula;
diff --git a/sc/source/core/tool/clkernelthread.cxx b/sc/source/core/tool/clkernelthread.cxx
index ea3c7d0..6c5afc0 100644
--- a/sc/source/core/tool/clkernelthread.cxx
+++ b/sc/source/core/tool/clkernelthread.cxx
@@ -69,6 +69,11 @@ void CLBuildKernelThread::push(CLBuildKernelWorkItem item)
osl::MutexGuard guard(maQueueMutex);
maQueue.push(item);
maQueueCondition.set();
// This is only to ensure that the OpenCL parameters are initialized on
// the main thread before spawning a worker thread for kernel
// pre-compilation.
sc::FormulaGroupInterpreter::getStatic();
}
void CLBuildKernelThread::produce()