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 committed Nov 27, 2020
1 parent 5bd85b7 commit 8efa53c
Showing 1 changed file with 17 additions and 70 deletions.
87 changes: 17 additions & 70 deletions test_common/harness/testHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,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 @@ -166,6 +164,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 @@ -236,74 +251,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], "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_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 8efa53c

Please sign in to comment.