Skip to content

Vectorize mbarrier initialization in warpspeed scan - #8423

Merged
bernhardmgruber merged 2 commits into
NVIDIA:mainfrom
bernhardmgruber:ref_scan
Apr 15, 2026
Merged

bernhardmgruber merged 2 commits into
NVIDIA:mainfrom
bernhardmgruber:ref_scan

Conversation

@bernhardmgruber

@bernhardmgruber bernhardmgruber commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

[0] NVIDIA B200

T{ct} OffsetT{ct} Elements{io} Ref Time Ref Noise Cmp Time Cmp Noise Diff %Diff Status
I8 I64 2^16 11.284 us 4.37% 10.404 us 9.78% -0.881 us -7.81% 🟢 FAST
I8 I64 2^20 12.637 us 6.95% 12.232 us 8.28% -0.405 us -3.20% 🔵 SAME
I8 I64 2^24 27.189 us 2.98% 26.249 us 3.77% -0.940 us -3.46% 🟢 FAST
I8 I64 2^28 216.046 us 0.50% 215.908 us 0.51% -0.138 us -0.06% 🔵 SAME
I8 I64 2^32 3.228 ms 0.22% 3.240 ms 0.11% 12.728 us 0.39% 🔴 SLOW
I16 I64 2^16 11.099 us 0.85% 11.014 us 3.55% -0.085 us -0.77% 🔵 SAME
I16 I64 2^20 13.233 us 3.21% 13.155 us 3.40% -0.078 us -0.59% 🔵 SAME
I16 I64 2^24 31.521 us 5.19% 31.046 us 5.18% -0.475 us -1.51% 🔵 SAME
I16 I64 2^28 214.188 us 0.67% 214.029 us 0.68% -0.159 us -0.07% 🔵 SAME
I16 I64 2^32 3.237 ms 1.39% 3.238 ms 1.24% 1.405 us 0.04% 🔵 SAME
I32 I64 2^16 9.707 us 9.89% 9.304 us 7.74% -0.402 us -4.14% 🔵 SAME
I32 I64 2^20 13.705 us 6.52% 13.612 us 6.87% -0.092 us -0.67% 🔵 SAME
I32 I64 2^24 38.102 us 4.68% 37.646 us 4.59% -0.456 us -1.20% 🔵 SAME
I32 I64 2^28 321.954 us 0.55% 321.593 us 0.55% -0.360 us -0.11% 🔵 SAME
I32 I64 2^32 5.091 ms 1.21% 5.104 ms 1.03% 13.646 us 0.27% 🔵 SAME
I64 I64 2^16 11.283 us 1.20% 11.155 us 4.52% -0.127 us -1.13% 🔵 SAME
I64 I64 2^20 15.473 us 4.21% 15.286 us 2.35% -0.187 us -1.21% 🔵 SAME
I64 I64 2^24 60.226 us 2.01% 59.460 us 2.00% -0.765 us -1.27% 🔵 SAME
I64 I64 2^28 688.208 us 0.18% 687.991 us 0.17% -0.217 us -0.03% 🔵 SAME
I64 I64 2^32 11.264 ms 0.82% 11.246 ms 0.85% -18.469 us -0.16% 🔵 SAME
I128 I64 2^16 13.072 us 4.17% 12.725 us 7.03% -0.348 us -2.66% 🔵 SAME
I128 I64 2^20 25.119 us 4.18% 24.435 us 4.28% -0.685 us -2.73% 🔵 SAME
I128 I64 2^24 172.993 us 0.66% 172.755 us 0.69% -0.238 us -0.14% 🔵 SAME
I128 I64 2^28 2.521 ms 0.09% 2.520 ms 0.10% -0.871 us -0.03% 🔵 SAME
I128 I64 2^32 40.173 ms 0.02% 40.162 ms 0.02% -10.644 us -0.03% 🟢 FAST
F32 I64 2^16 10.094 us 10.29% 10.008 us 10.06% -0.086 us -0.85% 🔵 SAME
F32 I64 2^20 14.279 us 7.19% 14.439 us 7.10% 0.160 us 1.12% 🔵 SAME
F32 I64 2^24 41.303 us 3.51% 40.681 us 3.60% -0.622 us -1.51% 🔵 SAME
F32 I64 2^28 345.811 us 0.44% 344.699 us 0.45% -1.112 us -0.32% 🔵 SAME
F32 I64 2^32 5.222 ms 0.39% 5.218 ms 0.10% -4.265 us -0.08% 🔵 SAME
F64 I64 2^16 11.045 us 2.02% 11.020 us 2.68% -0.025 us -0.23% 🔵 SAME
F64 I64 2^20 15.549 us 3.84% 15.374 us 0.83% -0.175 us -1.12% 🟢 FAST
F64 I64 2^24 65.203 us 1.66% 64.440 us 1.69% -0.764 us -1.17% 🔵 SAME
F64 I64 2^28 779.808 us 0.15% 779.802 us 0.14% -0.006 us -0.00% 🔵 SAME
F64 I64 2^32 12.233 ms 0.01% 12.238 ms 0.01% 4.682 us 0.04% 🔴 SLOW
C32 I64 2^16 10.791 us 7.36% 10.687 us 8.76% -0.104 us -0.97% 🔵 SAME
C32 I64 2^20 15.241 us 1.60% 15.136 us 3.35% -0.105 us -0.69% 🔵 SAME
C32 I64 2^24 59.184 us 2.01% 58.248 us 1.59% -0.936 us -1.58% 🔵 SAME
C32 I64 2^28 682.193 us 0.17% 679.964 us 0.17% -2.229 us -0.33% 🟢 FAST
C32 I64 2^32 10.662 ms 0.02% 10.635 ms 0.02% -26.996 us -0.25% 🟢 FAST

Fixes: #7440

@github-actions

This comment has been minimized.

warpspeed::SmemAllocator smemAllocator{};
auto r = allocResources<PolicySelector, InputT, OutputT, AccumT>(syncHandler, smemAllocator, params.numStages);
syncHandler.clusterInitSync(specialRegisters);
syncHandler.clusterInitSync<num_total_threads(policy)>(specialRegisters);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love that this takes all available threads

uint64_t* ptrBar = mPtrBar[ri][pi];
int numOwningThreads = mNumOwningThreads[ri][pi];
// use block strided iteration to vectorize setup of barriers
for (int si = sr.threadIdxX; si < numStages; si += NumThreads)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of threads in the warpspeed implementation, why isnt this guarding against invalid access?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

si < numStages is the guard here. We have to initialize numStages barriers starting at ptrBar, so each thread with index smaller than numStages enters the loop. In the theoretical case that we have to initialize more than NumThreads barriers, all threads shift by NumThreads after the first loop iteration and then the shifted index (si) is checked again against numStages. I think we are fine.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 38m: Pass: 100%/269 | Total: 9d 02h | Max: 1h 31m | Hits: 70%/177314

See results here.

@bernhardmgruber
bernhardmgruber merged commit 7b7a480 into NVIDIA:main Apr 15, 2026
288 of 291 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Apr 15, 2026
@bernhardmgruber
bernhardmgruber deleted the ref_scan branch April 15, 2026 09:26
jainishmehta pushed a commit to jainishmehta/cccl that referenced this pull request Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Reduce code size of warpspeed scan kernel

2 participants