Lack of unrolling and very high register usage
@Firestar99 がすでに取り組んでいます。
2025年11月26日 から。
評価
この issue はまだ評価されていません。
説明
I have many places in the code that can be condensed to something like this:
const MAX_BUCKET_SIZE: usize = 512;
const WORKGROUP_SIZE: u32 = 256;
unsafe {
core::hint::assert_unchecked(matches_count <= MAX_BUCKET_SIZE);
}
for index in (local_invocation_id..matches_count as u32).step_by(WORKGROUP_SIZE as usize) {
Can also be rewritten in a way that will probably produce some helpful runtime code in SPIR-V since I suspect the hint will be lost in translation:
const MAX_BUCKET_SIZE: usize = 512;
const WORKGROUP_SIZE: u32 = 256;
for index in (local_invocation_id..matches_count.min(MAX_BUCKET_SIZE) as u32)
.step_by(WORKGROUP_SIZE as usize)
{
It is not difficult for me to see that there will be at most two loop iterations here per invocation. However, it is not something compiler sees today.
The result is much higher register usage, impacting occupancy in a big way.
Rewriting it to inner function that is called twice with explicit bounds checks fixes register usage (though I hit https://github.com/Rust-GPU/rust-gpu/issues/461 when doing so), but is far from idiomatic Rust and is quite painful to do manually in all such cases.
I wish end-to-end compilation chain was aware of things like this, it is a very important pattern for performance.
In fact loop unrolling is extremely bad right now, even fixed loops with 3-4 iterations and one or several simply ALU instructions in it are not unrolled and balloon register usage.
- 主要言語
- Rust
- スター
- 3.4k
- フォーク
- 126
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Rust-GPU/rust-gpu のほかの issue
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
-
enhancement
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
Rust-GPU/rust-gpu の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100