aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven van Haastregt <sven.vanhaastregt@arm.com>2024-04-04 15:12:10 +0200
committerGitHub <noreply@github.com>2024-04-04 15:12:10 +0200
commit48003e9d32cc9efb83ae194c0519270dc711852f (patch)
treed99674849d472302fe087cc0194d1caab27db5d3
parent7f1caf4aa9a44fe71bac8304018dabb4393e1407 (diff)
downloadOpenCL-CTS-48003e9d32cc9efb83ae194c0519270dc711852f.tar.gz
[NFC] subgroups: clarify bs128 to uint4 conversion (#1893)
There appears to have been some confusion over `uint_mask` during the initial reviews of the subgroup tests. Add a comment to clarify the purpose of the mask. Use a 32-bit all-ones mask (`0xffffffff`) instead of a 64-bit all-ones mask to further clarify the intent, that is, don't delay discarding the upper 32 bits until the assignment but mask them out immediately. Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1203 Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
-rw-r--r--test_conformance/subgroups/subhelpers.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/test_conformance/subgroups/subhelpers.cpp b/test_conformance/subgroups/subhelpers.cpp
index 0899ef9c..2e9753ff 100644
--- a/test_conformance/subgroups/subhelpers.cpp
+++ b/test_conformance/subgroups/subhelpers.cpp
@@ -102,8 +102,9 @@ cl_uint4 generate_bit_mask(cl_uint subgroup_local_id,
if (mask_type == "gt") mask128.reset(pos);
}
- // convert std::bitset<128> to uint4
- auto const uint_mask = bs128{ static_cast<unsigned long>(-1) };
+ // convert std::bitset<128> to uint4.
+ // Use a mask to avoid std::overflow_error from to_ulong().
+ auto const uint_mask = bs128{ 0xffffffff };
mask.s0 = (mask128 & uint_mask).to_ulong();
mask128 >>= 32;
mask.s1 = (mask128 & uint_mask).to_ulong();