Skip to content

Warpspeed micro optimizations - #8418

Merged
bernhardmgruber merged 5 commits into
NVIDIA:mainfrom
bernhardmgruber:warpspeed_micro_opt
Apr 15, 2026
Merged

bernhardmgruber merged 5 commits into
NVIDIA:mainfrom
bernhardmgruber:warpspeed_micro_opt

Conversation

@bernhardmgruber

@bernhardmgruber bernhardmgruber commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Adds two micro optimizations

  • Avoids a bulk copy for storing of zero size (reverted, causes a bug)
  • limits the scope of the SyncHandler and SmemAllocator
  • setup scan resources before dispatch

And a bonus refactoring of some constants at the kernel start.

The SASS changes a bit, the kernel now has a few instructions less.

## [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.229 us |       3.26% |  11.284 us |       4.37% |   0.056 us |   0.50% |   SAME   |
|   I8    |      I64      |      2^20      |  12.645 us |       6.92% |  12.637 us |       6.95% |  -0.008 us |  -0.06% |   SAME   |
|   I8    |      I64      |      2^24      |  27.022 us |       3.55% |  27.189 us |       2.98% |   0.167 us |   0.62% |   SAME   |
|   I8    |      I64      |      2^28      | 217.644 us |       0.52% | 216.046 us |       0.50% |  -1.598 us |  -0.73% |   FAST   |
|   I8    |      I64      |      2^32      |   3.258 ms |       0.23% |   3.228 ms |       0.22% | -30.251 us |  -0.93% |   FAST   |
|   I16   |      I64      |      2^16      |  11.096 us |       0.94% |  11.099 us |       0.85% |   0.003 us |   0.03% |   SAME   |
|   I16   |      I64      |      2^20      |  13.219 us |       3.12% |  13.233 us |       3.21% |   0.014 us |   0.11% |   SAME   |
|   I16   |      I64      |      2^24      |  31.853 us |       5.01% |  31.521 us |       5.19% |  -0.331 us |  -1.04% |   SAME   |
|   I16   |      I64      |      2^28      | 213.988 us |       0.63% | 214.188 us |       0.67% |   0.200 us |   0.09% |   SAME   |
|   I16   |      I64      |      2^32      |   3.233 ms |       1.20% |   3.237 ms |       1.39% |   3.535 us |   0.11% |   SAME   |
|   I32   |      I64      |      2^16      |   9.747 us |       9.91% |   9.707 us |       9.89% |  -0.041 us |  -0.42% |   SAME   |
|   I32   |      I64      |      2^20      |  13.457 us |       6.09% |  13.705 us |       6.52% |   0.248 us |   1.84% |   SAME   |
|   I32   |      I64      |      2^24      |  38.227 us |       3.92% |  38.102 us |       4.68% |  -0.125 us |  -0.33% |   SAME   |
|   I32   |      I64      |      2^28      | 321.791 us |       0.55% | 321.954 us |       0.55% |   0.162 us |   0.05% |   SAME   |
|   I32   |      I64      |      2^32      |   5.102 ms |       1.13% |   5.091 ms |       1.21% | -11.281 us |  -0.22% |   SAME   |
|   I64   |      I64      |      2^16      |  11.258 us |       2.17% |  11.283 us |       1.20% |   0.025 us |   0.22% |   SAME   |
|   I64   |      I64      |      2^20      |  15.440 us |       3.81% |  15.473 us |       4.21% |   0.033 us |   0.21% |   SAME   |
|   I64   |      I64      |      2^24      |  60.081 us |       1.87% |  60.226 us |       2.01% |   0.145 us |   0.24% |   SAME   |
|   I64   |      I64      |      2^28      | 686.874 us |       0.17% | 688.208 us |       0.18% |   1.334 us |   0.19% |   SLOW   |
|   I64   |      I64      |      2^32      |  11.260 ms |       0.91% |  11.264 ms |       0.82% |   4.273 us |   0.04% |   SAME   |
|  I128   |      I64      |      2^16      |  13.035 us |       4.73% |  13.072 us |       4.17% |   0.038 us |   0.29% |   SAME   |
|  I128   |      I64      |      2^20      |  25.355 us |       3.60% |  25.119 us |       4.18% |  -0.236 us |  -0.93% |   SAME   |
|  I128   |      I64      |      2^24      | 173.144 us |       0.73% | 172.993 us |       0.66% |  -0.152 us |  -0.09% |   SAME   |
|  I128   |      I64      |      2^28      |   2.521 ms |       0.10% |   2.521 ms |       0.09% |   0.282 us |   0.01% |   SAME   |
|  I128   |      I64      |      2^32      |  40.175 ms |       0.02% |  40.173 ms |       0.02% |  -2.604 us |  -0.01% |   SAME   |
|   F32   |      I64      |      2^16      |  10.074 us |      10.46% |  10.094 us |      10.29% |   0.020 us |   0.20% |   SAME   |
|   F32   |      I64      |      2^20      |  14.327 us |       7.49% |  14.279 us |       7.19% |  -0.048 us |  -0.34% |   SAME   |
|   F32   |      I64      |      2^24      |  41.153 us |       3.55% |  41.303 us |       3.51% |   0.150 us |   0.37% |   SAME   |
|   F32   |      I64      |      2^28      | 345.244 us |       0.44% | 345.811 us |       0.44% |   0.567 us |   0.16% |   SAME   |
|   F32   |      I64      |      2^32      |   5.216 ms |       0.41% |   5.222 ms |       0.39% |   6.299 us |   0.12% |   SAME   |
|   F64   |      I64      |      2^16      |  11.054 us |       2.08% |  11.045 us |       2.02% |  -0.009 us |  -0.08% |   SAME   |
|   F64   |      I64      |      2^20      |  15.546 us |       3.82% |  15.549 us |       3.84% |   0.003 us |   0.02% |   SAME   |
|   F64   |      I64      |      2^24      |  64.794 us |       1.50% |  65.203 us |       1.66% |   0.409 us |   0.63% |   SAME   |
|   F64   |      I64      |      2^28      | 778.715 us |       0.14% | 779.808 us |       0.15% |   1.093 us |   0.14% |   SAME   |
|   F64   |      I64      |      2^32      |  12.223 ms |       0.01% |  12.233 ms |       0.01% |   9.897 us |   0.08% |   SLOW   |
|   C32   |      I64      |      2^16      |  10.818 us |       7.21% |  10.791 us |       7.36% |  -0.027 us |  -0.25% |   SAME   |
|   C32   |      I64      |      2^20      |  15.224 us |       2.23% |  15.241 us |       1.60% |   0.017 us |   0.11% |   SAME   |
|   C32   |      I64      |      2^24      |  59.083 us |       2.06% |  59.184 us |       2.01% |   0.101 us |   0.17% |   SAME   |
|   C32   |      I64      |      2^28      | 682.631 us |       0.17% | 682.193 us |       0.17% |  -0.438 us |  -0.06% |   SAME   |
|   C32   |      I64      |      2^32      |  10.670 ms |       0.02% |  10.662 ms |       0.02% |  -8.215 us |  -0.08% |   FAST   |

@bernhardmgruber
bernhardmgruber requested a review from a team as a code owner April 14, 2026 19:39
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Apr 14, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Apr 14, 2026
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 35m: Pass: 100%/269 | Total: 8d 07h | Max: 1h 28m | Hits: 74%/177308

See results here.

Comment on lines +290 to +294
static constexpr int tile_size = policy.tile_size();
static constexpr int look_ahead_items_per_thread = policy.look_ahead_items_per_thread;

// We might try to instantiate the kernel with hughe types which would lead to a small tile size. Ensure its never 0
constexpr int elemPerThread = policy.items_per_thread;
// We might try to instantiate the kernel with huge types which would lead to a small tile size. Ensure its never 0
static constexpr int elemPerThread = policy.items_per_thread;

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.

Q: Does static make a difference?

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.

Not here. It does sometimes, like when the variable is later used in a lambda you don't need to capture it, etc. Also, the color is nicer in CLion.

@bernhardmgruber
bernhardmgruber merged commit 6bcb155 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 warpspeed_micro_opt branch April 15, 2026 07:10
jainishmehta pushed a commit to jainishmehta/cccl that referenced this pull request Apr 19, 2026
* Create syncHandler amd smemAllocator temporarily
* Refactor constants
* Setup scan resources before dispatch
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.

2 participants