Skip to content

Commit efa7385

Browse files
authored
[mlir][spirv] Fix entry point, logical ops and sampled image Target tests (#159376)
For the entry point an incorrect combination of execution model and mode was used as well as arguments were specified for the entry function (the function should take no arguments). For logical ops the test was failing as using scalar condition with vector objects are not supported in spv1.0. Sampled image test was using incorrect *Sampled* and *Dim* values. Sampled images need to have *Sampled* operand of 0 or 1, but not 2 (`NoSampler`), and `SubpassData` is not allowed.
1 parent 1aded51 commit efa7385

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
// RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip -split-input-file %s | FileCheck %s
22

3-
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
3+
// RUN: %if spirv-tools %{ rm -rf %t %}
4+
// RUN: %if spirv-tools %{ mkdir %t %}
5+
// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
6+
// RUN: %if spirv-tools %{ spirv-val %t %}
7+
8+
spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel], []> {
49
spirv.func @noop() -> () "None" {
510
spirv.Return
611
}
7-
// CHECK: spirv.EntryPoint "GLCompute" @noop
12+
// CHECK: spirv.EntryPoint "Kernel" @noop
813
// CHECK-NEXT: spirv.ExecutionMode @noop "ContractionOff"
9-
spirv.EntryPoint "GLCompute" @noop
14+
spirv.EntryPoint "Kernel" @noop
1015
spirv.ExecutionMode @noop "ContractionOff"
1116
}
1217

@@ -15,13 +20,13 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
1520
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
1621
// CHECK: spirv.GlobalVariable @var2 : !spirv.ptr<f32, Input>
1722
// CHECK-NEXT: spirv.GlobalVariable @var3 : !spirv.ptr<f32, Output>
18-
// CHECK-NEXT: spirv.func @noop({{%.*}}: !spirv.ptr<f32, Input>, {{%.*}}: !spirv.ptr<f32, Output>) "None"
23+
// CHECK-NEXT: spirv.func @noop() "None"
1924
// CHECK: spirv.EntryPoint "GLCompute" @noop, @var2, @var3
2025
spirv.GlobalVariable @var2 : !spirv.ptr<f32, Input>
2126
spirv.GlobalVariable @var3 : !spirv.ptr<f32, Output>
22-
spirv.func @noop(%arg0 : !spirv.ptr<f32, Input>, %arg1 : !spirv.ptr<f32, Output>) -> () "None" {
27+
spirv.func @noop() -> () "None" {
2328
spirv.Return
2429
}
2530
spirv.EntryPoint "GLCompute" @noop, @var2, @var3
26-
spirv.ExecutionMode @noop "ContractionOff"
31+
spirv.ExecutionMode @noop "LocalSize", 1, 1, 1
2732
}

mlir/test/Target/SPIRV/logical-ops.mlir

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// RUN: mlir-translate -no-implicit-module -split-input-file -test-spirv-roundtrip %s | FileCheck %s
22

3-
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
3+
// RUN: %if spirv-tools %{ rm -rf %t %}
4+
// RUN: %if spirv-tools %{ mkdir %t %}
5+
// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
6+
// RUN: %if spirv-tools %{ spirv-val %t %}
7+
8+
spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel, Linkage], []> {
49
spirv.func @iequal_scalar(%arg0: i32, %arg1: i32) "None" {
510
// CHECK: {{.*}} = spirv.IEqual {{.*}}, {{.*}} : i32
611
%0 = spirv.IEqual %arg0, %arg1 : i32
@@ -92,7 +97,7 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
9297

9398
// -----
9499

95-
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
100+
spirv.module Logical GLSL450 requires #spirv.vce<v1.4, [Shader, Linkage], []> {
96101
spirv.SpecConstant @condition_scalar = true
97102
spirv.func @select() -> () "None" {
98103
%0 = spirv.Constant 4.0 : f32
@@ -115,7 +120,7 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
115120

116121
// Test select works with bf16 scalar and vectors.
117122

118-
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
123+
spirv.module Logical GLSL450 requires #spirv.vce<v1.4, [Shader, Linkage, BFloat16TypeKHR], [SPV_KHR_bfloat16]> {
119124
spirv.SpecConstant @condition_scalar = true
120125
spirv.func @select_bf16() -> () "None" {
121126
%0 = spirv.Constant 4.0 : bf16

mlir/test/Target/SPIRV/sampled-image.mlir

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s
22

3-
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
4-
// CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, UniformConstant>
5-
spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, UniformConstant>
3+
// RUN: %if spirv-tools %{ rm -rf %t %}
4+
// RUN: %if spirv-tools %{ mkdir %t %}
5+
// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
6+
// RUN: %if spirv-tools %{ spirv-val %t %}
67

7-
// CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, SubpassData, DepthUnknown, Arrayed, MultiSampled, NoSampler, Unknown>>, UniformConstant>
8-
spirv.GlobalVariable @var1 bind(0, 0) : !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, SubpassData, DepthUnknown, Arrayed, MultiSampled, NoSampler, Unknown>>, UniformConstant>
8+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Sampled1D, SampledRect, StorageImageExtendedFormats, Linkage], []> {
9+
// CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NeedSampler, Unknown>>, UniformConstant>
10+
spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NeedSampler, Unknown>>, UniformConstant>
11+
12+
// CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, Cube, DepthUnknown, Arrayed, MultiSampled, NeedSampler, Unknown>>, UniformConstant>
13+
spirv.GlobalVariable @var1 bind(0, 0) : !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, Cube, DepthUnknown, Arrayed, MultiSampled, NeedSampler, Unknown>>, UniformConstant>
914

1015
// CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<i32, Rect, DepthUnknown, Arrayed, MultiSampled, NeedSampler, R8ui>>, UniformConstant>
1116
spirv.GlobalVariable @var2 bind(0, 0) : !spirv.ptr<!spirv.sampled_image<!spirv.image<i32, Rect, DepthUnknown, Arrayed, MultiSampled, NeedSampler, R8ui>>, UniformConstant>

0 commit comments

Comments
 (0)