@@ -170,6 +170,7 @@ void version_expected_info(const char *test_name, const char *api_name,
170170 " reports %s version %s)\n " ,
171171 test_name, api_name, expected_version, api_name, device_version);
172172}
173+
173174int runTestHarnessWithCheck (int argc, const char *argv[], int testNum,
174175 test_definition testList[],
175176 int forceNoContextCreation,
@@ -187,6 +188,7 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
187188 cl_device_id *devices = NULL ;
188189 cl_uint choosen_device_index = 0 ;
189190 cl_uint choosen_platform_index = 0 ;
191+ const char * chosen_platform_name = nullptr ;
190192
191193 int err, ret;
192194 char *endPtr;
@@ -248,6 +250,12 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
248250 choosen_platform_index = atoi (env_mode);
249251 }
250252
253+ env_mode = getenv (" CL_PLATFORM_NAME" );
254+ if (env_mode != NULL )
255+ {
256+ chosen_platform_name = env_mode;
257+ }
258+
251259 /* Process the command line arguments */
252260
253261 argc = parseCustomParam (argc, argv);
@@ -397,10 +405,11 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
397405 break ;
398406 default : log_error (" Requesting unknown device " ); return EXIT_FAILURE;
399407 }
408+
400409 log_info (based_on_env_var ? " based on environment variable "
401410 : " based on command line " );
402- log_info (" for platform index %d and device index %d\n " ,
403- choosen_platform_index, choosen_device_index);
411+ log_info (" for platform index %d / name %s and device index %d\n " ,
412+ choosen_platform_index, chosen_platform_name, choosen_device_index);
404413
405414#if defined(__APPLE__)
406415#if defined(__i386__) || defined(__x86_64__)
@@ -463,6 +472,32 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
463472 return EXIT_FAILURE;
464473 }
465474
475+ if (chosen_platform_name) {
476+ unsigned i = 0 ;
477+ for (; i < num_platforms; ++i) {
478+ char PlatformName[1024 ];
479+ size_t ActualSize = 0 ;
480+ err = clGetPlatformInfo (platforms[i], CL_PLATFORM_NAME,
481+ 1024 , PlatformName, &ActualSize);
482+ if (err || ActualSize >= 1024 )
483+ {
484+ print_error (err, " clGetPlatformInfo(CL_PLATFORM_NAME) failed" );
485+ return EXIT_FAILURE;
486+ }
487+ if (strstr (PlatformName, chosen_platform_name) != nullptr ) {
488+ choosen_platform_index = i;
489+ log_info (" Using platform index %d / name %s and device index %d\n " ,
490+ choosen_platform_index, PlatformName, choosen_device_index);
491+ break ;
492+ }
493+ }
494+ if (i == num_platforms) {
495+ log_error (" could not find any platform by name '%s'\n " ,
496+ chosen_platform_name);
497+ return EXIT_FAILURE;
498+ }
499+ }
500+
466501 /* Get the number of requested devices */
467502 err = clGetDeviceIDs (platforms[choosen_platform_index], device_type, 0 ,
468503 NULL , &num_devices);
0 commit comments