brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 5fa27ea Raw
41 lines · plain
1// RUN: mlir-opt %s \2// RUN: | mlir-opt -gpu-kernel-outlining \3// RUN: | mlir-opt -pass-pipeline='builtin.module(gpu.module(strip-debuginfo,convert-gpu-to-rocdl),rocdl-attach-target{chip=%chip})' \4// RUN: | mlir-opt -gpu-to-llvm -reconcile-unrealized-casts -gpu-module-to-binary \5// RUN: | mlir-runner \6// RUN:   --shared-libs=%mlir_rocm_runtime \7// RUN:   --shared-libs=%mlir_runner_utils \8// RUN:   --entry-point-result=void \9// RUN: | FileCheck %s10 11func.func @other_func(%arg0 : f32, %arg1 : memref<?xf32>) {12  %c0 = arith.constant 0 : index13  %c1 = arith.constant 1 : index14  %block_dim = memref.dim %arg1, %c0 : memref<?xf32>15  gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %c1, %grid_y = %c1, %grid_z = %c1)16             threads(%tx, %ty, %tz) in (%block_x = %block_dim, %block_y = %c1, %block_z = %c1) {17    memref.store %arg0, %arg1[%tx] : memref<?xf32>18    gpu.terminator19  }20  return21}22 23// CHECK: [1, 1, 1, 1, 1]24func.func @main() {25  %arg0 = memref.alloc() : memref<5xf32>26  %21 = arith.constant 5 : i3227  %22 = memref.cast %arg0 : memref<5xf32> to memref<?xf32>28  %cast = memref.cast %22 : memref<?xf32> to memref<*xf32>29  gpu.host_register %cast : memref<*xf32>30  %23 = memref.cast %22 : memref<?xf32> to memref<*xf32>31  call @printMemrefF32(%23) : (memref<*xf32>) -> ()32  %24 = arith.constant 1.0 : f3233  %25 = call @mgpuMemGetDeviceMemRef1dFloat(%22) : (memref<?xf32>) -> (memref<?xf32>)34  call @other_func(%24, %25) : (f32, memref<?xf32>) -> ()35  call @printMemrefF32(%23) : (memref<*xf32>) -> ()36  return37}38 39func.func private @mgpuMemGetDeviceMemRef1dFloat(%ptr : memref<?xf32>) -> (memref<?xf32>)40func.func private @printMemrefF32(%ptr : memref<*xf32>)41