mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Spirv readiness - move to harness
Fixes support cl_khr_il_program
This commit is contained in:
committed by
Alastair Murray
parent
adec8f9412
commit
9a006ba1a0
@@ -433,7 +433,20 @@ int runTestHarnessWithCheck( int argc, const char *argv[], int testNum, test_def
|
|||||||
log_error("Invalid device address bit size returned by device.\n");
|
log_error("Invalid device address bit size returned by device.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (gCompilationMode == kSpir_v) {
|
||||||
|
test_status spirv_readiness = check_spirv_compilation_readiness(device);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If we have a device checking function, run it */
|
/* If we have a device checking function, run it */
|
||||||
if( ( deviceCheckFn != NULL ) )
|
if( ( deviceCheckFn != NULL ) )
|
||||||
@@ -892,19 +905,37 @@ Version get_device_cl_version(cl_device_id device)
|
|||||||
throw std::runtime_error(std::string("Unknown OpenCL version: ") + str.data());
|
throw std::runtime_error(std::string("Unknown OpenCL version: ") + str.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_device_spirv_il_support(cl_device_id device) {
|
bool check_device_spirv_version_reported(cl_device_id device) {
|
||||||
size_t str_size;
|
size_t str_size;
|
||||||
cl_int err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size);
|
cl_int err;
|
||||||
if (err != CL_SUCCESS) {
|
std::vector<char> str;
|
||||||
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION size;");
|
if (gCoreILProgram) {
|
||||||
return false;
|
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;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<char> str(str_size);
|
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);
|
||||||
if (err != CL_SUCCESS) {
|
if (err != CL_SUCCESS) {
|
||||||
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION value;");
|
log_error("clGetDeviceInfo: cannot read CL_DEVICE_IL_VERSION value;");
|
||||||
return false;
|
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;");
|
||||||
|
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;");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(str.data(), "SPIR-V") == NULL) {
|
if (strstr(str.data(), "SPIR-V") == NULL) {
|
||||||
@@ -915,17 +946,30 @@ bool check_device_spirv_il_support(cl_device_id 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;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Version get_device_spirv_il_version(cl_device_id device)
|
Version get_device_spirv_il_version(cl_device_id device)
|
||||||
{
|
{
|
||||||
size_t str_size;
|
size_t str_size;
|
||||||
cl_int err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size);
|
cl_int err;
|
||||||
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
std::vector<char> str;
|
||||||
|
if (gCoreILProgram) {
|
||||||
|
err = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &str_size);
|
||||||
|
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||||
|
|
||||||
std::vector<char> str(str_size);
|
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");
|
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
ASSERT_SUCCESS(err, "clGetDeviceInfo");
|
||||||
|
}
|
||||||
|
|
||||||
if (strstr(str.data(), "SPIR-V_1.0") != NULL)
|
if (strstr(str.data(), "SPIR-V_1.0") != NULL)
|
||||||
return Version(1, 0);
|
return Version(1, 0);
|
||||||
@@ -943,37 +987,42 @@ Version get_device_spirv_il_version(cl_device_id device)
|
|||||||
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, bool force)
|
test_status check_spirv_compilation_readiness(cl_device_id device)
|
||||||
{
|
{
|
||||||
if (gCompilationMode == kSpir_v || force) {
|
auto ocl_version = get_device_cl_version(device);
|
||||||
auto ocl_version = get_device_cl_version(device);
|
auto ocl_expected_min_version = Version(2, 1);
|
||||||
auto ocl_expected_min_version = Version(2, 1);
|
|
||||||
|
|
||||||
if (ocl_version < ocl_expected_min_version) {
|
if (ocl_version < ocl_expected_min_version) {
|
||||||
if (is_extension_available(device, "cl_khr_il_program")) {
|
if (is_extension_available(device, "cl_khr_il_program")) {
|
||||||
gCoreILProgram = false;
|
gCoreILProgram = false;
|
||||||
log_info("SPIR-V intermediate language supported in OpenCL %s by extension cl_khr_il_program.\n", ocl_version.to_string().c_str());
|
bool spirv_supported = check_device_spirv_version_reported(device);
|
||||||
}
|
|
||||||
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_il_support(device);
|
|
||||||
if (ocl_version >= ocl_expected_min_version && ocl_version <= Version(2, 2)) {
|
|
||||||
if (spirv_supported == false) {
|
if (spirv_supported == false) {
|
||||||
log_error("SPIR-V intermediate language not supported !!! OpenCL %s requires support.\n", ocl_version.to_string().c_str());
|
log_error("SPIR-V intermediate language not supported !!! OpenCL %s requires support.\n", ocl_version.to_string().c_str());
|
||||||
return TEST_FAIL;
|
return TEST_FAIL;
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
|
return TEST_PASS;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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());
|
||||||
|
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());
|
||||||
|
return TEST_SKIP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TEST_PASS;
|
return TEST_PASS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ extern cl_device_id GetOpposingDevice( cl_device_id device );
|
|||||||
Version get_device_spirv_il_version(cl_device_id device);
|
Version get_device_spirv_il_version(cl_device_id device);
|
||||||
bool check_device_spirv_il_support(cl_device_id device);
|
bool check_device_spirv_il_support(cl_device_id device);
|
||||||
void version_expected_info(const char * test_name, const char * api_name, const char * expected_version, const char * device_version);
|
void version_expected_info(const char * test_name, const char * api_name, const char * expected_version, const char * device_version);
|
||||||
test_status check_spirv_compilation_readiness(cl_device_id device, bool force = false);
|
test_status check_spirv_compilation_readiness(cl_device_id device);
|
||||||
|
|
||||||
|
|
||||||
extern int gFlushDenormsToZero; // This is set to 1 if the device does not support denorms (CL_FP_DENORM)
|
extern int gFlushDenormsToZero; // This is set to 1 if the device does not support denorms (CL_FP_DENORM)
|
||||||
|
|||||||
@@ -1103,12 +1103,6 @@ test_status InitCL( cl_device_id device )
|
|||||||
}
|
}
|
||||||
|
|
||||||
gDevice = device;
|
gDevice = device;
|
||||||
test_status spirv_status;
|
|
||||||
spirv_status = check_spirv_compilation_readiness(device);
|
|
||||||
if (spirv_status != TEST_PASS) {
|
|
||||||
return spirv_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (error = clGetDeviceInfo( gDevice, CL_DEVICE_MAX_COMPUTE_UNITS, configSize, &gComputeDevices, NULL )) )
|
if( (error = clGetDeviceInfo( gDevice, CL_DEVICE_MAX_COMPUTE_UNITS, configSize, &gComputeDevices, NULL )) )
|
||||||
gComputeDevices = 1;
|
gComputeDevices = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ test_status InitCL(cl_device_id id)
|
|||||||
{
|
{
|
||||||
test_status spirv_status;
|
test_status spirv_status;
|
||||||
bool force = true;
|
bool force = true;
|
||||||
spirv_status = check_spirv_compilation_readiness(id, force);
|
spirv_status = check_spirv_compilation_readiness(id);
|
||||||
if (spirv_status != TEST_PASS) {
|
if (spirv_status != TEST_PASS) {
|
||||||
return spirv_status;
|
return spirv_status;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user