mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Fix code format errors
This commit is contained in:
committed by
Alastair Murray
parent
c85527cec7
commit
44a240367e
@@ -57,7 +57,7 @@ int gIsEmbedded = 0;
|
||||
int gIsOpenCL_C_1_0_Device = 0;
|
||||
int gIsOpenCL_1_0_Device = 0;
|
||||
int gHasLong = 1;
|
||||
bool gCoreILProgram = true;
|
||||
bool gCoreILProgram = true;
|
||||
|
||||
#define DEFAULT_NUM_ELEMENTS 0x4000
|
||||
|
||||
@@ -79,9 +79,13 @@ int fail_init_info(int count) {
|
||||
log_info("FAILED %d of %d tests.\n", count, count);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
void version_expected_info(const char * test_name, const char * api_name, const char * expected_version, const char * device_version) {
|
||||
log_info("%s skipped (requires at least %s version %s, but the device reports %s version %s)\n",
|
||||
test_name, api_name, expected_version, api_name, device_version);
|
||||
void version_expected_info(const char *test_name, const char *api_name,
|
||||
const char *expected_version,
|
||||
const char *device_version)
|
||||
{
|
||||
log_info("%s skipped (requires at least %s version %s, but the device "
|
||||
"reports %s version %s)\n",
|
||||
test_name, api_name, expected_version, api_name, device_version);
|
||||
}
|
||||
int runTestHarnessWithCheck( int argc, const char *argv[], int testNum, test_definition testList[],
|
||||
int forceNoContextCreation, cl_command_queue_properties queueProps,
|
||||
@@ -433,17 +437,16 @@ int runTestHarnessWithCheck( int argc, const char *argv[], int testNum, test_def
|
||||
log_error("Invalid device address bit size returned by device.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (gCompilationMode == kSpir_v) {
|
||||
if (gCompilationMode == kSpir_v)
|
||||
{
|
||||
test_status spirv_readiness = check_spirv_compilation_readiness(device);
|
||||
if (spirv_readiness != TEST_PASS) {
|
||||
if (spirv_readiness != TEST_PASS)
|
||||
{
|
||||
switch (spirv_readiness)
|
||||
{
|
||||
case TEST_PASS:
|
||||
break;
|
||||
case TEST_FAIL:
|
||||
return fail_init_info(testNum);
|
||||
case TEST_SKIP:
|
||||
return skip_init_info(testNum);
|
||||
case TEST_PASS: break;
|
||||
case TEST_FAIL: return fail_init_info(testNum);
|
||||
case TEST_SKIP: return skip_init_info(testNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -699,7 +702,9 @@ test_status callSingleTestFunction( test_definition test, cl_device_id deviceToU
|
||||
const Version device_version = get_device_cl_version(deviceToUse);
|
||||
if (test.min_version > device_version)
|
||||
{
|
||||
version_expected_info(test.name, "OpenCL", test.min_version.to_string().c_str(), device_version.to_string().c_str());
|
||||
version_expected_info(test.name, "OpenCL",
|
||||
test.min_version.to_string().c_str(),
|
||||
device_version.to_string().c_str());
|
||||
return TEST_SKIP;
|
||||
}
|
||||
|
||||
@@ -905,48 +910,66 @@ Version get_device_cl_version(cl_device_id device)
|
||||
throw std::runtime_error(std::string("Unknown OpenCL version: ") + str.data());
|
||||
}
|
||||
|
||||
bool check_device_spirv_version_reported(cl_device_id device) {
|
||||
bool check_device_spirv_version_reported(cl_device_id device)
|
||||
{
|
||||
size_t str_size;
|
||||
cl_int err;
|
||||
std::vector<char> str;
|
||||
if (gCoreILProgram) {
|
||||
if (gCoreILProgram)
|
||||
{
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size);
|
||||
if (err != CL_SUCCESS) {
|
||||
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION size;");
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error(
|
||||
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION size;");
|
||||
return false;
|
||||
}
|
||||
|
||||
str.resize(str_size);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size, str.data(), NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION value;");
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size,
|
||||
str.data(), NULL);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error(
|
||||
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION value;");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cl_int err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL, &str_size);
|
||||
if (err != CL_SUCCESS) {
|
||||
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR size;");
|
||||
else
|
||||
{
|
||||
cl_int err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL,
|
||||
&str_size);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error(
|
||||
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR size;");
|
||||
return false;
|
||||
}
|
||||
|
||||
str.resize(str_size);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size, str.data(), NULL);
|
||||
if (err != CL_SUCCESS) {
|
||||
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR value;");
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size,
|
||||
str.data(), NULL);
|
||||
if (err != CL_SUCCESS)
|
||||
{
|
||||
log_error(
|
||||
"clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION_KHR value;");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (strstr(str.data(), "SPIR-V") == NULL) {
|
||||
if (strstr(str.data(), "SPIR-V") == NULL)
|
||||
{
|
||||
log_info("This device does not support SPIR-V offline compilation.\n");
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Version spirv_version = get_device_spirv_il_version(device);
|
||||
log_info("This device supports SPIR-V offline compilation. SPIR-V version is %s\n", spirv_version.to_string().c_str());
|
||||
log_info("This device supports SPIR-V offline compilation. SPIR-V "
|
||||
"version is %s\n",
|
||||
spirv_version.to_string().c_str());
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
Version get_device_spirv_il_version(cl_device_id device)
|
||||
@@ -954,20 +977,25 @@ Version get_device_spirv_il_version(cl_device_id device)
|
||||
size_t str_size;
|
||||
cl_int err;
|
||||
std::vector<char> str;
|
||||
if (gCoreILProgram) {
|
||||
if (gCoreILProgram)
|
||||
{
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size);
|
||||
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||
|
||||
str.resize(str_size);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size, str.data(), NULL);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, str_size,
|
||||
str.data(), NULL);
|
||||
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||
}
|
||||
else {
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL, &str_size);
|
||||
else
|
||||
{
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, 0, NULL,
|
||||
&str_size);
|
||||
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||
|
||||
str.resize(str_size);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size, str.data(), NULL);
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION_KHR, str_size,
|
||||
str.data(), NULL);
|
||||
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||
}
|
||||
|
||||
@@ -984,7 +1012,8 @@ Version get_device_spirv_il_version(cl_device_id device)
|
||||
else if (strstr(str.data(), "SPIR-V_1.5") != NULL)
|
||||
return Version(1, 5);
|
||||
|
||||
throw std::runtime_error(std::string("Unknown SPIR-V version: ") + str.data());
|
||||
throw std::runtime_error(std::string("Unknown SPIR-V version: ")
|
||||
+ str.data());
|
||||
}
|
||||
|
||||
test_status check_spirv_compilation_readiness(cl_device_id device)
|
||||
@@ -992,35 +1021,52 @@ test_status check_spirv_compilation_readiness(cl_device_id device)
|
||||
auto ocl_version = get_device_cl_version(device);
|
||||
auto ocl_expected_min_version = Version(2, 1);
|
||||
|
||||
if (ocl_version < ocl_expected_min_version) {
|
||||
if (is_extension_available(device, "cl_khr_il_program")) {
|
||||
if (ocl_version < ocl_expected_min_version)
|
||||
{
|
||||
if (is_extension_available(device, "cl_khr_il_program"))
|
||||
{
|
||||
gCoreILProgram = false;
|
||||
bool spirv_supported = check_device_spirv_version_reported(device);
|
||||
if (spirv_supported == false) {
|
||||
log_error("SPIR-V intermediate language not supported !!! OpenCL %s requires support.\n", ocl_version.to_string().c_str());
|
||||
if (spirv_supported == false)
|
||||
{
|
||||
log_error("SPIR-V intermediate language not supported !!! "
|
||||
"OpenCL %s requires support.\n",
|
||||
ocl_version.to_string().c_str());
|
||||
return TEST_FAIL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return TEST_PASS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
version_expected_info("Test", "OpenCL", ocl_expected_min_version.to_string().c_str(), ocl_version.to_string().c_str());
|
||||
else
|
||||
{
|
||||
version_expected_info("Test", "OpenCL",
|
||||
ocl_expected_min_version.to_string().c_str(),
|
||||
ocl_version.to_string().c_str());
|
||||
return TEST_SKIP;
|
||||
}
|
||||
}
|
||||
|
||||
bool spirv_supported = check_device_spirv_version_reported(device);
|
||||
if (ocl_version >= ocl_expected_min_version && ocl_version <= Version(2, 2)) {
|
||||
if (spirv_supported == false) {
|
||||
log_error("SPIR-V intermediate language not supported !!! OpenCL %s requires support.\n", ocl_version.to_string().c_str());
|
||||
if (ocl_version >= ocl_expected_min_version && ocl_version <= Version(2, 2))
|
||||
{
|
||||
if (spirv_supported == false)
|
||||
{
|
||||
log_error("SPIR-V intermediate language not supported !!! OpenCL "
|
||||
"%s requires support.\n",
|
||||
ocl_version.to_string().c_str());
|
||||
return TEST_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ocl_version > Version(2, 2)) {
|
||||
if (spirv_supported == false) {
|
||||
log_info("SPIR-V intermediate language not supported in OpenCL %s. Test skipped.\n", ocl_version.to_string().c_str());
|
||||
if (ocl_version > Version(2, 2))
|
||||
{
|
||||
if (spirv_supported == false)
|
||||
{
|
||||
log_info("SPIR-V intermediate language not supported in OpenCL %s. "
|
||||
"Test skipped.\n",
|
||||
ocl_version.to_string().c_str());
|
||||
return TEST_SKIP;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user