Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ __global__ void split_q_block(const int *__restrict__ seq_lens_q,
const int num_rows_per_block,
const int group_size) {
// one block one warp
const int lane_id = threadIdx.x % warpSize;
const int lane_id = threadIdx.x % WARP_SIZE;
int prev_offset = 0;

// loop on warp tile:[base, base+32)
for (int base = 0; base < bsz; base += warpSize) {
for (int base = 0; base < bsz; base += WARP_SIZE) {
const int bid = base + lane_id;

// calculate loop_times for bid
Expand All @@ -199,13 +199,13 @@ __global__ void split_q_block(const int *__restrict__ seq_lens_q,
// prefix sum for each lane, get the start offset in this tile
// inclusive scan
int x = loop_times;
for (int offset = 1; offset < warpSize; offset <<= 1) {
for (int offset = 1; offset < WARP_SIZE; offset <<= 1) {
int y = __shfl_up_sync(0xffffffff, x, offset);
if (lane_id >= offset) x += y;
}
// exclusive prefix sum
int bid_offset = x - loop_times;
int tile_sum = __shfl_sync(0xffffffff, x, warpSize - 1);
int tile_sum = __shfl_sync(0xffffffff, x, WARP_SIZE - 1);

// write batch_ids and tile_ids_per_batch
if (bid < bsz && loop_times > 0) {
Expand Down
6 changes: 3 additions & 3 deletions custom_ops/gpu_ops/get_padding_offset.cu
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ __global__ void PrefixSumKernel(int64_t *ids_remove_padding,
int cum_seq_len = 0;

// compute sum of seq_lens[0,1,2,...,bi]
for (int i = lane_id; i < bi + 1; i += warpSize) {
for (int i = lane_id; i < bi + 1; i += WARP_SIZE) {
cum_seq_len += seq_lens[i];
}

for (int offset = 1; offset < warpSize; offset <<= 1) {
for (int offset = 1; offset < WARP_SIZE; offset <<= 1) {
const int tmp = __shfl_up_sync(0xffffffff, cum_seq_len, offset);
if (lane_id >= offset) cum_seq_len += tmp;
}

cum_seq_len = __shfl_sync(0xffffffff, cum_seq_len, warpSize - 1);
cum_seq_len = __shfl_sync(0xffffffff, cum_seq_len, WARP_SIZE - 1);

if (tid == 0) {
cu_seqlens_q[bi + 1] = cum_seq_len;
Expand Down
Loading
Loading