From ef923e28c0bc3ef5cb88c2638d54c24bd266c282 Mon Sep 17 00:00:00 2001 From: Ellen Norris-Thompson Date: Mon, 23 Nov 2020 16:04:51 +0000 Subject: [PATCH] Remove command line parameters for platform and device selection Fixes #711 Signed-off-by: Ellen Norris-Thompson --- test_common/harness/testHarness.cpp | 96 +++++------------------------ 1 file changed, 17 insertions(+), 79 deletions(-) diff --git a/test_common/harness/testHarness.cpp b/test_common/harness/testHarness.cpp index 0e3c49e9a3..8056053515 100644 --- a/test_common/harness/testHarness.cpp +++ b/test_common/harness/testHarness.cpp @@ -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; @@ -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); @@ -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