[Libreoffice-commits] core.git: 2 commits - offapi/com offapi/UnoApi_offapi.mk sc/inc sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Mon Nov 25 11:44:14 PST 2013
offapi/UnoApi_offapi.mk | 7 +
offapi/com/sun/star/sheet/opencl/OpenCLDevice.idl | 37 +++++++
offapi/com/sun/star/sheet/opencl/OpenCLPlatform.idl | 33 ++++++
offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl | 52 +++++++++++
sc/inc/docuno.hxx | 25 +++++
sc/inc/formulagroup.hxx | 1
sc/source/core/opencl/formulagroupcl.cxx | 5 +
sc/source/core/opencl/openclwrapper.cxx | 39 ++++++++
sc/source/core/opencl/openclwrapper.hxx | 2
sc/source/core/tool/formulagroup.cxx | 33 ++++++
sc/source/ui/unoobj/docuno.cxx | 85 +++++++++++++++++-
11 files changed, 317 insertions(+), 2 deletions(-)
New commits:
commit 4e736a8b8ce4d69c5be924b77bb07bd19b1e4d73
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Nov 23 20:02:26 2013 +0100
add API to retrieve all available OpenCL platforms and devices
Change-Id: I2475961ae315ee7193ca2cedd5943b663bfee7a0
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index e7c52f2..a1ad831 100755
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -3327,6 +3327,8 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/security,\
))
$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet/opencl,\
+ OpenCLDevice \
+ OpenCLPlatform \
XOpenCLSelection \
))
diff --git a/offapi/com/sun/star/sheet/opencl/OpenCLDevice.idl b/offapi/com/sun/star/sheet/opencl/OpenCLDevice.idl
new file mode 100644
index 0000000..7cf795f
--- /dev/null
+++ b/offapi/com/sun/star/sheet/opencl/OpenCLDevice.idl
@@ -0,0 +1,37 @@
+/* -*- 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 __com_sun_star_sheet_opencl_OpenCLDevice_idl__
+#define __com_sun_star_sheet_opencl_OpenCLDevice_idl__
+
+module com { module sun { module star { module sheet { module opencl {
+
+struct OpenCLDevice
+{
+ /**
+ * The name of the device as returned by OpenCL
+ */
+ string Name;
+
+ /**
+ * The vendor of the device as returned by OpenCL
+ */
+ string Vendor;
+
+ /**
+ * The driver version as returned by OpenCL
+ */
+ string Driver;
+};
+
+}; }; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/sheet/opencl/OpenCLPlatform.idl b/offapi/com/sun/star/sheet/opencl/OpenCLPlatform.idl
new file mode 100644
index 0000000..bb8a683
--- /dev/null
+++ b/offapi/com/sun/star/sheet/opencl/OpenCLPlatform.idl
@@ -0,0 +1,33 @@
+/* -*- 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 __com_sun_star_sheet_opencl_OpenCLPlatform_idl__
+#define __com_sun_star_sheet_opencl_OpenCLPlatform_idl__
+
+#include <com/sun/star/sheet/opencl/OpenCLDevice.idl>
+
+module com { module sun { module star { module sheet { module opencl {
+
+struct OpenCLPlatform
+{
+ /**
+ * The name of the platform as returned by OpenCL
+ */
+ string Name;
+
+ string Vendor;
+
+ sequence< OpenCLDevice > Devices;
+};
+
+}; }; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl b/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
index c6e18cf..26ab328 100644
--- a/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
+++ b/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
@@ -7,6 +7,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <com/sun/star/sheet/opencl/OpenCLPlatform.idl>
+
module com { module sun { module star { module sheet { module opencl {
interface XOpenCLSelection : com::sun::star::uno::XInterface
@@ -38,6 +40,11 @@ interface XOpenCLSelection : com::sun::star::uno::XInterface
*/
long getDeviceID();
+ /**
+ * lists all OpenCL devices and platforms
+ */
+ sequence< OpenCLPlatform > getOpenCLPlatforms();
+
};
}; }; }; }; };
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index a3b7680..1228afe 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -46,6 +46,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XCellRangesAccess.hpp>
#include <com/sun/star/sheet/opencl/XOpenCLSelection.hpp>
+#include <com/sun/star/sheet/opencl/OpenCLPlatform.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
@@ -333,6 +334,10 @@ public:
virtual sal_Int32 SAL_CALL getDeviceID()
throw(::com::sun::star::uno::RuntimeException);
+
+ virtual com::sun::star::uno::Sequence< com::sun::star::sheet::opencl::OpenCLPlatform >
+ SAL_CALL getOpenCLPlatforms()
+ throw(::com::sun::star::uno::RuntimeException);
};
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index 24459c6..54d997d 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -997,6 +997,10 @@ bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect)
void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId)
{
+ int status = clewInit(OPENCL_DLL_NAME);
+ if (status < 0)
+ return;
+
cl_device_id id = OpenclDevice::gpuEnv.mpDevID;
findDeviceInfoFromDeviceId(id, rDeviceId, rPlatformId);
}
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 372e8fc..c225820 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -660,7 +660,7 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3
rDeviceId = -1;
rPlatformId = -1;
bool bOpenCLEnabled = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled;
- if(bOpenCLEnabled)
+ if(!bOpenCLEnabled)
return;
#if HAVE_FEATURE_OPENCL
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index c1671c6..b78f8b8 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -477,6 +477,7 @@ uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
SC_QUERYINTERFACE( lang::XMultiServiceFactory )
SC_QUERYINTERFACE( lang::XServiceInfo )
SC_QUERYINTERFACE( util::XChangesNotifier )
+ SC_QUERYINTERFACE( sheet::opencl::XOpenCLSelection )
uno::Any aRet(SfxBaseModel::queryInterface( rType ));
if ( !aRet.hasValue()
@@ -529,7 +530,7 @@ uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeExcep
long nAggLen = aAggTypes.getLength();
const uno::Type* pAggPtr = aAggTypes.getConstArray();
- const long nThisLen = 15;
+ const long nThisLen = 16;
aTypes.realloc( nParentLen + nAggLen + nThisLen );
uno::Type* pPtr = aTypes.getArray();
pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetDocument>*)0);
@@ -547,6 +548,7 @@ uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeExcep
pPtr[nParentLen +12] = getCppuType((const uno::Reference<lang::XMultiServiceFactory>*)0);
pPtr[nParentLen +13] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XChangesNotifier>*)0);
+ pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::opencl::XOpenCLSelection>*)0);
long i;
for (i=0; i<nParentLen; i++)
@@ -2341,6 +2343,31 @@ sal_Int32 ScModelObj::getDeviceID()
return nDeviceId;
}
+uno::Sequence< sheet::opencl::OpenCLPlatform > ScModelObj::getOpenCLPlatforms()
+ throw (uno::RuntimeException)
+{
+ std::vector<sc::OpenclPlatformInfo> aPlatformInfo;
+ sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
+
+ uno::Sequence<sheet::opencl::OpenCLPlatform> aRet(aPlatformInfo.size());
+ for(size_t i = 0; i < aPlatformInfo.size(); ++i)
+ {
+ aRet[i].Name = aPlatformInfo[i].maName;
+ aRet[i].Vendor = aPlatformInfo[i].maVendor;
+
+ aRet[i].Devices.realloc(aPlatformInfo[i].maDevices.size());
+ for(size_t j = 0; j < aPlatformInfo[i].maDevices.size(); ++j)
+ {
+ const sc::OpenclDeviceInfo& rDevice = aPlatformInfo[i].maDevices[j];
+ aRet[i].Devices[j].Name = rDevice.maName;
+ aRet[i].Devices[j].Vendor = rDevice.maVendor;
+ aRet[i].Devices[j].Driver = rDevice.maDriver;
+ }
+ }
+
+ return aRet;
+}
+
//------------------------------------------------------------------------
commit 6c71102545beccd0a4f8ec8ee7123d3c63e1b09d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Nov 22 20:27:48 2013 +0100
provide UNO API for OpenCL selection
Change-Id: If5eb71e9298cefdac3dda98cb1ff67fe913ad3c3
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index f75da685..e7c52f2 100755
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -3325,6 +3325,11 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/security,\
XSanExtension \
XSerialNumberAdapter \
))
+
+$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet/opencl,\
+ XOpenCLSelection \
+))
+
$(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet,\
ActivationEvent \
AddressConvention \
diff --git a/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl b/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
new file mode 100644
index 0000000..c6e18cf
--- /dev/null
+++ b/offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl
@@ -0,0 +1,45 @@
+/* -*- 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/.
+ */
+
+module com { module sun { module star { module sheet { module opencl {
+
+interface XOpenCLSelection : com::sun::star::uno::XInterface
+{
+
+ /**
+ * Returns true if calculation with OpenCL is enabled
+ */
+ boolean isOpenCLEnabled();
+
+ /**
+ * Enables or disables OpenCL
+ */
+ void enableOpenCL( [in] boolean enable );
+
+ /**
+ * Set the OpenCL device with the platform ID and device ID
+ * Uses the ID of the platform and the device
+ */
+ void selectOpenCLDevice( [in] long platform, [in] long device );
+
+ /**
+ * returns the platform id of the currently selected device
+ */
+ long getPlatformID();
+
+ /**
+ * returns the device id of the currently selected device
+ */
+ long getDeviceID();
+
+};
+
+}; }; }; }; };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 9be1ee2..a3b7680 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -45,6 +45,7 @@
#include <com/sun/star/sheet/XSheetAnnotations.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XCellRangesAccess.hpp>
+#include <com/sun/star/sheet/opencl/XOpenCLSelection.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
@@ -81,7 +82,8 @@ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
public com::sun::star::beans::XPropertySet,
public SvxFmMSFactory, ///< derived from XMultiServiceFactory
public com::sun::star::lang::XServiceInfo,
- public ::com::sun::star::util::XChangesNotifier
+ public ::com::sun::star::util::XChangesNotifier,
+ public com::sun::star::sheet::opencl::XOpenCLSelection
{
private:
SfxItemPropertySet aPropSet;
@@ -315,6 +317,22 @@ public:
virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference<
::com::sun::star::util::XChangesListener >& aListener )
throw (::com::sun::star::uno::RuntimeException);
+
+ // XOpenCLSelection
+ virtual sal_Bool SAL_CALL isOpenCLEnabled()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL enableOpenCL(sal_Bool bEnable)
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL selectOpenCLDevice( sal_Int32 platform, sal_Int32 device )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getPlatformID()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getDeviceID()
+ throw(::com::sun::star::uno::RuntimeException);
};
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 9f8d09c..17f00d1 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -97,6 +97,7 @@ class SC_DLLPUBLIC FormulaGroupInterpreter
static void fillOpenCLInfo(std::vector<OpenclPlatformInfo>& rPlatforms);
static bool switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect);
static void enableOpenCL(bool bEnable);
+ static void getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId);
virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0;
virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc,
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index bee159b..8e4c5be 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2894,6 +2894,11 @@ SAL_DLLPUBLIC_EXPORT bool SAL_CALL switchOpenClDevice(
return sc::opencl::switchOpenclDevice(pDeviceId, bAutoSelect);
}
+SAL_DLLPUBLIC_EXPORT void SAL_CALL getOpenCLDeviceInfo(size_t* pDeviceId, size_t* pPlatformId)
+{
+ sc::opencl::getOpenCLDeviceInfo(*pDeviceId, *pPlatformId);
+}
+
} // extern "C"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index 8127b74..24459c6 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -889,6 +889,35 @@ cl_device_id findDeviceIdByDeviceString(const OUString& rString, const std::vect
return NULL;
}
+void findDeviceInfoFromDeviceId(cl_device_id aDeviceId, size_t& rDeviceId, size_t& rPlatformId)
+{
+ cl_platform_id platformId;
+ cl_int nState = clGetDeviceInfo(aDeviceId, CL_DEVICE_PLATFORM,
+ sizeof(platformId), &platformId, NULL);
+
+ if(nState != CL_SUCCESS)
+ return;
+
+ const std::vector<OpenclPlatformInfo>& rPlatforms = fillOpenCLInfo();
+ for(size_t i = 0; i < rPlatforms.size(); ++i)
+ {
+ cl_platform_id platId = static_cast<cl_platform_id>(rPlatforms[i].platform);
+ if(platId != platformId)
+ continue;
+
+ for(size_t j = 0; j < rPlatforms[i].maDevices.size(); ++j)
+ {
+ cl_device_id id = static_cast<cl_device_id>(rPlatforms[i].maDevices[j].device);
+ if(id == aDeviceId)
+ {
+ rDeviceId = j;
+ rPlatformId = i;
+ return;
+ }
+ }
+ }
+}
+
}
bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect)
@@ -966,6 +995,12 @@ bool switchOpenclDevice(const OUString* pDevice, bool bAutoSelect)
return !OpenclDevice::initOpenclRunEnv(0);
}
+void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId)
+{
+ cl_device_id id = OpenclDevice::gpuEnv.mpDevID;
+ findDeviceInfoFromDeviceId(id, rDeviceId, rPlatformId);
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/openclwrapper.hxx b/sc/source/core/opencl/openclwrapper.hxx
index 0dfe24c..073ce1a 100644
--- a/sc/source/core/opencl/openclwrapper.hxx
+++ b/sc/source/core/opencl/openclwrapper.hxx
@@ -185,6 +185,8 @@ const std::vector<OpenclPlatformInfo>& fillOpenCLInfo();
*/
bool switchOpenclDevice(const OUString* pDeviceId, bool bAutoSelect);
+void getOpenCLDeviceInfo(size_t& rDeviceId, size_t& rPlatformId);
+
}}
#endif
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index f3ec3e0..372e8fc 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -33,6 +33,7 @@ extern "C" size_t getOpenCLPlatformCount(void);
extern "C" void fillOpenCLInfo(sc::OpenclPlatformInfo*, size_t);
extern "C" bool switchOpenClDevice(const OUString*, bool);
extern "C" sc::FormulaGroupInterpreter* createFormulaGroupOpenCLInterpreter();
+extern "C" void getOpenCLDeviceInfo(size_t*, size_t*);
#endif
@@ -504,6 +505,7 @@ typedef FormulaGroupInterpreter* (*__createFormulaGroupOpenCLInterpreter)(void);
typedef size_t (*__getOpenCLPlatformCount)(void);
typedef void (*__fillOpenCLInfo)(OpenclPlatformInfo*, size_t);
typedef bool (*__switchOpenClDevice)(const OUString*, bool);
+typedef void (*__getOpenCLDeviceInfo)(size_t*, size_t*);
#endif
@@ -653,6 +655,37 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
return false;
}
+void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int32& rPlatformId)
+{
+ rDeviceId = -1;
+ rPlatformId = -1;
+ bool bOpenCLEnabled = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled;
+ if(bOpenCLEnabled)
+ return;
+
+#if HAVE_FEATURE_OPENCL
+
+ size_t aDeviceId = -1;
+ size_t aPlatformId = -1;
+
+#ifndef DISABLE_DYNLOADING
+ osl::Module* pModule = getOpenCLModule();
+ if (!pModule)
+ return;
+
+ oslGenericFunction fn = pModule->getFunctionSymbol("getOpenCLDeviceInfo");
+ if (!fn)
+ return;
+
+ reinterpret_cast<__getOpenCLDeviceInfo>(fn)(&aDeviceId, &aPlatformId);
+#else
+ getOpenCLDeviceInfo(&aDeviceId, &aPlatformId);
+#endif
+ rDeviceId = aDeviceId;
+ rPlatformId = aPlatformId;
+#endif
+}
+
void FormulaGroupInterpreter::enableOpenCL(bool bEnable)
{
ScCalcConfig aConfig = ScInterpreter::GetGlobalConfig();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index a1312aa..c1671c6 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -92,6 +92,9 @@
#include "sheetevents.hxx"
#include "sc.hrc"
#include "scresid.hxx"
+#include "platforminfo.hxx"
+#include "interpre.hxx"
+#include "formulagroup.hxx"
using namespace com::sun::star;
@@ -2286,6 +2289,59 @@ void ScModelObj::HandleCalculateEvents()
}
}
+// XOpenCLSelection
+
+sal_Bool ScModelObj::isOpenCLEnabled()
+ throw (uno::RuntimeException)
+{
+ return ScInterpreter::GetGlobalConfig().mbOpenCLEnabled;
+}
+
+void ScModelObj::enableOpenCL(sal_Bool bEnable)
+ throw (uno::RuntimeException)
+{
+ ScCalcConfig aConfig = ScInterpreter::GetGlobalConfig();
+ aConfig.mbOpenCLEnabled = bEnable;
+ ScInterpreter::SetGlobalConfig(aConfig);
+}
+
+void ScModelObj::selectOpenCLDevice( sal_Int32 nPlatform, sal_Int32 nDevice )
+ throw (uno::RuntimeException)
+{
+ if(nPlatform < 0 || nDevice < 0)
+ throw uno::RuntimeException();
+
+ std::vector<sc::OpenclPlatformInfo> aPlatformInfo;
+ sc::FormulaGroupInterpreter::fillOpenCLInfo(aPlatformInfo);
+ if(size_t(nPlatform) >= aPlatformInfo.size())
+ throw uno::RuntimeException();
+
+ if(size_t(nDevice) >= aPlatformInfo[nPlatform].maDevices.size())
+ throw uno::RuntimeException();
+
+ OUString aDeviceString = aPlatformInfo[nPlatform].maVendor + " " + aPlatformInfo[nPlatform].maDevices[nDevice].maName;
+ sc::FormulaGroupInterpreter::switchOpenCLDevice(aDeviceString, false);
+}
+
+sal_Int32 ScModelObj::getPlatformID()
+ throw (uno::RuntimeException)
+{
+ sal_Int32 nPlatformId;
+ sal_Int32 nDeviceId;
+ sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
+ return nPlatformId;
+}
+
+sal_Int32 ScModelObj::getDeviceID()
+ throw (uno::RuntimeException)
+{
+ sal_Int32 nPlatformId;
+ sal_Int32 nDeviceId;
+ sc::FormulaGroupInterpreter::getOpenCLDeviceInfo(nDeviceId, nPlatformId);
+ return nDeviceId;
+}
+
+
//------------------------------------------------------------------------
ScDrawPagesObj::ScDrawPagesObj(ScDocShell* pDocSh) :
More information about the Libreoffice-commits
mailing list