summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-09-16 13:52:51 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-09-19 17:03:19 +0200
commitb5e03516299c5aa47966729c928cd42296795085 (patch)
treec5010ded934ebb5a0614b8b7909a731ac364a7f2
parent5cc6c3fd4fd4610d26576841bcd694bf2f8231a4 (diff)
store the opencl device id and propagate it from the ui to opencl code
Change-Id: I47ed4add16c804e598feebd84ae823a45d2f8dd9
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Calc.xcs7
-rw-r--r--sc/inc/calcconfig.hxx3
-rw-r--r--sc/source/core/opencl/openclwrapper.cxx18
-rw-r--r--sc/source/core/tool/calcconfig.cxx3
-rw-r--r--sc/source/core/tool/formulagroup.cxx2
-rw-r--r--sc/source/core/tool/formulaopt.cxx24
-rw-r--r--sc/source/ui/app/scmod.cxx3
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx1
8 files changed, 53 insertions, 8 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 5950597cd73b..25fe724d2832 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1344,6 +1344,13 @@
</info>
<value>true</value>
</prop>
+ <prop oor:name="OpenCLAutoDevice" oor:type="xs:string" oor:nillable="false">
+ <!-- UIHints: Tools - Options Spreadsheet Formula -->
+ <info>
+ <desc>The Device ID of the OpenCL device selected if OpenCLAutoSelect is false</desc>
+ </info>
+ <value></value>
+ </prop>
</group>
<group oor:name="Syntax">
<info>
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 14778744279d..94a72cc8b6a9 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -13,6 +13,8 @@
#include "scdllapi.h"
#include "formula/grammar.hxx"
+#include "rtl/ustring.hxx"
+
// have to match the registry values
enum ScRecalcOptions
{
@@ -30,6 +32,7 @@ struct SC_DLLPUBLIC ScCalcConfig
bool mbEmptyStringAsZero:1;
bool mbOpenCLEnabled:1;
bool mbOpenCLAutoSelect:1;
+ OUString maOpenCLDevice;
ScCalcConfig();
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index 72d1ab3dfc6d..ea2d754f493f 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -2773,6 +2773,20 @@ namespace {
cl_device_id findDeviceIdByDeviceString(const OUString& rString, const std::vector<OpenclPlatformInfo>& rPlatforms)
{
+ std::vector<OpenclPlatformInfo>::const_iterator it = rPlatforms.begin(), itEnd = rPlatforms.end();
+ for(; it != itEnd; ++it)
+ {
+ std::vector<OpenclDeviceInfo>::const_iterator itr = it->maDevices.begin(), itrEnd = it->maDevices.end();
+ for(; itr != itrEnd; ++itr)
+ {
+ OUString aDeviceId = it->maVendor + " " + itr->maName;
+ if(rString == aDeviceId)
+ {
+ return static_cast<cl_device_id>(itr->device);
+ }
+ }
+ }
+
return NULL;
}
@@ -2851,6 +2865,10 @@ bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect)
env.mpOclDevsID = pDeviceId;
env.mpOclCmdQueue = command_queue;
OpenclDevice::initOpenclAttr(&env);
+
+ // why do we need this at all?
+ OpenclDevice::gpuEnv.mpArryDevsID = (cl_device_id*) malloc( 1 );
+ OpenclDevice::gpuEnv.mpArryDevsID[0] = pDeviceId;
return !OpenclDevice::initOpenclRunEnv(0);
}
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 12784028d3dc..f910bb151a87 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -27,7 +27,8 @@ bool ScCalcConfig::operator== (const ScCalcConfig& r) const
return meStringRefAddressSyntax == r.meStringRefAddressSyntax &&
mbEmptyStringAsZero == r.mbEmptyStringAsZero &&
mbOpenCLEnabled == r.mbOpenCLEnabled &&
- mbOpenCLAutoSelect == r.mbOpenCLAutoSelect;
+ mbOpenCLAutoSelect == r.mbOpenCLAutoSelect &&
+ maOpenCLDevice == r.maOpenCLDevice;
}
bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 9b3ab9a20df5..dd765a8eb235 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -427,7 +427,7 @@ void FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
if (!pModule)
return;
- oslGenericFunction fn = pModule->getFunctionSymbol("switchOpenclDevice");
+ oslGenericFunction fn = pModule->getFunctionSymbol("switchOpenClDevice");
if (!fn)
return;
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index bf6b385fbd0d..4c926e96f792 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -15,6 +15,7 @@
#include "formulaopt.hxx"
#include "miscuno.hxx"
#include "global.hxx"
+#include "formulagroup.hxx"
using namespace utl;
using namespace com::sun::star::uno;
@@ -197,7 +198,8 @@ SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
#define SCFORMULAOPT_ODF_RECALC 8
#define SCFORMULAOPT_OPENCL_ENABLED 9
#define SCFORMULAOPT_OPENCL_AUTOSELECT 10
-#define SCFORMULAOPT_COUNT 11
+#define SCFORMULAOPT_OPENCL_DEVICE 11
+#define SCFORMULAOPT_COUNT 12
Sequence<OUString> ScFormulaCfg::GetPropertyNames()
{
@@ -213,7 +215,8 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
"Load/OOXMLRecalcMode", // SCFORMULAOPT_OOXML_RECALC
"Load/ODFRecalcMode", // SCFORMULAOPT_ODF_RECALC
"Calculation/OpenCL", // SCFORMULAOPT_OPENCL_ENABLED
- "Calculation/OpenCLAutoSelect" // SCFORMULAOPT_OPENCL_AUTOSELECT
+ "Calculation/OpenCLAutoSelect", // SCFORMULAOPT_OPENCL_AUTOSELECT
+ "Calculation/OpenCLDevice" // SCFORMULAOPT_OPENCL_DEVICE
};
Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
OUString* pNames = aNames.getArray();
@@ -226,7 +229,7 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
ScFormulaCfg::PropsToIds ScFormulaCfg::GetPropNamesToId()
{
Sequence<OUString> aPropNames = GetPropertyNames();
- static sal_uInt16 aVals[] = { SCFORMULAOPT_GRAMMAR, SCFORMULAOPT_ENGLISH_FUNCNAME, SCFORMULAOPT_SEP_ARG, SCFORMULAOPT_SEP_ARRAY_ROW, SCFORMULAOPT_SEP_ARRAY_COL, SCFORMULAOPT_STRING_REF_SYNTAX, SCFORMULAOPT_EMPTY_STRING_AS_ZERO, SCFORMULAOPT_OOXML_RECALC, SCFORMULAOPT_ODF_RECALC, SCFORMULAOPT_OPENCL_ENABLED, SCFORMULAOPT_OPENCL_AUTOSELECT };
+ static sal_uInt16 aVals[] = { SCFORMULAOPT_GRAMMAR, SCFORMULAOPT_ENGLISH_FUNCNAME, SCFORMULAOPT_SEP_ARG, SCFORMULAOPT_SEP_ARRAY_ROW, SCFORMULAOPT_SEP_ARRAY_COL, SCFORMULAOPT_STRING_REF_SYNTAX, SCFORMULAOPT_EMPTY_STRING_AS_ZERO, SCFORMULAOPT_OOXML_RECALC, SCFORMULAOPT_ODF_RECALC, SCFORMULAOPT_OPENCL_ENABLED, SCFORMULAOPT_OPENCL_AUTOSELECT, SCFORMULAOPT_OPENCL_DEVICE };
OSL_ENSURE( SAL_N_ELEMENTS(aVals) == aPropNames.getLength(), "Properties and ids are out of Sync");
PropsToIds aPropIdMap;
for ( sal_uInt16 i=0; i<aPropNames.getLength(); ++i )
@@ -418,6 +421,13 @@ void ScFormulaCfg::UpdateFromProperties( const Sequence<OUString>& aNames )
pValues[nProp] >>= bVal;
GetCalcConfig().mbOpenCLAutoSelect = bVal;
}
+ break;
+ case SCFORMULAOPT_OPENCL_DEVICE:
+ {
+ OUString aOpenCLDevice = GetCalcConfig().maOpenCLDevice;
+ pValues[nProp] >>= aOpenCLDevice;
+ GetCalcConfig().maOpenCLDevice = aOpenCLDevice;
+ }
default:
;
}
@@ -532,6 +542,14 @@ void ScFormulaCfg::Commit()
pValues[nProp] <<= bVal;
}
break;
+ case SCFORMULAOPT_OPENCL_DEVICE:
+ {
+ OUString aOpenCLDevice = GetCalcConfig().maOpenCLDevice;
+ pValues[nProp] <<= aOpenCLDevice;
+ sc::FormulaGroupInterpreter::switchOpenCLDevice(
+ aOpenCLDevice, GetCalcConfig().mbOpenCLAutoSelect);
+ }
+ break;
default:
;
}
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 2fe4540a2469..00a974818441 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -179,9 +179,6 @@ ScModule::ScModule( SfxObjectFactory* pFact ) :
ScGlobal::InitTextHeight( pMessagePool );
StartListening( *SFX_APP() ); // for SFX_HINT_DEINITIALIZING
-
- // initialize formula grouping
- sc::FormulaGroupInterpreter::getStatic();
}
ScModule::~ScModule()
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 652090b36cb4..6dd78fea9214 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -371,6 +371,7 @@ void ScCalcOptionsDialog::SelectedDeviceChanged()
mpFtFrequency->SetText(OUString::number(pInfo->mnFrequency));
mpFtComputeUnits->SetText(OUString::number(pInfo->mnComputeUnits));
mpFtMemory->SetText(OUString::number(pInfo->mnMemory/1024/1024));
+ maConfig.maOpenCLDevice = dynamic_cast<SvLBoxString*>(pEntry->GetItem(1))->GetText();
#endif
}