-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[mlir][spirv] Add spirv validation for module.mlir target test #153227
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
[mlir][spirv] Add spirv validation for module.mlir target test #153227
Conversation
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-spirv Author: Igor Wodiany (IgWod-IMG) ChangesCreating this patch as an example on using the new Full diff: https://github.com/llvm/llvm-project/pull/153227.diff 1 Files Affected:
diff --git a/mlir/test/Target/SPIRV/module.mlir b/mlir/test/Target/SPIRV/module.mlir
index dcdcab8097e41..e610001a3a71f 100644
--- a/mlir/test/Target/SPIRV/module.mlir
+++ b/mlir/test/Target/SPIRV/module.mlir
@@ -1,21 +1,29 @@
-// RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip -split-input-file %s | FileCheck %s
+// RUN: mlir-translate --no-implicit-module --test-spirv-roundtrip --split-input-file %s | FileCheck %s
+
+// REQUIRES: shell
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t && mlir-translate --no-implicit-module --serialize-spirv \ %}
+// RUN: %if spirv-tools %{ --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s \ %}
+// RUN: %if spirv-tools %{ && ls %t/module* | xargs -I{} bash -c 'spirv-val {}' %}
// CHECK: spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
// CHECK-NEXT: spirv.func @foo() "Inline" {
// CHECK-NEXT: spirv.Return
// CHECK-NEXT: }
+// CHECK-NEXT: spirv.EntryPoint "Vertex" @foo
// CHECK-NEXT: }
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
spirv.func @foo() -> () "Inline" {
spirv.Return
}
+ spirv.EntryPoint "Vertex" @foo
}
// -----
// CHECK: v1.5
-spirv.module Logical GLSL450 requires #spirv.vce<v1.5, [Shader], []> {
+spirv.module Logical GLSL450 requires #spirv.vce<v1.5, [Shader, Linkage], []> {
}
// -----
@@ -26,13 +34,13 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.6, [Shader, Linkage], []> {
// -----
-// CHECK: [Shader, Float16]
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Float16], []> {
+// CHECK: [Shader, Float16, Linkage]
+spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Float16, Linkage], []> {
}
// -----
// CHECK: [SPV_KHR_float_controls, SPV_KHR_subgroup_vote]
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], [SPV_KHR_float_controls, SPV_KHR_subgroup_vote]> {
+spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], [SPV_KHR_float_controls, SPV_KHR_subgroup_vote]> {
}
|
|
One more thing. Do we want to use the I'll also update the SPIR-V dialect documentation once this PR is merged to make it clear in the contributions section that Target tests need to be validated. |
kuhar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see it caught legitimate issues already
mlir/test/Target/SPIRV/module.mlir
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we specify the extension?
Also, why not xargs -I{} spirv-val {}?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by the extension?
Also, why not xargs -I{} spirv-val {}?
Good point, I'll simplfy it. The current code was an evolution of various attempts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File extension like .spv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To have an extension I need to update the logic that writes files. I created a seperate PR #153440 for that.
I think it's fine to have xargs / for loop in a single test like this one, but I wouldn't use it elsewhere until spirv-val learns to take directories. |
Creating this patch as an example on using the new `mlir-translate` flag. Eventually all the tests will be updated to validate SPIR-V modules.
fce65ed to
e4decc3
Compare
|
I had to replace: with the code below, where every command occupies a single |
Creating this patch as an example on using the new
mlir-translateflag. Eventually all tests will be updated to validate SPIR-V modules.