Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Codegen][GPU] Clean up prefetch pipeline stages flag to support integer values#23568

Merged
Yu-Zhewen merged 5 commits into
iree-org:mainfrom
Yu-Zhewen:num_stages_option
Feb 27, 2026
Merged

[Codegen][GPU] Clean up prefetch pipeline stages flag to support integer values#23568
Yu-Zhewen merged 5 commits into
iree-org:mainfrom
Yu-Zhewen:num_stages_option

Conversation

@Yu-Zhewen
Copy link
Copy Markdown
Contributor

@Yu-Zhewen Yu-Zhewen commented Feb 24, 2026

Replaces the boolean --iree-llvmgpu-enable-prefetch flag with an integer --iree-llvmgpu-prefetch-num-stages flag backed by std::optional<uint64_t>. When unset (default), each code path uses its own heuristic default. 0 or 1 disables pipelining, and 2+ enables pipelining with the specified number of stages.

ci-extra: test_torch

Signed-off-by: Yu-Zhewen <[email protected]>
Comment thread compiler/src/iree/compiler/Codegen/Dialect/GPU/TargetUtils/ConfigUtils.cpp Outdated
Comment thread compiler/src/iree/compiler/Codegen/LLVMGPU/KernelConfig.cpp Outdated
Signed-off-by: Yu-Zhewen <[email protected]>
@Yu-Zhewen Yu-Zhewen requested a review from benvanik as a code owner February 24, 2026 23:09
Signed-off-by: Yu-Zhewen <[email protected]>
precompile,
};

struct BytecodeVersionParser : public llvm::cl::parser<std::optional<int64_t>> {
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 am not sure if this needs to remove?

Copy link
Copy Markdown
Contributor Author

@Yu-Zhewen Yu-Zhewen Feb 25, 2026

Choose a reason for hiding this comment

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

Code changed. BytecodeVersionParser is now left untouched in its original location

kuhar
kuhar previously approved these changes Feb 25, 2026
//===----------------------------------------------------------------------===//
LogicalResult initGPULaunchConfig(FunctionOpInterface funcOp,
const GPUCodegenOptions &gpuOpts) {
LogicalResult initGPULaunchConfig(FunctionOpInterface funcOp) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a guard in this routine, where all config setting logic start from, to enforce that the pipeline number of state is non-negative? This comment is motivated from @lialan 's previous comment.

A negative stage count won't do any damage because we'd guard it later in the lowering pipeline. But still I believe the current state as-is a negative value will be silently accepted and materialized in IR like (prefetch_num_stages=-1), which is odd.

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.

I am now using std::optional<int64_t>, as @lialan previously suggested.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume using std::optional<int64_t> does not solve the negative value problem? The type int64_t is signed, std::optional doesn't constrain the range. You can still pass --iree-llvmgpu-prefetch-num-stages=-3 and it will happily parse into std::optional<int64_t>(-3) and materialize as prefetch_num_stages = -3 in the IR.

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.

Good point. Negative values are now rejected at parse time.

Signed-off-by: Yu-Zhewen <[email protected]>
Comment thread compiler/src/iree/compiler/Utils/OptionUtils.h Outdated
@kuhar kuhar dismissed their stale review February 26, 2026 00:45

code changed

Signed-off-by: Yu-Zhewen <[email protected]>
@Yu-Zhewen Yu-Zhewen merged commit c18957b into iree-org:main Feb 27, 2026
56 of 62 checks passed
kimm240 pushed a commit to kimm240/iree that referenced this pull request May 8, 2026
…ger values (iree-org#23568)

Replaces the boolean `--iree-llvmgpu-enable-prefetch` flag with an
integer `--iree-llvmgpu-prefetch-num-stages` flag backed by
std::optional<uint64_t>. When unset (default), each code path uses its
own heuristic default. 0 or 1 disables pipelining, and 2+ enables
pipelining with the specified number of stages.

ci-extra: test_torch

---------

Signed-off-by: Yu-Zhewen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants