35 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: --entry-point-result=void \7// RUN: | FileCheck %s8 9// CHECK: [{{(35, ){34}35}}]10func.func @main() {11 %arg = memref.alloc() : memref<35xf32>12 %dst = memref.cast %arg : memref<35xf32> to memref<?xf32>13 %one = arith.constant 1 : index14 %c0 = arith.constant 0 : index15 %sx = memref.dim %dst, %c0 : memref<?xf32>16 %cast_dst = memref.cast %dst : memref<?xf32> to memref<*xf32>17 gpu.host_register %cast_dst : memref<*xf32>18 gpu.launch blocks(%bx, %by, %bz) in (%grid_x = %one, %grid_y = %one, %grid_z = %one)19 threads(%tx, %ty, %tz) in (%block_x = %sx, %block_y = %one, %block_z = %one) {20 %val = arith.index_cast %tx : index to i3221 %xor = gpu.all_reduce %val uniform {22 ^bb(%lhs : i32, %rhs : i32):23 %xor = arith.xori %lhs, %rhs : i3224 "gpu.yield"(%xor) : (i32) -> ()25 } : (i32) -> (i32)26 %res = arith.sitofp %xor : i32 to f3227 memref.store %res, %dst[%tx] : memref<?xf32>28 gpu.terminator29 }30 call @printMemrefF32(%cast_dst) : (memref<*xf32>) -> ()31 return32}33 34func.func private @printMemrefF32(memref<*xf32>)35