|
| 1 | +// RUN: mlir-opt --split-input-file --convert-gpu-to-spirv %s | FileCheck %s |
| 2 | + |
| 3 | +module attributes {gpu.container_module} { |
| 4 | + // CHECK-LABEL: spirv.module @{{.*}} GLSL450 |
| 5 | + gpu.module @kernels [#spirv.target_env<#spirv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spirv.resource_limits<>>] { |
| 6 | + // CHECK: spirv.func @load_kernel |
| 7 | + // CHECK-SAME: %[[ARG:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<48 x f32, stride=4> [0])>, StorageBuffer> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 0)>}) |
| 8 | + gpu.func @load_kernel(%arg0: memref<12x4xf32>) kernel attributes {spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [16, 1, 1]>} { |
| 9 | + %c0 = arith.constant 0 : index |
| 10 | + // CHECK: %[[PTR:.*]] = spirv.AccessChain %[[ARG]]{{\[}}{{%.*}}, {{%.*}}{{\]}} |
| 11 | + // CHECK-NEXT: {{%.*}} = spirv.Load "StorageBuffer" %[[PTR]] : f32 |
| 12 | + %0 = memref.load %arg0[%c0, %c0] : memref<12x4xf32> |
| 13 | + // CHECK: spirv.Return |
| 14 | + gpu.return |
| 15 | + } |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +// ----- |
| 20 | +// Checks that the `-convert-gpu-to-spirv` pass selects the first |
| 21 | +// `spirv.target_env` from the `targets` array attribute attached to `gpu.module`. |
| 22 | +module attributes {gpu.container_module} { |
| 23 | + // CHECK-LABEL: spirv.module @{{.*}} GLSL450 |
| 24 | + // CHECK-SAME: #spirv.target_env<#spirv.vce<v1.4, [Shader], [SPV_KHR_storage_buffer_storage_class]> |
| 25 | + gpu.module @kernels [ |
| 26 | + #spirv.target_env<#spirv.vce<v1.4, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spirv.resource_limits<>>, |
| 27 | + #spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, #spirv.resource_limits<>>, |
| 28 | + #spirv.target_env<#spirv.vce<v1.0, [Shader], []>, #spirv.resource_limits<>>] { |
| 29 | + // CHECK: spirv.func @load_kernel |
| 30 | + // CHECK-SAME: %[[ARG:.*]]: !spirv.ptr<!spirv.struct<(!spirv.array<48 x f32, stride=4> [0])>, StorageBuffer> {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 0)>}) |
| 31 | + gpu.func @load_kernel(%arg0: memref<12x4xf32>) kernel attributes {spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [16, 1, 1]>} { |
| 32 | + %c0 = arith.constant 0 : index |
| 33 | + // CHECK: %[[PTR:.*]] = spirv.AccessChain %[[ARG]]{{\[}}{{%.*}}, {{%.*}}{{\]}} |
| 34 | + // CHECK-NEXT: {{%.*}} = spirv.Load "StorageBuffer" %[[PTR]] : f32 |
| 35 | + %0 = memref.load %arg0[%c0, %c0] : memref<12x4xf32> |
| 36 | + // CHECK: spirv.Return |
| 37 | + gpu.return |
| 38 | + } |
| 39 | + } |
| 40 | +} |
0 commit comments