From 72f9bf5469e7c8bea08116800f341153f10b843a Mon Sep 17 00:00:00 2001 From: Igor Wodiany Date: Wed, 17 Sep 2025 15:43:44 +0100 Subject: [PATCH] [mlir][spirv] Fix entry point, logical ops and sampled image Target tests 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 and vector objects is not supported in spv1.0. For 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. --- mlir/test/Target/SPIRV/entry-point.mlir | 17 +++++++++++------ mlir/test/Target/SPIRV/logical-ops.mlir | 11 ++++++++--- mlir/test/Target/SPIRV/sampled-image.mlir | 15 ++++++++++----- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/mlir/test/Target/SPIRV/entry-point.mlir b/mlir/test/Target/SPIRV/entry-point.mlir index 88ad637fb7606..a7ec5290151ef 100644 --- a/mlir/test/Target/SPIRV/entry-point.mlir +++ b/mlir/test/Target/SPIRV/entry-point.mlir @@ -1,12 +1,17 @@ // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip -split-input-file %s | FileCheck %s -spirv.module Logical GLSL450 requires #spirv.vce { +// RUN: %if spirv-tools %{ rm -rf %t %} +// RUN: %if spirv-tools %{ mkdir %t %} +// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %} +// RUN: %if spirv-tools %{ spirv-val %t %} + +spirv.module Logical OpenCL requires #spirv.vce { spirv.func @noop() -> () "None" { spirv.Return } - // CHECK: spirv.EntryPoint "GLCompute" @noop + // CHECK: spirv.EntryPoint "Kernel" @noop // CHECK-NEXT: spirv.ExecutionMode @noop "ContractionOff" - spirv.EntryPoint "GLCompute" @noop + spirv.EntryPoint "Kernel" @noop spirv.ExecutionMode @noop "ContractionOff" } @@ -15,13 +20,13 @@ spirv.module Logical GLSL450 requires #spirv.vce { spirv.module Logical GLSL450 requires #spirv.vce { // CHECK: spirv.GlobalVariable @var2 : !spirv.ptr // CHECK-NEXT: spirv.GlobalVariable @var3 : !spirv.ptr - // CHECK-NEXT: spirv.func @noop({{%.*}}: !spirv.ptr, {{%.*}}: !spirv.ptr) "None" + // CHECK-NEXT: spirv.func @noop() "None" // CHECK: spirv.EntryPoint "GLCompute" @noop, @var2, @var3 spirv.GlobalVariable @var2 : !spirv.ptr spirv.GlobalVariable @var3 : !spirv.ptr - spirv.func @noop(%arg0 : !spirv.ptr, %arg1 : !spirv.ptr) -> () "None" { + spirv.func @noop() -> () "None" { spirv.Return } spirv.EntryPoint "GLCompute" @noop, @var2, @var3 - spirv.ExecutionMode @noop "ContractionOff" + spirv.ExecutionMode @noop "LocalSize", 1, 1, 1 } diff --git a/mlir/test/Target/SPIRV/logical-ops.mlir b/mlir/test/Target/SPIRV/logical-ops.mlir index 05cbddc048151..d570815448b7c 100644 --- a/mlir/test/Target/SPIRV/logical-ops.mlir +++ b/mlir/test/Target/SPIRV/logical-ops.mlir @@ -1,6 +1,11 @@ // RUN: mlir-translate -no-implicit-module -split-input-file -test-spirv-roundtrip %s | FileCheck %s -spirv.module Logical GLSL450 requires #spirv.vce { +// RUN: %if spirv-tools %{ rm -rf %t %} +// RUN: %if spirv-tools %{ mkdir %t %} +// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %} +// RUN: %if spirv-tools %{ spirv-val %t %} + +spirv.module Logical OpenCL requires #spirv.vce { spirv.func @iequal_scalar(%arg0: i32, %arg1: i32) "None" { // CHECK: {{.*}} = spirv.IEqual {{.*}}, {{.*}} : i32 %0 = spirv.IEqual %arg0, %arg1 : i32 @@ -92,7 +97,7 @@ spirv.module Logical GLSL450 requires #spirv.vce { // ----- -spirv.module Logical GLSL450 requires #spirv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { spirv.SpecConstant @condition_scalar = true spirv.func @select() -> () "None" { %0 = spirv.Constant 4.0 : f32 @@ -115,7 +120,7 @@ spirv.module Logical GLSL450 requires #spirv.vce { // Test select works with bf16 scalar and vectors. -spirv.module Logical GLSL450 requires #spirv.vce { +spirv.module Logical GLSL450 requires #spirv.vce { spirv.SpecConstant @condition_scalar = true spirv.func @select_bf16() -> () "None" { %0 = spirv.Constant 4.0 : bf16 diff --git a/mlir/test/Target/SPIRV/sampled-image.mlir b/mlir/test/Target/SPIRV/sampled-image.mlir index 694862d943534..ff068208540f4 100644 --- a/mlir/test/Target/SPIRV/sampled-image.mlir +++ b/mlir/test/Target/SPIRV/sampled-image.mlir @@ -1,11 +1,16 @@ // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s -spirv.module Logical GLSL450 requires #spirv.vce { - // CHECK: !spirv.ptr>, UniformConstant> - spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr>, UniformConstant> +// RUN: %if spirv-tools %{ rm -rf %t %} +// RUN: %if spirv-tools %{ mkdir %t %} +// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %} +// RUN: %if spirv-tools %{ spirv-val %t %} - // CHECK: !spirv.ptr>, UniformConstant> - spirv.GlobalVariable @var1 bind(0, 0) : !spirv.ptr>, UniformConstant> +spirv.module Logical GLSL450 requires #spirv.vce { + // CHECK: !spirv.ptr>, UniformConstant> + spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr>, UniformConstant> + + // CHECK: !spirv.ptr>, UniformConstant> + spirv.GlobalVariable @var1 bind(0, 0) : !spirv.ptr>, UniformConstant> // CHECK: !spirv.ptr>, UniformConstant> spirv.GlobalVariable @var2 bind(0, 0) : !spirv.ptr>, UniformConstant>