Kaydet (Commit) e0d936ef authored tarafından Kohei Yoshida's avatar Kohei Yoshida

More code that's specific to OpenCL kernel pre-compilation.

Change-Id: I82474c48924aca36d9fde468081fb2457a153ac6
üst 1c2781df
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "formularesult.hxx" #include "formularesult.hxx"
#define ENABLE_THREADED_OPENCL_KERNEL_COMPILATION 0
namespace sc { namespace sc {
class CLBuildKernelThread; class CLBuildKernelThread;
...@@ -78,8 +80,10 @@ struct SC_DLLPUBLIC ScFormulaCellGroup : boost::noncopyable ...@@ -78,8 +80,10 @@ struct SC_DLLPUBLIC ScFormulaCellGroup : boost::noncopyable
ScDocument& rDoc, const ScAddress& rPos, formula::FormulaGrammar::Grammar eGram ); ScDocument& rDoc, const ScAddress& rPos, formula::FormulaGrammar::Grammar eGram );
void compileOpenCLKernel(); void compileOpenCLKernel();
#if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION
static int snCount; static int snCount;
static rtl::Reference<sc::CLBuildKernelThread> sxCompilationThread; static rtl::Reference<sc::CLBuildKernelThread> sxCompilationThread;
#endif
}; };
inline void intrusive_ptr_add_ref(const ScFormulaCellGroup *p) inline void intrusive_ptr_add_ref(const ScFormulaCellGroup *p)
......
...@@ -59,8 +59,6 @@ ...@@ -59,8 +59,6 @@
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#define ENABLE_THREADED_OPENCL_KERNEL_COMPILATION 0
using namespace formula; using namespace formula;
#ifdef USE_MEMPOOL #ifdef USE_MEMPOOL
...@@ -392,6 +390,7 @@ void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldD ...@@ -392,6 +390,7 @@ void adjustDBRange(ScToken* pToken, ScDocument& rNewDoc, const ScDocument* pOldD
} }
#if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION
// The mutex to synchronize access to the OpenCL compilation thread. // The mutex to synchronize access to the OpenCL compilation thread.
static osl::Mutex& getOpenCLCompilationThreadMutex() static osl::Mutex& getOpenCLCompilationThreadMutex()
{ {
...@@ -411,6 +410,7 @@ static osl::Mutex& getOpenCLCompilationThreadMutex() ...@@ -411,6 +410,7 @@ static osl::Mutex& getOpenCLCompilationThreadMutex()
int ScFormulaCellGroup::snCount = 0; int ScFormulaCellGroup::snCount = 0;
rtl::Reference<sc::CLBuildKernelThread> ScFormulaCellGroup::sxCompilationThread; rtl::Reference<sc::CLBuildKernelThread> ScFormulaCellGroup::sxCompilationThread;
#endif
ScFormulaCellGroup::ScFormulaCellGroup() : ScFormulaCellGroup::ScFormulaCellGroup() :
mnRefCount(0), mnRefCount(0),
...@@ -424,6 +424,7 @@ ScFormulaCellGroup::ScFormulaCellGroup() : ...@@ -424,6 +424,7 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
meCalcState(sc::GroupCalcEnabled), meCalcState(sc::GroupCalcEnabled),
meKernelState(sc::OpenCLKernelNone) meKernelState(sc::OpenCLKernelNone)
{ {
#if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION
if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
{ {
osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex()); osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
...@@ -434,10 +435,12 @@ ScFormulaCellGroup::ScFormulaCellGroup() : ...@@ -434,10 +435,12 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
sxCompilationThread->launch(); sxCompilationThread->launch();
} }
} }
#endif
} }
ScFormulaCellGroup::~ScFormulaCellGroup() ScFormulaCellGroup::~ScFormulaCellGroup()
{ {
#if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION
if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
{ {
osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex()); osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
...@@ -450,17 +453,20 @@ ScFormulaCellGroup::~ScFormulaCellGroup() ...@@ -450,17 +453,20 @@ ScFormulaCellGroup::~ScFormulaCellGroup()
sxCompilationThread.clear(); sxCompilationThread.clear();
} }
} }
#endif
delete mpCode; delete mpCode;
delete mpCompiledFormula; delete mpCompiledFormula;
} }
void ScFormulaCellGroup::scheduleCompilation() void ScFormulaCellGroup::scheduleCompilation()
{ {
#if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION
meKernelState = sc::OpenCLKernelCompilationScheduled; meKernelState = sc::OpenCLKernelCompilationScheduled;
sc::CLBuildKernelWorkItem aWorkItem; sc::CLBuildKernelWorkItem aWorkItem;
aWorkItem.meWhatToDo = sc::CLBuildKernelWorkItem::COMPILE; aWorkItem.meWhatToDo = sc::CLBuildKernelWorkItem::COMPILE;
aWorkItem.mxGroup = this; aWorkItem.mxGroup = this;
sxCompilationThread->push(aWorkItem); sxCompilationThread->push(aWorkItem);
#endif
} }
void ScFormulaCellGroup::setCode( const ScTokenArray& rCode ) void ScFormulaCellGroup::setCode( const ScTokenArray& rCode )
......
...@@ -3450,6 +3450,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, ...@@ -3450,6 +3450,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
DynamicKernel *pKernel = NULL; DynamicKernel *pKernel = NULL;
boost::scoped_ptr<DynamicKernel> pLocalKernel; boost::scoped_ptr<DynamicKernel> pLocalKernel;
#if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION
if (xGroup->meKernelState == sc::OpenCLKernelCompilationScheduled || if (xGroup->meKernelState == sc::OpenCLKernelCompilationScheduled ||
xGroup->meKernelState == sc::OpenCLKernelBinaryCreated) xGroup->meKernelState == sc::OpenCLKernelBinaryCreated)
{ {
...@@ -3467,6 +3468,10 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, ...@@ -3467,6 +3468,10 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
pKernel = static_cast<DynamicKernel*>(createCompiledFormula(rDoc, rTopPos, *xGroup, rCode)); pKernel = static_cast<DynamicKernel*>(createCompiledFormula(rDoc, rTopPos, *xGroup, rCode));
pLocalKernel.reset(pKernel); // to be deleted when done. pLocalKernel.reset(pKernel); // to be deleted when done.
} }
#else
pKernel = static_cast<DynamicKernel*>(createCompiledFormula(rDoc, rTopPos, *xGroup, rCode));
pLocalKernel.reset(pKernel); // to be deleted when done.
#endif
if (!pKernel) if (!pKernel)
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment