Skip to content

Commit

Permalink
Remove command line parameters for platform and device selection
Browse files Browse the repository at this point in the history
Fixes #711

Signed-off-by: Ellen Norris-Thompson <ellen.norris-thompson@arm.com>
  • Loading branch information
ellnor01 authored and ahesham-arm committed Jul 11, 2024
1 parent 6d60301 commit ef923e2
Showing 1 changed file with 17 additions and 79 deletions.
96 changes: 17 additions & 79 deletions test_common/harness/testHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,12 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,

int err, ret;
char *endPtr;
int based_on_env_var = 0;


/* Check for environment variable to set device type */
char *env_mode = getenv("CL_DEVICE_TYPE");
if (env_mode != NULL)
{
based_on_env_var = 1;
if (strcmp(env_mode, "gpu") == 0
|| strcmp(env_mode, "CL_DEVICE_TYPE_GPU") == 0)
device_type = CL_DEVICE_TYPE_GPU;
Expand Down Expand Up @@ -226,6 +224,23 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
choosen_platform_index = atoi(env_mode);
}

switch (device_type)
{
case CL_DEVICE_TYPE_GPU: log_info("Requesting GPU device "); break;
case CL_DEVICE_TYPE_CPU: log_info("Requesting CPU device "); break;
case CL_DEVICE_TYPE_ACCELERATOR:
log_info("Requesting Accelerator device ");
break;
case CL_DEVICE_TYPE_DEFAULT:
log_info("Requesting Default device ");
break;
default: log_error("Requesting unknown device "); return EXIT_FAILURE;
}
log_info("based on environment variable for platform index %d and device "
"index %d\n",
choosen_platform_index, choosen_device_index);


/* Process the command line arguments */

argc = parseCustomParam(argc, argv);
Expand Down Expand Up @@ -296,83 +311,6 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum,
}
}

/* Do we have a CPU/GPU specification? */
if (argc > 1)
{
if (strcmp(argv[argc - 1], "gpu") == 0
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_GPU") == 0)
{
device_type = CL_DEVICE_TYPE_GPU;
argc--;
}
else if (strcmp(argv[argc - 1], "cpu") == 0
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_CPU") == 0)
{
device_type = CL_DEVICE_TYPE_CPU;
argc--;
}
else if (strcmp(argv[argc - 1], "accelerator") == 0
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_ACCELERATOR") == 0)
{
device_type = CL_DEVICE_TYPE_ACCELERATOR;
argc--;
}
else if (strcmp(argv[argc - 1], "custom") == 0
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_CUSTOM") == 0)
{
device_type = CL_DEVICE_TYPE_CUSTOM;
argc--;
}
else if (strcmp(argv[argc - 1], "CL_DEVICE_TYPE_DEFAULT") == 0)
{
device_type = CL_DEVICE_TYPE_DEFAULT;
argc--;
}
}

/* Did we choose a specific device index? */
if (argc > 1)
{
if (strlen(argv[argc - 1]) >= 3 && argv[argc - 1][0] == 'i'
&& argv[argc - 1][1] == 'd')
{
choosen_device_index = atoi(&(argv[argc - 1][2]));
argc--;
}
}

/* Did we choose a specific platform index? */
if (argc > 1)
{
if (strlen(argv[argc - 1]) >= 3 && argv[argc - 1][0] == 'p'
&& argv[argc - 1][1] == 'i' && argv[argc - 1][2] == 'd')
{
choosen_platform_index = atoi(&(argv[argc - 1][3]));
argc--;
}
}


switch (device_type)
{
case CL_DEVICE_TYPE_GPU: log_info("Requesting GPU device "); break;
case CL_DEVICE_TYPE_CPU: log_info("Requesting CPU device "); break;
case CL_DEVICE_TYPE_ACCELERATOR:
log_info("Requesting Accelerator device ");
break;
case CL_DEVICE_TYPE_CUSTOM:
log_info("Requesting Custom device ");
break;
case CL_DEVICE_TYPE_DEFAULT:
log_info("Requesting Default device ");
break;
default: log_error("Requesting unknown device "); return EXIT_FAILURE;
}
log_info(based_on_env_var ? "based on environment variable "
: "based on command line ");
log_info("for platform index %d and device index %d\n",
choosen_platform_index, choosen_device_index);

#if defined(__APPLE__)
#if defined(__i386__) || defined(__x86_64__)
#define kHasSSE3 0x00000008
Expand Down

0 comments on commit ef923e2

Please sign in to comment.