Improve logging of unknown extensions (#1556)

Add missing newlines, and log all unknown extensions instead of logging
only the first unknown extension found.
This commit is contained in:
Stuart Brady
2022-11-04 18:26:19 +00:00
committed by GitHub
parent f29ebf0d59
commit 133834615e

View File

@@ -164,6 +164,7 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context
memset( extension_type, 0, sizeof( extension_type) ); memset( extension_type, 0, sizeof( extension_type) );
bool failed = false;
// loop over extension string // loop over extension string
while (currentP != extensions + stringSize) while (currentP != extensions + stringSize)
{ {
@@ -225,8 +226,10 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context
} }
if( ii == num_known_extensions ) if( ii == num_known_extensions )
{ {
log_error( "FAIL: Extension %s is not in the list of approved Khronos extensions!", extensions_supported[ num_of_supported_extensions ] ); log_error("FAIL: Extension %s is not in the list of approved "
return -1; "Khronos extensions!\n",
extensions_supported[num_of_supported_extensions]);
failed = true;
} }
} }
// Is it an embedded extension? // Is it an embedded extension?
@@ -241,19 +244,29 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context
} }
if( known_embedded_extensions[ ii ] == NULL ) if( known_embedded_extensions[ ii ] == NULL )
{ {
log_error( "FAIL: Extension %s is not in the list of approved Khronos embedded extensions!", extensions_supported[ num_of_supported_extensions ] ); log_error("FAIL: Extension %s is not in the list of approved "
return -1; "Khronos embedded extensions!\n",
extensions_supported[num_of_supported_extensions]);
failed = true;
} }
else
// It's approved, but are we even an embedded system?
char profileStr[128] = "";
error = clGetDeviceInfo( device, CL_DEVICE_PROFILE, sizeof( profileStr ), &profileStr, NULL );
test_error( error, "Unable to get CL_DEVICE_PROFILE to validate embedded extension name" );
if( strcmp( profileStr, "EMBEDDED_PROFILE" ) != 0 )
{ {
log_error( "FAIL: Extension %s is an approved embedded extension, but on a non-embedded profile!", extensions_supported[ num_of_supported_extensions ] ); // It's approved, but are we even an embedded system?
return -1; char profileStr[128] = "";
error = clGetDeviceInfo(device, CL_DEVICE_PROFILE,
sizeof(profileStr), &profileStr, NULL);
test_error(error,
"Unable to get CL_DEVICE_PROFILE to validate "
"embedded extension name");
if (strcmp(profileStr, "EMBEDDED_PROFILE") != 0)
{
log_error(
"FAIL: Extension %s is an approved embedded extension, "
"but on a non-embedded profile!\n",
extensions_supported[num_of_supported_extensions]);
failed = true;
}
} }
} }
else else
@@ -262,25 +275,31 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context
extensions_supported[ num_of_supported_extensions ][1] != 'l' || extensions_supported[ num_of_supported_extensions ][1] != 'l' ||
extensions_supported[ num_of_supported_extensions ][2] != '_' ) extensions_supported[ num_of_supported_extensions ][2] != '_' )
{ {
log_error( "FAIL: Extension %s doesn't start with \"cl_\"!", extensions_supported[ num_of_supported_extensions ] ); log_error("FAIL: Extension %s doesn't start with \"cl_\"!\n",
return -1; extensions_supported[num_of_supported_extensions]);
failed = true;
} }
else if (extensions_supported[num_of_supported_extensions][3] == '_'
if( extensions_supported[ num_of_supported_extensions ][3] == '_' || extensions_supported[ num_of_supported_extensions ][3] == '\0' ) || extensions_supported[num_of_supported_extensions][3]
== '\0')
{ {
log_error( "FAIL: Vendor name is missing in extension %s!", extensions_supported[ num_of_supported_extensions ] ); log_error("FAIL: Vendor name is missing in extension %s!\n",
return -1; extensions_supported[num_of_supported_extensions]);
failed = true;
} }
else
// look for the second underscore for name
char *p = extensions_supported[ num_of_supported_extensions ] + 4;
while( *p != '\0' && *p != '_' )
p++;
if( *p != '_' || p[1] == '\0')
{ {
log_error( "FAIL: extension name is missing in extension %s!", extensions_supported[ num_of_supported_extensions ] ); // look for the second underscore for name
return -1; char *p = extensions_supported[num_of_supported_extensions] + 4;
while (*p != '\0' && *p != '_') p++;
if (*p != '_' || p[1] == '\0')
{
log_error(
"FAIL: extension name is missing in extension %s!\n",
extensions_supported[num_of_supported_extensions]);
failed = true;
}
} }
} }
@@ -288,6 +307,11 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context
num_of_supported_extensions++; num_of_supported_extensions++;
} }
if (failed)
{
return -1;
}
// Build a list of the known extensions that are not supported by the device // Build a list of the known extensions that are not supported by the device
char *extensions_not_supported[1024]; char *extensions_not_supported[1024];
int num_not_supported_extensions = 0; int num_not_supported_extensions = 0;