xref: /llvm-project/mlir/test/Conversion/ConvertToSPIRV/convert-gpu-modules-nested.mlir (revision 25ae1a266d50f24a8fffc57152d7f3c3fcb65517)
1// RUN: mlir-opt -test-convert-to-spirv="convert-gpu-modules=true nest-in-gpu-module=true run-signature-conversion=false run-vector-unrolling=false" %s | FileCheck %s
2
3module attributes {
4  gpu.container_module,
5  spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Shader], []>, #spirv.resource_limits<>>
6} {
7  // CHECK-LABEL: func.func @main
8  // CHECK:       %[[C1:.*]] = arith.constant 1 : index
9  // CHECK:       gpu.launch_func  @[[$KERNELS_1:.*]]::@[[$BUILTIN_WG_ID_X:.*]] blocks in (%[[C1]], %[[C1]], %[[C1]]) threads in (%[[C1]], %[[C1]], %[[C1]])
10  func.func @main() {
11    %c1 = arith.constant 1 : index
12    gpu.launch_func @kernels_1::@builtin_workgroup_id_x
13        blocks in (%c1, %c1, %c1) threads in (%c1, %c1, %c1)
14    return
15  }
16
17  // CHECK: gpu.module @[[$KERNELS_1]]
18  // CHECK:   spirv.module @{{.*}} Logical GLSL450
19  // CHECK:   spirv.func @[[$BUILTIN_WG_ID_X]]
20  // CHECK:   spirv.mlir.addressof
21  // CHECK:   spirv.Load "Input"
22  // CHECK:   spirv.CompositeExtract
23  gpu.module @kernels_1 {
24    gpu.func @builtin_workgroup_id_x() kernel
25      attributes {spirv.entry_point_abi = #spirv.entry_point_abi<workgroup_size = [16, 1, 1]>} {
26      %0 = gpu.block_id x
27      gpu.return
28    }
29  }
30}
31