1// RUN: mlir-opt %s \ 2// RUN: -gpu-kernel-outlining \ 3// RUN: -pass-pipeline='gpu.module(strip-debuginfo,convert-gpu-to-nvvm,gpu-to-cubin)' \ 4// RUN: -gpu-to-llvm \ 5// RUN: | mlir-cpu-runner \ 6// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_cuda_runtime%shlibext \ 7// RUN: --shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \ 8// RUN: --entry-point-result=void \ 9// RUN: | FileCheck %s 10 11// CHECK: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] 12func @main() { 13 %arg = memref.alloc() : memref<13xi32> 14 %dst = memref.cast %arg : memref<13xi32> to memref<?xi32> 15 %one = constant 1 : index 16 %c0 = constant 0 : index 17 %sx = memref.dim %dst, %c0 : memref<?xi32> 18 %cast_dst = memref.cast %dst : memref<?xi32> to memref<*xi32> 19 gpu.host_register %cast_dst : memref<*xi32> 20 gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %one, %grid_y = %one, %grid_z = %one) 21 threads(%tx, %ty, %tz) in (%block_x = %sx, %block_y = %one, %block_z = %one) { 22 %t0 = index_cast %tx : index to i32 23 memref.store %t0, %dst[%tx] : memref<?xi32> 24 gpu.terminator 25 } 26 gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %one, %grid_y = %one, %grid_z = %one) 27 threads(%tx, %ty, %tz) in (%block_x = %sx, %block_y = %one, %block_z = %one) { 28 %t0 = index_cast %tx : index to i32 29 memref.store %t0, %dst[%tx] : memref<?xi32> 30 gpu.terminator 31 } 32 call @print_memref_i32(%cast_dst) : (memref<*xi32>) -> () 33 return 34} 35 36func private @print_memref_i32(%memref : memref<*xi32>) 37