Add missing __syncwarp() in reduce kernel + CUDA 13.0 build fix#15
Merged
JeffreyXiang merged 2 commits intoJeffreyXiang:mainfrom Mar 11, 2026
Merged
Conversation
The warp-level reduction loop in reduce_code_cuda_kernel reads from shared memory at buf[threadIdx.x + cur_len] after a prior iteration wrote to buf[threadIdx.x]. Without __syncwarp(), there is no guarantee that the write is visible to other threads in the warp before the next iteration reads it. While current NVIDIA hardware executes warps in lockstep, this is undefined behavior per the CUDA programming model and may break on future architectures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CUDA 13.0 with MSVC 2025 (Visual Studio 18) fails to compile without this flag, as nvcc only officially supports MSVC 2019-2022. The flag allows compilation on newer toolchains without affecting runtime behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
This may also address:
|
Owner
|
Thanks! Merged |
Contributor
Author
|
Happy to contribute - thanks for your work on this! |
This was referenced Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes discovered while debugging Trellis2 on NVIDIA Blackwell (RTX 5090, sm_120):
1. Missing
__syncwarp()in warp-level reductionreduce_code_cuda_kernelinneighbor_map.cuperforms a warp-level reduction over shared memory without__syncwarp()between iterations. Each iteration readsbuf[threadIdx.x + cur_len]after the prior iteration wrote tobuf[threadIdx.x]. Without a warp barrier, there is no guarantee the write is visible to other threads before the next read.While current NVIDIA hardware executes warps in lockstep, this is undefined behavior per the CUDA programming model and may break on future architectures.
2.
-allow-unsupported-compilerfor CUDA 13.0CUDA 13.0 with MSVC 2025 (Visual Studio 18) fails to compile without this flag, as nvcc only officially supports MSVC 2019-2022.
Testing