brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · fe3c2b1 Raw
42 lines · plain
1// RUN: mlir-opt %s \2// RUN: | mlir-opt -gpu-lower-to-nvvm-pipeline="cubin-format=%gpu_compilation_format allow-pattern-rollback=0" \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 10func.func @other_func(%arg0 : f32, %arg1 : memref<?xf32>) {11  %cst = arith.constant 1 : index12  %c0 = arith.constant 0 : index13  %cst2 = memref.dim %arg1, %c0 : memref<?xf32>14  gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, %grid_z = %cst)15             threads(%tx, %ty, %tz) in (%block_x = %cst2, %block_y = %cst, %block_z = %cst) {16    memref.store %arg0, %arg1[%tx] : memref<?xf32>17    gpu.terminator18  }19  return20}21 22// CHECK: [1, 1, 1, 1, 1]23// CHECK: ( 1, 1 )24func.func @main() {25  %v0 = arith.constant 0.0 : f3226  %c0 = arith.constant 0: index27  %arg0 = memref.alloc() : memref<5xf32>28  %21 = arith.constant 5 : i3229  %22 = memref.cast %arg0 : memref<5xf32> to memref<?xf32>30  %23 = memref.cast %22 : memref<?xf32> to memref<*xf32>31  gpu.host_register %23 : memref<*xf32>32  call @printMemrefF32(%23) : (memref<*xf32>) -> ()33  %24 = arith.constant 1.0 : f3234  call @other_func(%24, %22) : (f32, memref<?xf32>) -> ()35  call @printMemrefF32(%23) : (memref<*xf32>) -> ()36  %val1 = vector.transfer_read %arg0[%c0], %v0: memref<5xf32>, vector<2xf32>37  vector.print %val1: vector<2xf32>38  return39}40 41func.func private @printMemrefF32(%ptr : memref<*xf32>)42