Skip to content

[mlir][SPIRV] Add spirv.vce when create spirv.module in GPUToSPIRV #147267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oojahooo
Copy link

@oojahooo oojahooo commented Jul 7, 2025

In GPUToSPIRV conversion, we can pass the spirv.vce triple obtained from spirv.target_env when creating a spirv.module in GPUModuleConversion::matchAndRewrite because spirv.target_env must derived by executing lookupTargetEnvOrDefault

In GPUToSPIRV conversion, pass the `spirv.vce` triple obtained from
`spirv.target_env` when creating a `spirv.module` in
`GPUModuleConversion::matchAndRewrite`
Copy link

github-actions bot commented Jul 7, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jul 7, 2025

@llvm/pr-subscribers-mlir-spirv

@llvm/pr-subscribers-mlir

Author: Jaeho Kim (oojahooo)

Changes

In GPUToSPIRV conversion, we can pass the spirv.vce triple obtained from spirv.target_env when creating a spirv.module in GPUModuleConversion::matchAndRewrite because spirv.target_env must derived by executing lookupTargetEnvOrDefault


Full diff: https://github.com/llvm/llvm-project/pull/147267.diff

1 Files Affected:

  • (modified) mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp (+2-2)
diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
index b99ed261ecfa3..9c9afef8c226f 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
@@ -368,8 +368,8 @@ LogicalResult GPUModuleConversion::matchAndRewrite(
   // Add a keyword to the module name to avoid symbolic conflict.
   std::string spvModuleName = (kSPIRVModule + moduleOp.getName()).str();
   auto spvModule = rewriter.create<spirv::ModuleOp>(
-      moduleOp.getLoc(), addressingModel, *memoryModel, std::nullopt,
-      StringRef(spvModuleName));
+      moduleOp.getLoc(), addressingModel, *memoryModel,
+      targetEnv.getAttr().getTripleAttr(), StringRef(spvModuleName));
 
   // Move the region from the module op into the SPIR-V module.
   Region &spvModuleRegion = spvModule.getRegion();

@llvmbot
Copy link
Member

llvmbot commented Jul 7, 2025

@llvm/pr-subscribers-mlir-gpu

Author: Jaeho Kim (oojahooo)

Changes

In GPUToSPIRV conversion, we can pass the spirv.vce triple obtained from spirv.target_env when creating a spirv.module in GPUModuleConversion::matchAndRewrite because spirv.target_env must derived by executing lookupTargetEnvOrDefault


Full diff: https://github.com/llvm/llvm-project/pull/147267.diff

1 Files Affected:

  • (modified) mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp (+2-2)
diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
index b99ed261ecfa3..9c9afef8c226f 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
@@ -368,8 +368,8 @@ LogicalResult GPUModuleConversion::matchAndRewrite(
   // Add a keyword to the module name to avoid symbolic conflict.
   std::string spvModuleName = (kSPIRVModule + moduleOp.getName()).str();
   auto spvModule = rewriter.create<spirv::ModuleOp>(
-      moduleOp.getLoc(), addressingModel, *memoryModel, std::nullopt,
-      StringRef(spvModuleName));
+      moduleOp.getLoc(), addressingModel, *memoryModel,
+      targetEnv.getAttr().getTripleAttr(), StringRef(spvModuleName));
 
   // Move the region from the module op into the SPIR-V module.
   Region &spvModuleRegion = spvModule.getRegion();

Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

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

Can you add a test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants