diff --git a/test_common/harness/errorHelpers.h b/test_common/harness/errorHelpers.h index d59bc78d..80eb3b58 100644 --- a/test_common/harness/errorHelpers.h +++ b/test_common/harness/errorHelpers.h @@ -62,6 +62,7 @@ static int vlog_win32(const char *format, ...); return TEST_FAIL; \ } #define test_error(errCode, msg) test_error_ret(errCode, msg, errCode) +#define test_error_fail(errCode, msg) test_error_ret(errCode, msg, TEST_FAIL) #define test_error_ret(errCode, msg, retValue) \ { \ auto errCodeResult = errCode; \ diff --git a/test_conformance/subgroups/subgroup_common_templates.h b/test_conformance/subgroups/subgroup_common_templates.h index 349f8100..cfe02c2f 100644 --- a/test_conformance/subgroups/subgroup_common_templates.h +++ b/test_conformance/subgroups/subgroup_common_templates.h @@ -168,8 +168,8 @@ template struct BC } } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int ii, i, j, k, l, n; int ng = test_params.global_workgroup_size; @@ -499,8 +499,8 @@ template struct SHF } } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int ii, i, j, k, l, n; int nw = test_params.local_workgroup_size; @@ -583,8 +583,8 @@ template struct SCEX_NU genrand(x, t, m, ns, nw, ng); } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int ii, i, j, k, n; int nw = test_params.local_workgroup_size; @@ -689,8 +689,8 @@ template struct SCIN_NU operation_names(operation), TypeManager::name()); } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int ii, i, j, k, n; int nw = test_params.local_workgroup_size; @@ -805,8 +805,8 @@ template struct RED_NU genrand(x, t, m, ns, nw, ng); } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int ii, i, j, k, n; int nw = test_params.local_workgroup_size; diff --git a/test_conformance/subgroups/subhelpers.h b/test_conformance/subgroups/subhelpers.h index 6d32928a..bd4b6d61 100644 --- a/test_conformance/subgroups/subhelpers.h +++ b/test_conformance/subgroups/subhelpers.h @@ -1375,25 +1375,31 @@ static int run_kernel(cl_context context, cl_command_queue queue, // Driver for testing a single built in function template struct test { - static int mrun(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements, const char *kname, - const char *src, WorkGroupParams test_params) + static test_status mrun(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements, + const char *kname, const char *src, + WorkGroupParams test_params) { - int error = TEST_PASS; + test_status combined_error = TEST_SKIPPED_ITSELF; for (auto &mask : test_params.all_work_item_masks) { test_params.work_items_mask = mask; - error |= run(device, context, queue, num_elements, kname, src, - test_params); + test_status error = run(device, context, queue, num_elements, kname, + src, test_params); + + if (error == TEST_FAIL + || (error == TEST_PASS && combined_error != TEST_FAIL)) + combined_error = error; } - return error; + return combined_error; }; - static int run(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements, const char *kname, - const char *src, WorkGroupParams test_params) + static test_status run(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements, + const char *kname, const char *src, + WorkGroupParams test_params) { size_t tmp; - int error; + cl_int error; int subgroup_size, num_subgroups; size_t realSize; size_t global = test_params.global_workgroup_size; @@ -1434,7 +1440,7 @@ template struct test if (!TypeManager::type_supported(device)) { log_info("Data type not supported : %s\n", TypeManager::name()); - return 0; + return TEST_SKIPPED_ITSELF; } else { @@ -1450,7 +1456,7 @@ template struct test error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), (void *)&platform, NULL); - test_error(error, "clGetDeviceInfo failed for CL_DEVICE_PLATFORM"); + test_error_fail(error, "clGetDeviceInfo failed for CL_DEVICE_PLATFORM"); if (test_params.use_core_subgroups) { kernel_sstr @@ -1465,12 +1471,12 @@ template struct test error = create_single_kernel_helper(context, &program, &kernel, 1, &kernel_src, kname); - if (error != 0) return error; + if (error != CL_SUCCESS) return TEST_FAIL; // Determine some local dimensions to use for the test. error = get_max_common_work_group_size( context, kernel, test_params.global_workgroup_size, &local); - test_error(error, "get_max_common_work_group_size failed"); + test_error_fail(error, "get_max_common_work_group_size failed"); // Limit it a bit so we have muliple work groups // Ideally this will still be large enough to give us multiple @@ -1543,7 +1549,7 @@ template struct test input_array_size * sizeof(Ty), sgmap.data(), global * sizeof(cl_int4), odata.data(), output_array_size * sizeof(Ty), TSIZE * sizeof(Ty)); - test_error(error, "Running kernel first time failed"); + test_error_fail(error, "Running kernel first time failed"); // Generate the desired input for the kernel @@ -1553,13 +1559,18 @@ template struct test input_array_size * sizeof(Ty), sgmap.data(), global * sizeof(cl_int4), odata.data(), output_array_size * sizeof(Ty), TSIZE * sizeof(Ty)); - test_error(error, "Running kernel second time failed"); + test_error_fail(error, "Running kernel second time failed"); // Check the result - error = Fns::chk(idata.data(), odata.data(), mapin.data(), - mapout.data(), sgmap.data(), test_params); - test_error(error, "Data verification failed"); - return TEST_PASS; + test_status status = Fns::chk(idata.data(), odata.data(), mapin.data(), + mapout.data(), sgmap.data(), test_params); + // Detailed failure and skip messages should be logged by Fns::gen + // and Fns::chk. + if (status == TEST_FAIL) + { + test_fail("Data verification failed\n"); + } + return status; } }; @@ -1625,7 +1636,10 @@ struct RunTestForType test_params_); } - return error; + // If we return TEST_SKIPPED_ITSELF here, then an entire suite may be + // reported as having been skipped even if some tests within it + // passed, as the status codes are erroneously ORed together: + return error == TEST_FAIL ? TEST_FAIL : TEST_PASS; } private: diff --git a/test_conformance/subgroups/test_barrier.cpp b/test_conformance/subgroups/test_barrier.cpp index 47e42f65..b570e922 100644 --- a/test_conformance/subgroups/test_barrier.cpp +++ b/test_conformance/subgroups/test_barrier.cpp @@ -92,8 +92,8 @@ template struct BAR } } - static int chk(cl_int *x, cl_int *y, cl_int *mx, cl_int *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(cl_int *x, cl_int *y, cl_int *mx, cl_int *my, + cl_int *m, const WorkGroupParams &test_params) { int ii, i, j, k, n; int nw = test_params.local_workgroup_size; @@ -133,7 +133,7 @@ template struct BAR "id %d in sub group %d in group %d expected " "%d got %d\n", i, j, k, tr, rr); - return -1; + return TEST_FAIL; } } } @@ -143,7 +143,7 @@ template struct BAR m += 2 * nw; } - return 0; + return TEST_PASS; } }; @@ -187,4 +187,4 @@ int test_barrier_functions_ext(cl_device_id device, cl_context context, } return test_barrier_functions(device, context, queue, num_elements, false); -} \ No newline at end of file +} diff --git a/test_conformance/subgroups/test_ifp.cpp b/test_conformance/subgroups/test_ifp.cpp index fccaa8c7..f6c5227d 100644 --- a/test_conformance/subgroups/test_ifp.cpp +++ b/test_conformance/subgroups/test_ifp.cpp @@ -245,8 +245,8 @@ struct IFP } } - static int chk(cl_int *x, cl_int *y, cl_int *t, cl_int *, cl_int *, - const WorkGroupParams &test_params) + static test_status chk(cl_int *x, cl_int *y, cl_int *t, cl_int *, cl_int *, + const WorkGroupParams &test_params) { int i, k; int nw = test_params.local_workgroup_size; @@ -255,8 +255,8 @@ struct IFP int nj = (nw + ns - 1) / ns; ng = ng / nw; - // We need at least 2 sub groups per group for this tes - if (nj == 1) return 0; + // We need at least 2 sub groups per group for this test + if (nj == 1) return TEST_SKIPPED_ITSELF; log_info(" independent forward progress...\n"); @@ -270,14 +270,14 @@ struct IFP log_error( "ERROR: mismatch at element %d in work group %d\n", i, k); - return -1; + return TEST_FAIL; } } x += nj * (NUM_LOC + 1); y += NUM_LOC; } - return 0; + return TEST_PASS; } }; diff --git a/test_conformance/subgroups/test_subgroup.cpp b/test_conformance/subgroups/test_subgroup.cpp index 63bfc453..eefca5f8 100644 --- a/test_conformance/subgroups/test_subgroup.cpp +++ b/test_conformance/subgroups/test_subgroup.cpp @@ -68,8 +68,8 @@ template struct AA } } - static int chk(cl_int *x, cl_int *y, cl_int *mx, cl_int *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(cl_int *x, cl_int *y, cl_int *mx, cl_int *my, + cl_int *m, const WorkGroupParams &test_params) { int ii, i, j, k, n; int ng = test_params.global_workgroup_size; diff --git a/test_conformance/subgroups/test_subgroup_ballot.cpp b/test_conformance/subgroups/test_subgroup_ballot.cpp index ac90bad7..0228e82c 100644 --- a/test_conformance/subgroups/test_subgroup_ballot.cpp +++ b/test_conformance/subgroups/test_subgroup_ballot.cpp @@ -33,8 +33,8 @@ template struct BALLOT log_info(" sub_group_ballot...\n"); } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int wi_id, wg_id, sb_id; int gws = test_params.global_workgroup_size; @@ -146,8 +146,8 @@ template struct BALLOT_BIT_EXTRACT } } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int wi_id, wg_id, l, sb_id; int gws = test_params.global_workgroup_size; @@ -269,8 +269,8 @@ template struct BALLOT_INVERSE // no work here } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int wi_id, wg_id, sb_id; int gws = test_params.global_workgroup_size; @@ -444,8 +444,8 @@ template struct BALLOT_COUNT_SCAN_FIND return mask; } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int wi_id, wg_id, sb_id; int gws = test_params.global_workgroup_size; @@ -617,8 +617,8 @@ template struct SMASK } } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int wi_id, wg_id, sb_id; int gws = test_params.global_workgroup_size; diff --git a/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp b/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp index 11fcebc4..ad9e1ff2 100644 --- a/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp +++ b/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp @@ -50,8 +50,8 @@ template struct RED_CLU genrand(x, t, m, ns, nw, ng); } - static int chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m, + const WorkGroupParams &test_params) { int nw = test_params.local_workgroup_size; int ns = test_params.subgroup_size; diff --git a/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp b/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp index 835de25d..b21a9f7e 100644 --- a/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp +++ b/test_conformance/subgroups/test_subgroup_non_uniform_vote.cpp @@ -83,8 +83,8 @@ template struct VOTE } } - static int chk(T *x, T *y, T *mx, T *my, cl_int *m, - const WorkGroupParams &test_params) + static test_status chk(T *x, T *y, T *mx, T *my, cl_int *m, + const WorkGroupParams &test_params) { int ii, i, j, k, n; int nw = test_params.local_workgroup_size;