Skip to content

Commit c2c8644

Browse files
authored
[mlir][spirv] Fix UpdateVCEPass pass to deduce the correct version (#151192)
UpdateVCEPass currently deduces the required version based on vrsion requirement of ops. This fix adds a check to update the minimum required version based on capabilities as well. --------- Signed-off-by: Mohammadreza Ameri Mahabadian <[email protected]>
1 parent bf72bd6 commit c2c8644

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ void UpdateVCEPass::runOnOperation() {
174174
if (walkResult.wasInterrupted())
175175
return signalPassFailure();
176176

177+
// Update min version requirement for capabilities after deducing them.
178+
for (spirv::Capability cap : deducedCapabilities) {
179+
if (std::optional<spirv::Version> minVersion = spirv::getMinVersion(cap)) {
180+
deducedVersion = std::max(deducedVersion, *minVersion);
181+
if (deducedVersion > allowedVersion) {
182+
module.emitError("Capability '")
183+
<< spirv::stringifyCapability(cap) << "' requires min version "
184+
<< spirv::stringifyVersion(deducedVersion)
185+
<< " but target environment allows up to "
186+
<< spirv::stringifyVersion(allowedVersion);
187+
return signalPassFailure();
188+
}
189+
}
190+
}
191+
177192
// TODO: verify that the deduced version is consistent with
178193
// SPIR-V ops' maximal version requirements.
179194

mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ spirv.module Logical GLSL450 attributes {
178178
// Vulkan memory model requires SPV_KHR_vulkan_memory_model, which is enabled
179179
// implicitly by v1.5.
180180

181-
// CHECK: requires #spirv.vce<v1.0, [VulkanMemoryModel], [SPV_KHR_vulkan_memory_model]>
181+
// CHECK: requires #spirv.vce<v1.5, [VulkanMemoryModel], [SPV_KHR_vulkan_memory_model]>
182182
spirv.module Logical Vulkan attributes {
183183
spirv.target_env = #spirv.target_env<
184184
#spirv.vce<v1.5, [Shader, VulkanMemoryModel], []>, #spirv.resource_limits<>>

0 commit comments

Comments
 (0)