Kaydet (Commit) 4e736a8b authored tarafından Markus Mohrhard's avatar Markus Mohrhard

add API to retrieve all available OpenCL platforms and devices

Change-Id: I2475961ae315ee7193ca2cedd5943b663bfee7a0
üst 6c711025
......@@ -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 \
))
......
/* -*- 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: */
/* -*- 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: */
......@@ -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();
};
}; }; }; }; };
......
......@@ -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);
};
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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;
}
//------------------------------------------------------------------------
......
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