Skip to content

[spirv] Add fast math support for WebGPU - #10352

Merged
antiagainst merged 3 commits into
iree-org:mainfrom
antiagainst:spirv-fast-math
Sep 13, 2022
Merged

antiagainst merged 3 commits into
iree-org:mainfrom
antiagainst:spirv-fast-math

Conversation

@antiagainst

Copy link
Copy Markdown
Member

This exposes a control when building the SPIR-V CodeGen pipeline to allow enabling fast math mode, which will let patterns to assume no NaN/infinity floating point values. This matches the behavoir of WebGPU.

This exposes a control when building the SPIR-V CodeGen pipeline
to allow enabling fast math mode, which will let patterns to
assume no NaN/infinity floating point values. This matches the
behavoir of WebGPU.
@antiagainst
antiagainst marked this pull request as draft September 9, 2022 19:05

@MaheshRavishankar MaheshRavishankar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome! This looks great! @dcaballe and @vmurali we need something similar on the CPU side as well (probably plumbed through in a similar way.

/// GPU processor ID ops into SPIR-V global variables, loop/standard ops into
/// corresponding SPIR-V ops.
std::unique_ptr<OperationPass<ModuleOp>> createConvertToSPIRVPass();
std::unique_ptr<OperationPass<ModuleOp>> createConvertToSPIRVPass(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Wondering if we want to wait for this to be in IREE llvm/llvm-project@67d0d7a .

I dont know the details, but is related to this issue llvm/llvm-project#53145 . That might allow using the MLIR pass options and auto-generated create methods....

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That seems to be orthogonal infra changes to this. We can convert everything after that landed.


void buildTranslationPassPipeline(OpPassManager &passManager) override {
buildSPIRVCodegenPassPipeline(passManager);
buildSPIRVCodegenPassPipeline(passManager, /*enableFastMath=*/true);

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 comment here with some context for why WebGPU wants fast math? You could link to #10142, some gpuweb issues, and/or the webgpu spec.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yup, added comments there.

@ScottTodd ScottTodd added codegen/spirv SPIR-V code generation compiler backend platform/web 🌐 Web-specific build, execution, benchmarking, and deployment labels Sep 12, 2022
@antiagainst
antiagainst marked this pull request as ready for review September 12, 2022 22:21
@antiagainst
antiagainst enabled auto-merge (squash) September 12, 2022 22:22
@antiagainst
antiagainst merged commit 66036b4 into iree-org:main Sep 13, 2022
@antiagainst
antiagainst deleted the spirv-fast-math branch September 13, 2022 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen/spirv SPIR-V code generation compiler backend platform/web 🌐 Web-specific build, execution, benchmarking, and deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants