Skip to content

Commit 4e604d4

Browse files
committed
[libc][NFC] Add u64 shuffle helpers to GPU
Summary: Precommit for later use.
1 parent 50316c1 commit 4e604d4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libc/src/__support/GPU/utils.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ LIBC_INLINE uint32_t shuffle(uint64_t lane_mask, uint32_t idx, uint32_t x,
9292
return __gpu_shuffle_idx_u32(lane_mask, idx, x, width);
9393
}
9494

95+
LIBC_INLINE uint64_t shuffle(uint64_t lane_mask, uint32_t idx, uint64_t x,
96+
uint32_t width = __gpu_num_lanes()) {
97+
return __gpu_shuffle_idx_u64(lane_mask, idx, x, width);
98+
}
99+
100+
template <typename T>
101+
LIBC_INLINE T *shuffle(uint64_t lane_mask, uint32_t idx, T *x,
102+
uint32_t width = __gpu_num_lanes()) {
103+
return reinterpret_cast<T *>(__gpu_shuffle_idx_u64(
104+
lane_mask, idx, reinterpret_cast<uintptr_t>(x), width));
105+
}
106+
95107
LIBC_INLINE uint64_t match_any(uint64_t lane_mask, uint32_t x) {
96108
return __gpu_match_any_u32(lane_mask, x);
97109
}

0 commit comments

Comments
 (0)