diff --git a/test_common/harness/kernelHelpers.cpp b/test_common/harness/kernelHelpers.cpp index 6dbd63f2..41e3af55 100644 --- a/test_common/harness/kernelHelpers.cpp +++ b/test_common/harness/kernelHelpers.cpp @@ -665,11 +665,32 @@ static int create_single_kernel_helper_create_program_offline(cl_context context size_t length = modifiedKernelBuf.size(); log_info("offlineCompiler: clCreateProgramWithSource replaced with clCreateProgramWithIL\n"); + if (gCoreILProgram) { + *outProgram = clCreateProgramWithIL(context, &modifiedKernelBuf[0], length, &error); + } + else { + cl_platform_id platform; + error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); + print_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); + clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL; + + clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)clGetExtensionFunctionAddressForPlatform(platform, "clCreateProgramWithILKHR"); + if (clCreateProgramWithILKHR == NULL) + { + log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n"); + return -1; + } + *outProgram = clCreateProgramWithILKHR(context, &modifiedKernelBuf[0], length, &error); + } - *outProgram = clCreateProgramWithIL(context, &modifiedKernelBuf[0], length, &error); if (*outProgram == NULL || error != CL_SUCCESS) { - print_error(error, "clCreateProgramWithIL failed"); + if (gCoreILProgram) { + print_error(error, "clCreateProgramWithIL failed"); + } + else { + print_error(error, "clCreateProgramWithILKHR failed"); + } return error; } } diff --git a/test_common/harness/testHarness.cpp b/test_common/harness/testHarness.cpp index b1dff655..91dd728b 100644 --- a/test_common/harness/testHarness.cpp +++ b/test_common/harness/testHarness.cpp @@ -57,6 +57,7 @@ int gIsEmbedded = 0; int gIsOpenCL_C_1_0_Device = 0; int gIsOpenCL_1_0_Device = 0; int gHasLong = 1; +bool gCoreILProgram = true; #define DEFAULT_NUM_ELEMENTS 0x4000 @@ -911,7 +912,7 @@ bool check_device_spirv_il_support(cl_device_id device) { return false; } 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()); + log_info("This device supports SPIR-V offline compilation. SPIR-V version is %s\n", spirv_version.to_string().c_str()); } return true; } @@ -949,21 +950,27 @@ test_status check_spirv_compilation_readiness(cl_device_id device, bool force) auto ocl_expected_min_version = Version(2, 1); if (ocl_version < ocl_expected_min_version) { - version_expected_info("Test", "OpenCL", ocl_expected_min_version.to_string().c_str(), ocl_version.to_string().c_str()); - return TEST_SKIP; + if (is_extension_available(device, "cl_khr_il_program")) { + 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()); + } + 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) { - log_error("SPIR-V intermediate language not supported !!! OpenCL %s requires support.\n", ocl_version.to_string()); + 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()); + log_info("SPIR-V intermediate language not supported in OpenCL %s. Test skipped.\n", ocl_version.to_string().c_str()); return TEST_SKIP; } } diff --git a/test_common/harness/testHarness.h b/test_common/harness/testHarness.h index d6aefb46..84ba334a 100644 --- a/test_common/harness/testHarness.h +++ b/test_common/harness/testHarness.h @@ -146,6 +146,7 @@ extern int gInfNanSupport; // This is set to 1 if the device suppor extern int gIsEmbedded; // This is set to 1 if the device is an embedded device extern int gHasLong; // This is set to 1 if the device suppots long and ulong types in OpenCL C. extern int gIsOpenCL_C_1_0_Device; // This is set to 1 if the device supports only OpenCL C 1.0. +extern bool gCoreILProgram; #if ! defined( __APPLE__ ) void memset_pattern4(void *, const void *, size_t); diff --git a/test_conformance/spirv_new/main.cpp b/test_conformance/spirv_new/main.cpp index 0cd9f090..1beed907 100644 --- a/test_conformance/spirv_new/main.cpp +++ b/test_conformance/spirv_new/main.cpp @@ -154,8 +154,25 @@ int get_program_with_il(clProgramWrapper &prog, } unsigned char *buffer = &buffer_vec[0]; - prog = clCreateProgramWithIL(context, buffer, file_bytes, &err); - SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithIL"); + if (gCoreILProgram) { + prog = clCreateProgramWithIL(context, buffer, file_bytes, &err); + SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithIL"); + } + else { + cl_platform_id platform; + err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); + print_error(err, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); + clCreateProgramWithILKHR_fn clCreateProgramWithILKHR = NULL; + + clCreateProgramWithILKHR = (clCreateProgramWithILKHR_fn)clGetExtensionFunctionAddressForPlatform(platform, "clCreateProgramWithILKHR"); + if (clCreateProgramWithILKHR == NULL) + { + log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n"); + return -1; + } + prog = clCreateProgramWithILKHR(context, buffer, file_bytes, &err); + SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithILKHR"); + } err = clBuildProgram(prog, 1, &deviceID, NULL, NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to build program");