mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-23 15:39:03 +00:00
Add minimal required version functionality (#271)
This adds functionality to define minimal required version through the ADD_TEST* macros. Tests that don't meet the version requirement will be skipped. By default the minimal required version is set to 1.0, subsequent patches will set the appropriate version for each of the tests. Signed-off-by: Radek Szymanski <radek.szymanski@arm.com>
This commit is contained in:
committed by
Kévin Petit
parent
dcbf54aa91
commit
f60f3ef9b5
@@ -17,6 +17,9 @@
|
||||
#include "compat.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include "threadTesting.h"
|
||||
#include "errorHelpers.h"
|
||||
#include "kernelHelpers.h"
|
||||
@@ -703,11 +706,12 @@ test_status callSingleTestFunction( test_definition test, cl_device_id deviceToU
|
||||
log_info( "%s...\n", test.name );
|
||||
fflush( stdout );
|
||||
|
||||
error = check_opencl_version_with_testname(test.name, deviceToUse);
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_missing_feature( error, test.name );
|
||||
return TEST_SKIP;
|
||||
const Version device_version = get_device_cl_version(deviceToUse);
|
||||
if (test.min_version > device_version)
|
||||
{
|
||||
log_info("%s skipped (requires at least version %s, but the device reports version %s)\n",
|
||||
test.name, test.min_version.to_string().c_str(), device_version.to_string().c_str());
|
||||
return TEST_SKIP;
|
||||
}
|
||||
|
||||
error = check_functions_for_offline_compiler(test.name, deviceToUse);
|
||||
@@ -893,3 +897,29 @@ cl_device_id GetOpposingDevice( cl_device_id device )
|
||||
// Should never get here
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Version get_device_cl_version(cl_device_id device)
|
||||
{
|
||||
size_t str_size;
|
||||
cl_int err = clGetDeviceInfo(device, CL_DEVICE_VERSION, 0, NULL, &str_size);
|
||||
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||
|
||||
std::vector<char> str(str_size);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_VERSION, str_size, str.data(), NULL);
|
||||
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||
|
||||
if (strstr(str.data(), "OpenCL 1.0") != NULL)
|
||||
return Version(1, 0);
|
||||
else if (strstr(str.data(), "OpenCL 1.1") != NULL)
|
||||
return Version(1, 1);
|
||||
else if (strstr(str.data(), "OpenCL 1.2") != NULL)
|
||||
return Version(1, 2);
|
||||
else if (strstr(str.data(), "OpenCL 2.0") != NULL)
|
||||
return Version(2, 0);
|
||||
else if (strstr(str.data(), "OpenCL 2.1") != NULL)
|
||||
return Version(2, 1);
|
||||
else if (strstr(str.data(), "OpenCL 2.2") != NULL)
|
||||
return Version(2, 2);
|
||||
|
||||
throw std::runtime_error(std::string("Unknown OpenCL version: ") + str.data());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user