mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Add support for cl_khr_il_program extension
This commit is contained in:
committed by
Alastair Murray
parent
3730bce4e8
commit
adec8f9412
@@ -665,11 +665,32 @@ static int create_single_kernel_helper_create_program_offline(cl_context context
|
|||||||
|
|
||||||
size_t length = modifiedKernelBuf.size();
|
size_t length = modifiedKernelBuf.size();
|
||||||
log_info("offlineCompiler: clCreateProgramWithSource replaced with clCreateProgramWithIL\n");
|
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)
|
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;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ int gIsEmbedded = 0;
|
|||||||
int gIsOpenCL_C_1_0_Device = 0;
|
int gIsOpenCL_C_1_0_Device = 0;
|
||||||
int gIsOpenCL_1_0_Device = 0;
|
int gIsOpenCL_1_0_Device = 0;
|
||||||
int gHasLong = 1;
|
int gHasLong = 1;
|
||||||
|
bool gCoreILProgram = true;
|
||||||
|
|
||||||
#define DEFAULT_NUM_ELEMENTS 0x4000
|
#define DEFAULT_NUM_ELEMENTS 0x4000
|
||||||
|
|
||||||
@@ -911,7 +912,7 @@ bool check_device_spirv_il_support(cl_device_id device) {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Version spirv_version = get_device_spirv_il_version(device);
|
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;
|
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);
|
auto ocl_expected_min_version = Version(2, 1);
|
||||||
|
|
||||||
if (ocl_version < ocl_expected_min_version) {
|
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());
|
if (is_extension_available(device, "cl_khr_il_program")) {
|
||||||
return TEST_SKIP;
|
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);
|
bool spirv_supported = check_device_spirv_il_support(device);
|
||||||
if (ocl_version >= ocl_expected_min_version && ocl_version <= Version(2, 2)) {
|
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());
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ocl_version > Version(2, 2)) {
|
if (ocl_version > Version(2, 2)) {
|
||||||
if (spirv_supported == false) {
|
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;
|
return TEST_SKIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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 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 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__ )
|
#if ! defined( __APPLE__ )
|
||||||
void memset_pattern4(void *, const void *, size_t);
|
void memset_pattern4(void *, const void *, size_t);
|
||||||
|
|||||||
@@ -154,8 +154,25 @@ int get_program_with_il(clProgramWrapper &prog,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *buffer = &buffer_vec[0];
|
unsigned char *buffer = &buffer_vec[0];
|
||||||
prog = clCreateProgramWithIL(context, buffer, file_bytes, &err);
|
if (gCoreILProgram) {
|
||||||
SPIRV_CHECK_ERROR(err, "Failed to create program with clCreateProgramWithIL");
|
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);
|
err = clBuildProgram(prog, 1, &deviceID, NULL, NULL, NULL);
|
||||||
SPIRV_CHECK_ERROR(err, "Failed to build program");
|
SPIRV_CHECK_ERROR(err, "Failed to build program");
|
||||||
|
|||||||
Reference in New Issue
Block a user