From e121b9d1bf0380a9d0468686e79ac1b4057857b8 Mon Sep 17 00:00:00 2001 From: Stuart Brady Date: Mon, 4 Apr 2022 17:57:36 +0100 Subject: [PATCH] Fix sub_group_ballot_find_msb/lsb tests (#1411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per the OpenCL Extension Specification ยง 38.6 Ballots: If no bits representing predicate values from all work items in the subgroup are set in the bitfield value then the return value is undefined. The case with no bits set is still worth testing, as it does not result in undefined behavior, but only an undefined return value. Signed-off-by: Stuart Brady --- test_conformance/subgroups/test_subgroup_ballot.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test_conformance/subgroups/test_subgroup_ballot.cpp b/test_conformance/subgroups/test_subgroup_ballot.cpp index 4148707e..b1e6944f 100644 --- a/test_conformance/subgroups/test_subgroup_ballot.cpp +++ b/test_conformance/subgroups/test_subgroup_ballot.cpp @@ -609,6 +609,12 @@ template struct BALLOT_COUNT_SCAN_FIND } else if (operation == BallotOp::ballot_find_lsb) { + if (bs.none()) + { + // Return value is undefined when no bits are set, + // so skip validation: + continue; + } for (int id = 0; id < sbs; ++id) { if (bs.test(id)) @@ -630,6 +636,12 @@ template struct BALLOT_COUNT_SCAN_FIND } else if (operation == BallotOp::ballot_find_msb) { + if (bs.none()) + { + // Return value is undefined when no bits are set, + // so skip validation: + continue; + } for (int id = sbs - 1; id >= 0; --id) { if (bs.test(id))