File: cga_cluster.mlir

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (65 lines) | stat: -rw-r--r-- 2,319 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RUN: mlir-opt %s \
// RUN:  -gpu-lower-to-nvvm-pipeline="cubin-chip=sm_90a cubin-features=+ptx80 opt-level=3" \
// RUN:  | mlir-cpu-runner \
// RUN:   --shared-libs=%mlir_cuda_runtime \
// RUN:   --shared-libs=%mlir_runner_utils \
// RUN:   --shared-libs=%mlir_c_runner_utils \
// RUN:   --entry-point-result=void \
// RUN:  | FileCheck %s

// CHECK: clusterIdx: (1, 1, 0) in Cluster Dimension: (2, 2, 1) blockIdx: (3, 3, 0) 

module attributes {gpu.container_module} {
  func.func @main() {
    %c1 = arith.constant 1 : index
    %c2 = arith.constant 2 : index
    %c4 = arith.constant 4 : index    
    gpu.launch_func  @gpumodule::@kernel_cluster clusters in(%c2,%c2,%c1)  blocks in (%c4, %c4, %c1) threads in (%c1, %c1, %c1)  
    return
  }
  gpu.module @gpumodule {
    gpu.func @kernel_cluster() kernel attributes {gpu.known_block_size = array<i32: 1, 1, 1>, gpu.known_grid_size = array<i32: 2, 2, 1>} {
      %cidX = gpu.cluster_id  x
      %cidY = gpu.cluster_id  y
      %cidZ = gpu.cluster_id  z
      %cdimX = gpu.cluster_dim_blocks  x
      %cdimY = gpu.cluster_dim_blocks  y
      %cdimZ = gpu.cluster_dim_blocks  z
      %bidX = gpu.block_id  x
      %bidY = gpu.block_id  y
      %bidZ = gpu.block_id  z
      %cidX_i32 = index.casts %cidX : index to i32
      %cidY_i32 = index.casts %cidY : index to i32
      %cidZ_i32 = index.casts %cidZ : index to i32
      %cdimX_i32 = index.casts %cdimX : index to i32
      %cdimY_i32 = index.casts %cdimY : index to i32
      %cdimZ_i32 = index.casts %cdimZ : index to i32
      %bidX_i32 = index.casts %bidX : index to i32
      %bidY_i32 = index.casts %bidY : index to i32
      %bidZ_i32 = index.casts %bidZ : index to i32

      %c3 = arith.constant 3 : index
      %cnd1 =  arith.cmpi eq, %bidX, %c3 : index
      %cnd2 =  arith.cmpi eq, %bidY, %c3 : index
      scf.if %cnd1 {
        scf.if %cnd2 {
          gpu.printf "clusterIdx: (%d, %d, %d) in Cluster Dimension: (%d, %d, %d) blockIdx: (%d, %d, %d) \n" 
            %cidX_i32,
            %cidY_i32,
            %cidZ_i32,
            %cdimX_i32,
            %cdimY_i32,
            %cdimZ_i32,
            %bidX_i32,
            %bidY_i32,
            %bidZ_i32      
            : 
            i32, i32, i32, i32, i32, i32, i32, i32, i32
        }
      }
      
      gpu.return
    }
  }
}