[libc-commits] [libc] b5cd8c3 - [libc] Fix leader calculation when done in wave64 mode
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Thu Jul 31 19:26:51 PDT 2025
Author: Joseph Huber
Date: 2025-07-31T21:26:31-05:00
New Revision: b5cd8c34a74733763fdc9c5b1386a75c13c155b8
URL: https://github.com/llvm/llvm-project/commit/b5cd8c34a74733763fdc9c5b1386a75c13c155b8
DIFF: https://github.com/llvm/llvm-project/commit/b5cd8c34a74733763fdc9c5b1386a75c13c155b8.diff
LOG: [libc] Fix leader calculation when done in wave64 mode
Summary:
Wave 64 mode touches the upper limit of this, which had an off-by-one
error. This caused it to return the same leader which gave an invalid
view of memory.
Added:
Modified:
libc/src/__support/GPU/allocator.cpp
Removed:
################################################################################
diff --git a/libc/src/__support/GPU/allocator.cpp b/libc/src/__support/GPU/allocator.cpp
index bd0a55cb938fb..250bebdbb7d81 100644
--- a/libc/src/__support/GPU/allocator.cpp
+++ b/libc/src/__support/GPU/allocator.cpp
@@ -156,7 +156,7 @@ static inline constexpr uint32_t get_start_index(uint32_t chunk_size) {
// Returns the id of the lane below this one that acts as its leader.
static inline uint32_t get_leader_id(uint64_t ballot, uint32_t id) {
- uint64_t mask = id < BITS_IN_DWORD ? ~0ull << (id + 1) : 0;
+ uint64_t mask = id < BITS_IN_DWORD - 1 ? ~0ull << (id + 1) : 0;
return BITS_IN_DWORD - cpp::countl_zero(ballot & ~mask) - 1;
}
More information about the libc-commits
mailing list