1 // RUN: mlir-opt -allow-unregistered-dialect -split-input-file -convert-gpu-to-spirv -verify-diagnostics %s -o - | FileCheck %s
3 module attributes {gpu.container_module} {
5 // CHECK: spv.module @{{.*}} Logical GLSL450 {
6 // CHECK-LABEL: spv.func @basic_module_structure
7 // CHECK-SAME: {{%.*}}: f32 {spv.interface_var_abi = #spv.interface_var_abi<(0, 0), StorageBuffer>}
8 // CHECK-SAME: {{%.*}}: !spv.ptr<!spv.struct<(!spv.array<12 x f32, stride=4> [0])>, StorageBuffer> {spv.interface_var_abi = #spv.interface_var_abi<(0, 1)>}
9 // CHECK-SAME: spv.entry_point_abi = {local_size = dense<[32, 4, 1]> : vector<3xi32>}
10 gpu.func @basic_module_structure(%arg0 : f32, %arg1 : memref<12xf32>) kernel
11 attributes {spv.entry_point_abi = {local_size = dense<[32, 4, 1]>: vector<3xi32>}} {
18 %0 = "op"() : () -> (f32)
19 %1 = "op"() : () -> (memref<12xf32>)
20 %cst = arith.constant 1 : index
21 gpu.launch_func @kernels::@basic_module_structure
22 blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst)
23 args(%0 : f32, %1 : memref<12xf32>)
30 module attributes {gpu.container_module} {
32 // CHECK: spv.module @{{.*}} Logical GLSL450 {
33 // CHECK-LABEL: spv.func @basic_module_structure_preset_ABI
34 // CHECK-SAME: {{%[a-zA-Z0-9_]*}}: f32
35 // CHECK-SAME: spv.interface_var_abi = #spv.interface_var_abi<(1, 2), StorageBuffer>
36 // CHECK-SAME: !spv.ptr<!spv.struct<(!spv.array<12 x f32, stride=4> [0])>, StorageBuffer>
37 // CHECK-SAME: spv.interface_var_abi = #spv.interface_var_abi<(3, 0)>
38 // CHECK-SAME: spv.entry_point_abi = {local_size = dense<[32, 4, 1]> : vector<3xi32>}
39 gpu.func @basic_module_structure_preset_ABI(
41 {spv.interface_var_abi = #spv.interface_var_abi<(1, 2), StorageBuffer>},
42 %arg1 : memref<12xf32>
43 {spv.interface_var_abi = #spv.interface_var_abi<(3, 0)>}) kernel
45 {spv.entry_point_abi = {local_size = dense<[32, 4, 1]>: vector<3xi32>}} {
54 module attributes {gpu.container_module} {
56 // expected-error @below {{failed to legalize operation 'gpu.func'}}
57 // expected-remark @below {{match failure: missing 'spv.entry_point_abi' attribute}}
58 gpu.func @missing_entry_point_abi(%arg0 : f32, %arg1 : memref<12xf32>) kernel {
64 %0 = "op"() : () -> (f32)
65 %1 = "op"() : () -> (memref<12xf32>)
66 %cst = arith.constant 1 : index
67 gpu.launch_func @kernels::@missing_entry_point_abi
68 blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst)
69 args(%0 : f32, %1 : memref<12xf32>)
76 module attributes {gpu.container_module} {
78 // expected-error @below {{failed to legalize operation 'gpu.func'}}
79 // expected-remark @below {{match failure: missing 'spv.interface_var_abi' attribute at argument 1}}
80 gpu.func @missing_entry_point_abi(
82 {spv.interface_var_abi = #spv.interface_var_abi<(1, 2), StorageBuffer>},
83 %arg1 : memref<12xf32>) kernel
85 {spv.entry_point_abi = {local_size = dense<[32, 4, 1]>: vector<3xi32>}} {
93 module attributes {gpu.container_module} {
95 // expected-error @below {{failed to legalize operation 'gpu.func'}}
96 // expected-remark @below {{match failure: missing 'spv.interface_var_abi' attribute at argument 0}}
97 gpu.func @missing_entry_point_abi(
99 %arg1 : memref<12xf32>
100 {spv.interface_var_abi = #spv.interface_var_abi<(3, 0)>}) kernel
102 {spv.entry_point_abi = {local_size = dense<[32, 4, 1]>: vector<3xi32>}} {