diff options
-rwxr-xr-x | offapi/UnoApi_offapi.mk | 2 | ||||
-rw-r--r-- | offapi/com/sun/star/sheet/opencl/OpenCLDevice.idl | 37 | ||||
-rw-r--r-- | offapi/com/sun/star/sheet/opencl/OpenCLPlatform.idl | 33 | ||||
-rw-r--r-- | offapi/com/sun/star/sheet/opencl/XOpenCLSelection.idl | 7 | ||||
-rw-r--r-- | sc/inc/docuno.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/opencl/openclwrapper.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 29 |
8 files changed, 117 insertions, 2 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index e7c52f2e63f2..a1ad8314aa62 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 000000000000..7cf795f97d02 --- /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 000000000000..bb8a683b8e71 --- /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 c6e18cf30e27..26ab32885ac7 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 a3b7680f7142..1228afe10a47 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 24459c627780..54d997db4cce 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 372e8fca1cc3..c2258205fe1c 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 c1671c6389e2..b78f8b8dd1fe 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; +} + //------------------------------------------------------------------------ |