/* -*- 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/.
*/
// device type enumclass DeviceType
{
None, // NativeCPU means the traditional Calc interpreter code path. (That also includes the so-called // "software interpreter", but note that it definitely does not mean *exclusively* that.)
NativeCPU, // OpenCLDevice means an OpenCL device as supplied by an OpenCL platform, which might well be // implemented using code that runs on the CPU (and not a GPU). On Windows, OpenCL platforms // typically provide two devices, one for the GPU and one for the CPU.
OpenCLDevice
};
numDevices = 0; for (i = 0; i < static_cast<unsignedint>(numPlatforms); i++)
{
cl_uint num = 0;
cl_int err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, nullptr, &num); if (err != CL_SUCCESS)
{ /* we want to catch at least the case when the call returns * CL_DEVICE_NOT_FOUND (i.e. no devices), because some platforms * don't set num to 0 in this case; but in fact this is a good * thing to do for _any_ error returned by the call
*/
num = 0;
}
numDevices += num;
}
if (numDevices != 0)
{
devices.resize(numDevices);
}
rProfile->devices.resize(numDevices + 1); // +1 to numDevices to include the native CPU
next = 0; for (i = 0; i < static_cast<unsignedint>(numPlatforms); i++)
{
cl_uint num = 0; unsigned j;
cl_int err = clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, numDevices, devices.data(), &num); if (err != CL_SUCCESS)
{ /* we want to catch at least the case when the call returns * CL_DEVICE_NOT_FOUND (i.e. no devices), because some platforms * don't set num to 0 in this case; but in fact this is a good * thing to do for _any_ error returned by the call
*/
num = 0;
} for (j = 0; j < num; j++, next++)
{
cl_device_id aDeviceID = devices[j];
for (ds_device& rDevice : pProfile->devices)
{ // type matches? either both are DS_DEVICE_OPENCL_DEVICE or DS_DEVICE_NATIVE_CPU if (rDevice.eType == eDeviceType)
{ // is DS_DEVICE_NATIVE_CPU or name + version matches? if (eDeviceType == DeviceType::NativeCPU ||
(sName == rDevice.sDeviceName &&
sVersion == rDevice.sDriverVersion))
{
rDevice.fTime = fTime;
rDevice.bErrors = bErrors;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.