From 9bbab539de6ee30676e3a4af1249ba91d0b6c5ed Mon Sep 17 00:00:00 2001 From: Yilong Guo Date: Thu, 23 Mar 2023 13:55:43 +0800 Subject: [PATCH] [subgroups][non_uniform_broadcast] Fix broadcasting index generation The subgroup size may not be greater than `NR_OF_ACTIVE_WORK_ITEMS`. Broadcasting index needs to be reduced in that case. Otherwise, if subgroup size == `NR_OF_ACTIVE_WORK_ITEMS` == 4, then we will encounter "divide-by-zero" error when evaluating `bcast_index % (n - NR_OF_ACTIVE_WORK_ITEMS)`. --- test_conformance/subgroups/subgroup_common_templates.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test_conformance/subgroups/subgroup_common_templates.h b/test_conformance/subgroups/subgroup_common_templates.h index f779ef37..436b502b 100644 --- a/test_conformance/subgroups/subgroup_common_templates.h +++ b/test_conformance/subgroups/subgroup_common_templates.h @@ -82,7 +82,7 @@ template struct BC // broadcasted (one the same value for whole subgroup) if (operation != SubgroupsBroadcastOp::broadcast) { - // reduce brodcasting index in case of non_uniform and + // reduce broadcasting index in case of non_uniform and // last workgroup last subgroup if (last_subgroup_size && j == nj - 1 && last_subgroup_size < NR_OF_ACTIVE_WORK_ITEMS) @@ -90,6 +90,13 @@ template struct BC bcast_if = bcast_index % last_subgroup_size; bcast_elseif = bcast_if; } + // reduce broadcasting index in case subgroup size <= + // NR_OF_ACTIVE_WORK_ITEMS (i.e. all items are active) + else if (n <= NR_OF_ACTIVE_WORK_ITEMS) + { + bcast_if = bcast_index % n; + bcast_elseif = bcast_if; + } else { bcast_if = bcast_index % NR_OF_ACTIVE_WORK_ITEMS;