mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Ensure is_extension_available is used where possible (#721)
(Patch1) A number of tests have got their own code for checking the presence of extensions. This change replaces that code with is_extension_available function. Contributes to #627 Change-Id: I8dd2233719aa8c84841ac61776437d7f6e3fafe6 Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
This commit is contained in:
@@ -5848,37 +5848,7 @@ int test_get_kernel_arg_info( cl_device_id deviceID, cl_context context, cl_c
|
||||
log_info(" o Not testing image kernel arguments.\n");
|
||||
}
|
||||
|
||||
// Get the extensions string for the device
|
||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_EXTENSIONS, 0, NULL, &size);
|
||||
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS size failed");
|
||||
|
||||
char *extensions = (char*)malloc(sizeof(char)*(size + 1));
|
||||
if (extensions == 0) {
|
||||
log_error("Failed to allocate memory for extensions string.\n");
|
||||
return -1;
|
||||
}
|
||||
memset( extensions, CHAR_MIN, sizeof(char)*(size+1) );
|
||||
|
||||
error = clGetDeviceInfo(deviceID, CL_DEVICE_EXTENSIONS, sizeof(char)*size, extensions, NULL);
|
||||
test_error(error, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS failed");
|
||||
|
||||
// Check to make sure the extension string is NUL terminated.
|
||||
if( extensions[size] != CHAR_MIN )
|
||||
{
|
||||
test_error( -1, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS wrote past the end of the array!" );
|
||||
return -1;
|
||||
}
|
||||
extensions[size] = '\0'; // set last char to NUL to avoid problems with string functions later
|
||||
|
||||
// test for termination with '\0'
|
||||
size_t stringSize = strlen( extensions );
|
||||
if( stringSize == size )
|
||||
{
|
||||
test_error( -1, "clGetDeviceInfo for CL_DEVICE_EXTENSIONS is not NUL terminated!" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strstr(extensions, "cl_khr_fp64")) {
|
||||
if (is_extension_available(deviceID, "cl_khr_fp64")) {
|
||||
log_info(" o Device claims extension 'cl_khr_fp64'\n");
|
||||
log_info(" o Expecting SUCCESS when testing double kernel arguments.\n");
|
||||
supports_double = 1;
|
||||
@@ -5895,7 +5865,7 @@ int test_get_kernel_arg_info( cl_device_id deviceID, cl_context context, cl_c
|
||||
}
|
||||
}
|
||||
|
||||
if (strstr(extensions, "cl_khr_fp16")) {
|
||||
if (is_extension_available(deviceID, "cl_khr_fp16")) {
|
||||
log_info(" o Device claims extension 'cl_khr_fp16'\n");
|
||||
log_info(" o Expecting SUCCESS when testing halfn* kernel arguments.\n");
|
||||
supports_half = 1;
|
||||
@@ -5905,7 +5875,7 @@ int test_get_kernel_arg_info( cl_device_id deviceID, cl_context context, cl_c
|
||||
supports_half = 0;
|
||||
}
|
||||
|
||||
if (strstr(extensions, "cl_khr_int64"))
|
||||
if (is_extension_available(deviceID, "cl_khr_int64"))
|
||||
{
|
||||
log_info(" o Device claims extension 'cl_khr_int64'\n");
|
||||
log_info(" o Expecting SUCCESS when testing long kernel arguments.\n");
|
||||
|
||||
Reference in New Issue
Block a user