/* -*- 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/.
*/
// The purpose of this separate executable is to check whether OpenCL works // without crashing (asserting, etc.). Other checks can be done by LO core itself.
#define check(value, expected) \ do \
{ \ auto val = (value); \ if (val != (expected)) \
{ \
SAL_WARN("opencl", \ "OpenCL driver check failed: " << val << "(line " << __LINE__ << ")"); \ return; \
} \
} while (false); #define openclcheck(value) check(value, CL_SUCCESS)
staticvoid runTest(constchar* deviceName, constchar* devicePlatform)
{ int status = clewInit(OPENCL_DLL_NAME);
check(status, CLEW_SUCCESS);
// Find the given OpenCL device (in order to use the same one as LO core).
cl_uint numPlatforms;
openclcheck(clGetPlatformIDs(0, nullptr, &numPlatforms));
std::vector<cl_platform_id> platforms(numPlatforms);
openclcheck(clGetPlatformIDs(numPlatforms, platforms.data(), nullptr));
cl_platform_id platformId = nullptr; for (cl_uint i = 0; i < numPlatforms; ++i)
{ char platformName[64]; if (clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, 64, platformName, nullptr)
== CL_SUCCESS
&& strcmp(devicePlatform, platformName) == 0)
{
platformId = platforms[i]; break;
}
} if (platformId == nullptr)
{
SAL_WARN("opencl", "Device platform not found: " << devicePlatform);
assert(false); return;
}
int main(int argc, char* argv[])
{ if (argc != 3) return 1;
runTest(argv[1], argv[2]); // Always return exit code 0, LO itself can do error checking better, we just care // if this helper crashes or not. return 0;
}
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.