Skip to content

Commit a2f5ead

Browse files
jhuber6github-actions[bot]
authored andcommitted
Automerge: [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.
2 parents b261de3 + b5cd8c3 commit a2f5ead

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libc/src/__support/GPU/allocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static inline constexpr uint32_t get_start_index(uint32_t chunk_size) {
156156

157157
// Returns the id of the lane below this one that acts as its leader.
158158
static inline uint32_t get_leader_id(uint64_t ballot, uint32_t id) {
159-
uint64_t mask = id < BITS_IN_DWORD ? ~0ull << (id + 1) : 0;
159+
uint64_t mask = id < BITS_IN_DWORD - 1 ? ~0ull << (id + 1) : 0;
160160
return BITS_IN_DWORD - cpp::countl_zero(ballot & ~mask) - 1;
161161
}
162162

0 commit comments

Comments
 (0)