1// RUN: mlir-opt -allow-unregistered-dialect -split-input-file -convert-gpu-to-spirv -verify-diagnostics %s -o - | FileCheck %s 2 3module attributes {gpu.container_module} { 4 gpu.module @kernels { 5 // CHECK: spv.module Logical GLSL450 { 6 // CHECK-LABEL: spv.func @basic_module_structure 7 // CHECK-SAME: {{%.*}}: f32 {spv.interface_var_abi = {binding = 0 : i32, descriptor_set = 0 : i32, storage_class = 12 : i32{{[}][}]}} 8 // CHECK-SAME: {{%.*}}: !spv.ptr<!spv.struct<!spv.array<12 x f32 [4]> [0]>, StorageBuffer> {spv.interface_var_abi = {binding = 1 : i32, descriptor_set = 0 : i32{{[}][}]}} 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>) 11 attributes {gpu.kernel, spv.entry_point_abi = {local_size = dense<[32, 4, 1]>: vector<3xi32>}} { 12 // CHECK: spv.Return 13 gpu.return 14 } 15 } 16 17 func @main() { 18 %0 = "op"() : () -> (f32) 19 %1 = "op"() : () -> (memref<12xf32>) 20 %cst = constant 1 : index 21 "gpu.launch_func"(%cst, %cst, %cst, %cst, %cst, %cst, %0, %1) { kernel = "basic_module_structure", kernel_module = @kernels } 22 : (index, index, index, index, index, index, f32, memref<12xf32>) -> () 23 return 24 } 25} 26 27// ----- 28 29module attributes {gpu.container_module} { 30 gpu.module @kernels { 31 // expected-error @below {{failed to legalize operation 'gpu.func'}} 32 // expected-remark @below {{match failure: missing 'spv.entry_point_abi' attribute}} 33 gpu.func @missing_entry_point_abi(%arg0 : f32, %arg1 : memref<12xf32>) attributes {gpu.kernel} { 34 gpu.return 35 } 36 } 37 38 func @main() { 39 %0 = "op"() : () -> (f32) 40 %1 = "op"() : () -> (memref<12xf32>) 41 %cst = constant 1 : index 42 "gpu.launch_func"(%cst, %cst, %cst, %cst, %cst, %cst, %0, %1) { kernel = "missing_entry_point_abi", kernel_module = @kernels } 43 : (index, index, index, index, index, index, f32, memref<12xf32>) -> () 44 return 45 } 46} 47