Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick] Fix the race condition in cumsum operator (#42205) #42500

Merged
merged 1 commit into from
May 6, 2022
Merged
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
12 changes: 5 additions & 7 deletions paddle/phi/kernels/gpu/cumsum_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ __device__ void BlockReverse(
int tx = threadIdx.x;

int offset = tx;
int in_index = src_base + offset;
if (offset >= valid_item) {
sh_mem[offset] = 0;
} else {
int sh_mem_index = BLOCK_SIZE - offset - 1;
T data = idata[in_index];
sh_mem[sh_mem_index] = data;
T src_data = 0;
int src_offset = BLOCK_SIZE - offset - 1;
if (src_offset < valid_item) {
src_data = idata[src_base + src_offset];
}
sh_mem[offset] = src_data;

__syncthreads();
int out_index = dst_base - offset;
Expand Down