brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 4a0117b Raw
66 lines · plain
1// RUN: mlir-opt %s \2// RUN:  -gpu-lower-to-nvvm-pipeline="cubin-chip=sm_90a cubin-features=+ptx80 opt-level=3" \3// RUN:  | mlir-runner \4// RUN:   --shared-libs=%mlir_cuda_runtime \5// RUN:   --shared-libs=%mlir_runner_utils \6// RUN:   --shared-libs=%mlir_c_runner_utils \7// RUN:   --entry-point-result=void \8// RUN:  | FileCheck %s9 10// CHECK: clusterIdx: (1, 1, 0) in Cluster Dimension: (2, 2, 1) blockIdx: (3, 3, 0) 11 12module attributes {gpu.container_module} {13  func.func @main() {14    %c1 = arith.constant 1 : index15    %c2 = arith.constant 2 : index16    %c4 = arith.constant 4 : index    17    gpu.launch_func  @gpumodule::@kernel_cluster clusters in(%c2,%c2,%c1)  blocks in (%c4, %c4, %c1) threads in (%c1, %c1, %c1)  18    return19  }20  gpu.module @gpumodule {21    gpu.func @kernel_cluster() kernel attributes {gpu.known_block_size = array<i32: 1, 1, 1>, gpu.known_grid_size = array<i32: 4, 4, 1>} {22      %cidX = gpu.cluster_id  x23      %cidY = gpu.cluster_id  y24      %cidZ = gpu.cluster_id  z25      %cdimX = gpu.cluster_dim_blocks  x26      %cdimY = gpu.cluster_dim_blocks  y27      %cdimZ = gpu.cluster_dim_blocks  z28      %bidX = gpu.block_id  x29      %bidY = gpu.block_id  y30      %bidZ = gpu.block_id  z31      %cidX_i32 = index.casts %cidX : index to i3232      %cidY_i32 = index.casts %cidY : index to i3233      %cidZ_i32 = index.casts %cidZ : index to i3234      %cdimX_i32 = index.casts %cdimX : index to i3235      %cdimY_i32 = index.casts %cdimY : index to i3236      %cdimZ_i32 = index.casts %cdimZ : index to i3237      %bidX_i32 = index.casts %bidX : index to i3238      %bidY_i32 = index.casts %bidY : index to i3239      %bidZ_i32 = index.casts %bidZ : index to i3240 41      %c3 = arith.constant 3 : index42      %cnd1 =  arith.cmpi eq, %bidX, %c3 : index43      %cnd2 =  arith.cmpi eq, %bidY, %c3 : index44      scf.if %cnd1 {45        scf.if %cnd2 {46          gpu.printf "clusterIdx: (%d, %d, %d) in Cluster Dimension: (%d, %d, %d) blockIdx: (%d, %d, %d) \n",47            %cidX_i32,48            %cidY_i32,49            %cidZ_i32,50            %cdimX_i32,51            %cdimY_i32,52            %cdimZ_i32,53            %bidX_i32,54            %bidY_i32,55            %bidZ_i32      56            : 57            i32, i32, i32, i32, i32, i32, i32, i32, i3258        }59      }60      61      gpu.return62    }63  }64}65 66