Refactor logging of subgroup test start/pass messages (#1361)

Note that this also corrects the start messages logged for the
sub_group_ballot_bit_count/find_msb/find_lsb tests.

Signed-off-by: Stuart Brady <stuart.brady@arm.com>
This commit is contained in:
Stuart Brady
2021-12-14 17:52:44 +00:00
committed by GitHub
parent 73d71b6a76
commit 1161d788dd
8 changed files with 164 additions and 98 deletions

View File

@@ -63,6 +63,13 @@ static cl_uint4 generate_bit_mask(cl_uint subgroup_local_id,
// only 4 work_items from subgroup enter the code (are active)
template <typename Ty, SubgroupsBroadcastOp operation> struct BC
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_%s(%s)...%s\n", operation_names(operation),
TypeManager<Ty>::name(), extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int i, ii, j, k, n;
@@ -76,8 +83,6 @@ template <typename Ty, SubgroupsBroadcastOp operation> struct BC
int last_subgroup_size = 0;
ii = 0;
log_info(" sub_group_%s(%s)...\n", operation_names(operation),
TypeManager<Ty>::name());
if (non_uniform_size)
{
ng++;
@@ -286,8 +291,6 @@ template <typename Ty, SubgroupsBroadcastOp operation> struct BC
y += nw;
m += 4 * nw;
}
log_info(" sub_group_%s(%s)... passed\n", operation_names(operation),
TypeManager<Ty>::name());
return TEST_PASS;
}
};
@@ -437,6 +440,13 @@ void genrand(Ty *x, Ty *t, cl_int *m, int ns, int nw, int ng)
template <typename Ty, ShuffleOp operation> struct SHF
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_%s(%s)...%s\n", operation_names(operation),
TypeManager<Ty>::name(), extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int i, ii, j, k, l, n, delta;
@@ -447,8 +457,6 @@ template <typename Ty, ShuffleOp operation> struct SHF
int d = ns > 100 ? 100 : ns;
ii = 0;
ng = ng / nw;
log_info(" sub_group_%s(%s)...\n", operation_names(operation),
TypeManager<Ty>::name());
for (k = 0; k < ng; ++k)
{ // for each work_group
for (j = 0; j < nj; ++j)
@@ -560,26 +568,29 @@ template <typename Ty, ShuffleOp operation> struct SHF
y += nw;
m += 4 * nw;
}
log_info(" sub_group_%s(%s)... passed\n", operation_names(operation),
TypeManager<Ty>::name());
return TEST_PASS;
}
};
template <typename Ty, ArithmeticOp operation> struct SCEX_NU
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
std::string func_name = (test_params.all_work_item_masks.size() > 0
? "sub_group_non_uniform_scan_exclusive"
: "sub_group_scan_exclusive");
log_info(" %s_%s(%s)...%s\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name(),
extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int nw = test_params.local_workgroup_size;
int ns = test_params.subgroup_size;
int ng = test_params.global_workgroup_size;
ng = ng / nw;
std::string func_name;
test_params.work_items_mask.any()
? func_name = "sub_group_non_uniform_scan_exclusive"
: func_name = "sub_group_scan_exclusive";
log_info(" %s_%s(%s)...\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name());
genrand<Ty, operation>(x, t, m, ns, nw, ng);
}
@@ -595,11 +606,9 @@ template <typename Ty, ArithmeticOp operation> struct SCEX_NU
Ty tr, rr;
ng = ng / nw;
std::string func_name;
test_params.work_items_mask.any()
? func_name = "sub_group_non_uniform_scan_exclusive"
: func_name = "sub_group_scan_exclusive";
std::string func_name = (test_params.all_work_item_masks.size() > 0
? "sub_group_non_uniform_scan_exclusive"
: "sub_group_scan_exclusive");
// for uniform case take into consideration all workitems
if (!work_items_mask.any())
@@ -656,8 +665,6 @@ template <typename Ty, ArithmeticOp operation> struct SCEX_NU
m += 4 * nw;
}
log_info(" %s_%s(%s)... passed\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name());
return TEST_PASS;
}
};
@@ -665,20 +672,24 @@ template <typename Ty, ArithmeticOp operation> struct SCEX_NU
// Test for scan inclusive non uniform functions
template <typename Ty, ArithmeticOp operation> struct SCIN_NU
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
std::string func_name = (test_params.all_work_item_masks.size() > 0
? "sub_group_non_uniform_scan_inclusive"
: "sub_group_scan_inclusive");
log_info(" %s_%s(%s)...%s\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name(),
extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int nw = test_params.local_workgroup_size;
int ns = test_params.subgroup_size;
int ng = test_params.global_workgroup_size;
ng = ng / nw;
std::string func_name;
test_params.work_items_mask.any()
? func_name = "sub_group_non_uniform_scan_inclusive"
: func_name = "sub_group_scan_inclusive";
genrand<Ty, operation>(x, t, m, ns, nw, ng);
log_info(" %s_%s(%s)...\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name());
}
static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m,
@@ -694,10 +705,9 @@ template <typename Ty, ArithmeticOp operation> struct SCIN_NU
Ty tr, rr;
ng = ng / nw;
std::string func_name;
work_items_mask.any()
? func_name = "sub_group_non_uniform_scan_inclusive"
: func_name = "sub_group_scan_inclusive";
std::string func_name = (test_params.all_work_item_masks.size() > 0
? "sub_group_non_uniform_scan_inclusive"
: "sub_group_scan_inclusive");
// for uniform case take into consideration all workitems
if (!work_items_mask.any())
@@ -771,8 +781,6 @@ template <typename Ty, ArithmeticOp operation> struct SCIN_NU
m += 4 * nw;
}
log_info(" %s_%s(%s)... passed\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name());
return TEST_PASS;
}
};
@@ -780,6 +788,16 @@ template <typename Ty, ArithmeticOp operation> struct SCIN_NU
// Test for reduce non uniform functions
template <typename Ty, ArithmeticOp operation> struct RED_NU
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
std::string func_name = (test_params.all_work_item_masks.size() > 0
? "sub_group_non_uniform_reduce"
: "sub_group_reduce");
log_info(" %s_%s(%s)...%s\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name(),
extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
@@ -787,13 +805,6 @@ template <typename Ty, ArithmeticOp operation> struct RED_NU
int ns = test_params.subgroup_size;
int ng = test_params.global_workgroup_size;
ng = ng / nw;
std::string func_name;
test_params.work_items_mask.any()
? func_name = "sub_group_non_uniform_reduce"
: func_name = "sub_group_reduce";
log_info(" %s_%s(%s)...\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name());
genrand<Ty, operation>(x, t, m, ns, nw, ng);
}
@@ -809,9 +820,9 @@ template <typename Ty, ArithmeticOp operation> struct RED_NU
ng = ng / nw;
Ty tr, rr;
std::string func_name;
work_items_mask.any() ? func_name = "sub_group_non_uniform_reduce"
: func_name = "sub_group_reduce";
std::string func_name = (test_params.all_work_item_masks.size() > 0
? "sub_group_non_uniform_reduce"
: "sub_group_reduce");
for (k = 0; k < ng; ++k)
{
@@ -875,8 +886,6 @@ template <typename Ty, ArithmeticOp operation> struct RED_NU
m += 4 * nw;
}
log_info(" %s_%s(%s)... passed\n", func_name.c_str(),
operation_names(operation), TypeManager<Ty>::name());
return TEST_PASS;
}
};

View File

@@ -1380,23 +1380,45 @@ template <typename Ty, typename Fns, size_t TSIZE = 0> struct test
const char *kname, const char *src,
WorkGroupParams test_params)
{
Fns::log_test(test_params, "");
test_status combined_error = TEST_SKIPPED_ITSELF;
for (auto &mask : test_params.all_work_item_masks)
{
test_params.work_items_mask = mask;
test_status error = run(device, context, queue, num_elements, kname,
src, test_params);
test_status error = do_run(device, context, queue, num_elements,
kname, src, test_params);
if (error == TEST_FAIL
|| (error == TEST_PASS && combined_error != TEST_FAIL))
combined_error = error;
}
if (combined_error == TEST_PASS)
{
Fns::log_test(test_params, " passed");
}
return combined_error;
};
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)
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)
{
Fns::log_test(test_params, "");
int error = do_run(device, context, queue, num_elements, kname, src,
test_params);
if (error == TEST_PASS)
{
Fns::log_test(test_params, " passed");
}
return error;
};
static test_status do_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;
cl_int error;
@@ -1442,16 +1464,14 @@ template <typename Ty, typename Fns, size_t TSIZE = 0> struct test
log_info("Data type not supported : %s\n", TypeManager<Ty>::name());
return TEST_SKIPPED_ITSELF;
}
else
if (strstr(TypeManager<Ty>::name(), "double"))
{
if (strstr(TypeManager<Ty>::name(), "double"))
{
kernel_sstr << "#pragma OPENCL EXTENSION cl_khr_fp64: enable\n";
}
else if (strstr(TypeManager<Ty>::name(), "half"))
{
kernel_sstr << "#pragma OPENCL EXTENSION cl_khr_fp16: enable\n";
}
kernel_sstr << "#pragma OPENCL EXTENSION cl_khr_fp64: enable\n";
}
else if (strstr(TypeManager<Ty>::name(), "half"))
{
kernel_sstr << "#pragma OPENCL EXTENSION cl_khr_fp16: enable\n";
}
error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform),

View File

@@ -59,6 +59,17 @@ static const char *gbar_source =
// barrier test functions
template <int Which> struct BAR
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
if (Which == 0)
log_info(" sub_group_barrier(CLK_LOCAL_MEM_FENCE)...%s\n",
extra_text);
else
log_info(" sub_group_barrier(CLK_GLOBAL_MEM_FENCE)...%s\n",
extra_text);
}
static void gen(cl_int *x, cl_int *t, cl_int *m,
const WorkGroupParams &test_params)
{
@@ -103,11 +114,6 @@ template <int Which> struct BAR
ng = ng / nw;
cl_int tr, rr;
if (Which == 0)
log_info(" sub_group_barrier(CLK_LOCAL_MEM_FENCE)...\n");
else
log_info(" sub_group_barrier(CLK_GLOBAL_MEM_FENCE)...\n");
for (k = 0; k < ng; ++k)
{
// Map to array indexed to array indexed by local ID and sub group

View File

@@ -225,6 +225,12 @@ void run_insts(cl_int *x, cl_int *p, int n)
struct IFP
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" independent forward progress...%s\n", extra_text);
}
static void gen(cl_int *x, cl_int *t, cl_int *,
const WorkGroupParams &test_params)
{
@@ -258,8 +264,6 @@ struct IFP
// 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");
for (k = 0; k < ng; ++k)
{
run_insts(x, t, nj);

View File

@@ -24,6 +24,13 @@ namespace {
// Any/All test functions
template <NonUniformVoteOp operation> struct AA
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_%s...%s\n", operation_names(operation),
extra_text);
}
static void gen(cl_int *x, cl_int *t, cl_int *m,
const WorkGroupParams &test_params)
{
@@ -35,7 +42,6 @@ template <NonUniformVoteOp operation> struct AA
int e;
ng = ng / nw;
ii = 0;
log_info(" sub_group_%s...\n", operation_names(operation));
for (k = 0; k < ng; ++k)
{
for (j = 0; j < nj; ++j)
@@ -124,7 +130,6 @@ template <NonUniformVoteOp operation> struct AA
y += nw;
m += 4 * nw;
}
log_info(" sub_group_%s... passed\n", operation_names(operation));
return TEST_PASS;
}
};

View File

@@ -23,6 +23,12 @@ namespace {
// Test for ballot functions
template <typename Ty> struct BALLOT
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_ballot...%s\n", extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
// no work here
@@ -30,7 +36,6 @@ template <typename Ty> struct BALLOT
int lws = test_params.local_workgroup_size;
int sbs = test_params.subgroup_size;
int non_uniform_size = gws % lws;
log_info(" sub_group_ballot...\n");
}
static test_status chk(Ty *x, Ty *y, Ty *mx, Ty *my, cl_int *m,
@@ -92,7 +97,6 @@ template <typename Ty> struct BALLOT
y += lws;
m += 4 * lws;
}
log_info(" sub_group_ballot... passed\n");
return TEST_PASS;
}
};
@@ -100,6 +104,13 @@ template <typename Ty> struct BALLOT
// Test for bit extract ballot functions
template <typename Ty, BallotOp operation> struct BALLOT_BIT_EXTRACT
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_ballot_%s(%s)...%s\n", operation_names(operation),
TypeManager<Ty>::name(), extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int wi_id, sb_id, wg_id, l;
@@ -110,8 +121,6 @@ template <typename Ty, BallotOp operation> struct BALLOT_BIT_EXTRACT
int wg_number = gws / lws;
int limit_sbs = sbs > 100 ? 100 : sbs;
int non_uniform_size = gws % lws;
log_info(" sub_group_%s(%s)...\n", operation_names(operation),
TypeManager<Ty>::name());
for (wg_id = 0; wg_id < wg_number; ++wg_id)
{ // for each work_group
@@ -251,21 +260,24 @@ template <typename Ty, BallotOp operation> struct BALLOT_BIT_EXTRACT
y += lws;
m += 4 * lws;
}
log_info(" sub_group_%s(%s)... passed\n", operation_names(operation),
TypeManager<Ty>::name());
return TEST_PASS;
}
};
template <typename Ty, BallotOp operation> struct BALLOT_INVERSE
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_inverse_ballot...%s\n", extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int gws = test_params.global_workgroup_size;
int lws = test_params.local_workgroup_size;
int sbs = test_params.subgroup_size;
int non_uniform_size = gws % lws;
log_info(" sub_group_inverse_ballot...\n");
// no work here
}
@@ -341,7 +353,6 @@ template <typename Ty, BallotOp operation> struct BALLOT_INVERSE
m += 4 * lws;
}
log_info(" sub_group_inverse_ballot... passed\n");
return TEST_PASS;
}
};
@@ -350,6 +361,13 @@ template <typename Ty, BallotOp operation> struct BALLOT_INVERSE
// Test for bit count/inclusive and exclusive scan/ find lsb msb ballot function
template <typename Ty, BallotOp operation> struct BALLOT_COUNT_SCAN_FIND
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_%s(%s)...%s\n", operation_names(operation),
TypeManager<Ty>::name(), extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int wi_id, wg_id, sb_id;
@@ -362,8 +380,6 @@ template <typename Ty, BallotOp operation> struct BALLOT_COUNT_SCAN_FIND
int last_subgroup_size = 0;
int current_sbs = 0;
log_info(" sub_group_%s(%s)...\n", operation_names(operation),
TypeManager<Ty>::name());
if (non_uniform_size)
{
wg_number++;
@@ -562,8 +578,6 @@ template <typename Ty, BallotOp operation> struct BALLOT_COUNT_SCAN_FIND
y += lws;
m += 4 * lws;
}
log_info(" sub_group_ballot_%s(%s)... passed\n",
operation_names(operation), TypeManager<Ty>::name());
return TEST_PASS;
}
};
@@ -571,6 +585,13 @@ template <typename Ty, BallotOp operation> struct BALLOT_COUNT_SCAN_FIND
// test mask functions
template <typename Ty, BallotOp operation> struct SMASK
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" get_sub_group_%s_mask...%s\n", operation_names(operation),
extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int wi_id, wg_id, l, sb_id;
@@ -579,7 +600,6 @@ template <typename Ty, BallotOp operation> struct SMASK
int sbs = test_params.subgroup_size;
int sb_number = (lws + sbs - 1) / sbs;
int wg_number = gws / lws;
log_info(" get_sub_group_%s_mask...\n", operation_names(operation));
for (wg_id = 0; wg_id < wg_number; ++wg_id)
{ // for each work_group
for (sb_id = 0; sb_id < sb_number; ++sb_id)
@@ -655,8 +675,6 @@ template <typename Ty, BallotOp operation> struct SMASK
y += lws;
m += 4 * lws;
}
log_info(" get_sub_group_%s_mask... passed\n",
operation_names(operation));
return TEST_PASS;
}
};

View File

@@ -38,15 +38,20 @@ __kernel void test_%s(const __global Type *in, __global int4 *xy, __global Type
// Test for reduce cluster functions
template <typename Ty, ArithmeticOp operation> struct RED_CLU
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_clustered_reduce_%s(%s, %d bytes) ...%s\n",
operation_names(operation), TypeManager<Ty>::name(),
sizeof(Ty), extra_text);
}
static void gen(Ty *x, Ty *t, cl_int *m, const WorkGroupParams &test_params)
{
int nw = test_params.local_workgroup_size;
int ns = test_params.subgroup_size;
int ng = test_params.global_workgroup_size;
ng = ng / nw;
log_info(" sub_group_clustered_reduce_%s(%s, %d bytes) ...\n",
operation_names(operation), TypeManager<Ty>::name(),
sizeof(Ty));
genrand<Ty, operation>(x, t, m, ns, nw, ng);
}
@@ -124,9 +129,6 @@ template <typename Ty, ArithmeticOp operation> struct RED_CLU
y += nw;
m += 4 * nw;
}
log_info(" sub_group_clustered_reduce_%s(%s, %d bytes) ... passed\n",
operation_names(operation), TypeManager<Ty>::name(),
sizeof(Ty));
return TEST_PASS;
}
};

View File

@@ -22,6 +22,15 @@ namespace {
template <typename T, NonUniformVoteOp operation> struct VOTE
{
static void log_test(const WorkGroupParams &test_params,
const char *extra_text)
{
log_info(" sub_group_%s%s(%s)...%s\n",
(operation == NonUniformVoteOp::elect) ? "" : "non_uniform_",
operation_names(operation), TypeManager<T>::name(),
extra_text);
}
static void gen(T *x, T *t, cl_int *m, const WorkGroupParams &test_params)
{
int i, ii, j, k, n;
@@ -34,10 +43,6 @@ template <typename T, NonUniformVoteOp operation> struct VOTE
int last_subgroup_size = 0;
ii = 0;
log_info(" sub_group_%s%s(%s)... \n",
(operation == NonUniformVoteOp::elect) ? "" : "non_uniform_",
operation_names(operation), TypeManager<T>::name());
if (operation == NonUniformVoteOp::elect) return;
for (k = 0; k < ng; ++k)
@@ -192,9 +197,6 @@ template <typename T, NonUniformVoteOp operation> struct VOTE
m += 4 * nw;
}
log_info(" sub_group_%s%s(%s)... passed\n",
(operation == NonUniformVoteOp::elect) ? "" : "non_uniform_",
operation_names(operation), TypeManager<T>::name());
return TEST_PASS;
}
};