1// RUN: mlir-cuda-runner %s --shared-libs=%cuda_wrapper_library_dir/libcuda-runtime-wrappers%shlibext,%linalg_test_lib_dir/libmlir_runner_utils%shlibext --entry-point-result=void | FileCheck %s
2
3func @other_func(%arg0 : f32, %arg1 : memref<?xf32>) {
4  %cst = constant 1 : index
5  %c0 = constant 0 : index
6  %cst2 = dim %arg1, %c0 : memref<?xf32>
7  gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %cst, %grid_y = %cst, %grid_z = %cst)
8             threads(%tx, %ty, %tz) in (%block_x = %cst2, %block_y = %cst, %block_z = %cst) {
9    store %arg0, %arg1[%tx] : memref<?xf32>
10    gpu.terminator
11  }
12  return
13}
14
15// CHECK: [1, 1, 1, 1, 1]
16func @main() {
17  %arg0 = alloc() : memref<5xf32>
18  %21 = constant 5 : i32
19  %22 = memref_cast %arg0 : memref<5xf32> to memref<?xf32>
20  %23 = memref_cast %22 : memref<?xf32> to memref<*xf32>
21  gpu.host_register %23 : memref<*xf32>
22  call @print_memref_f32(%23) : (memref<*xf32>) -> ()
23  %24 = constant 1.0 : f32
24  call @other_func(%24, %22) : (f32, memref<?xf32>) -> ()
25  call @print_memref_f32(%23) : (memref<*xf32>) -> ()
26  return
27}
28
29func private @print_memref_f32(%ptr : memref<*xf32>)
30