76 lines · plain
1// Run the test cases without distributing ops to test default lowering. Run2// everything on the same thread.3// RUN: mlir-opt %s -test-vector-warp-distribute=rewrite-warp-ops-to-scf-if -canonicalize | \4// RUN: mlir-opt -convert-vector-to-scf -convert-scf-to-cf -convert-cf-to-llvm -convert-vector-to-llvm -convert-arith-to-llvm \5// RUN: -gpu-lower-to-nvvm-pipeline | \6// RUN: mlir-runner -e main -entry-point-result=void \7// RUN: -shared-libs=%mlir_cuda_runtime \8// RUN: -shared-libs=%mlir_c_runner_utils \9// RUN: -shared-libs=%mlir_runner_utils | \10// RUN: FileCheck %s11 12// Run the same test cases with distribution and propagation.13// RUN: mlir-opt %s -test-vector-warp-distribute="hoist-uniform distribute-transfer-write" \14// RUN: -test-vector-warp-distribute=rewrite-warp-ops-to-scf-if -canonicalize | \15// RUN: mlir-opt -convert-vector-to-scf -convert-scf-to-cf -convert-cf-to-llvm -convert-vector-to-llvm -convert-arith-to-llvm \16// RUN: -gpu-lower-to-nvvm-pipeline | \17// RUN: mlir-runner -e main -entry-point-result=void \18// RUN: -shared-libs=%mlir_cuda_runtime \19// RUN: -shared-libs=%mlir_c_runner_utils \20// RUN: -shared-libs=%mlir_runner_utils | \21// RUN: FileCheck %s22 23// RUN: mlir-opt %s -test-vector-warp-distribute="hoist-uniform distribute-transfer-write propagate-distribution" \24// RUN: -test-vector-warp-distribute=rewrite-warp-ops-to-scf-if -canonicalize | \25// RUN: mlir-opt -convert-vector-to-scf -convert-scf-to-cf -convert-cf-to-llvm -convert-vector-to-llvm -convert-arith-to-llvm \26// RUN: -gpu-lower-to-nvvm-pipeline | \27// RUN: mlir-runner -e main -entry-point-result=void \28// RUN: -shared-libs=%mlir_cuda_runtime \29// RUN: -shared-libs=%mlir_c_runner_utils \30// RUN: -shared-libs=%mlir_runner_utils | \31// RUN: FileCheck %s32 33func.func @gpu_func(%arg1: memref<32xf32>, %arg2: memref<32xf32>) {34 %c1 = arith.constant 1 : index35 %c0 = arith.constant 0 : index36 %c32 = arith.constant 32 : index37 %cst = arith.constant 0.000000e+00 : f3238 gpu.launch blocks(%arg3, %arg4, %arg5)39 in (%arg9 = %c1, %arg10 = %c1, %arg11 = %c1)40 threads(%arg6, %arg7, %arg8) in (%arg12 = %c32, %arg13 = %c1, %arg14 = %c1) {41 gpu.warp_execute_on_lane_0(%arg6)[32] {42 %0 = vector.transfer_read %arg1[%c0], %cst {in_bounds = [true]} : memref<32xf32>, vector<32xf32>43 %1 = vector.transfer_read %arg2[%c0], %cst {in_bound = [true]} : memref<32xf32>, vector<32xf32>44 %2 = arith.addf %0, %1 : vector<32xf32>45 vector.transfer_write %2, %arg1[%c0] {in_bounds = [true]} : vector<32xf32>, memref<32xf32>46 }47 gpu.terminator48 }49 return50}51func.func @main() {52 %cst = arith.constant 0.000000e+00 : f3253 %c0 = arith.constant 0 : index54 %0 = memref.alloc() : memref<32xf32>55 %1 = memref.alloc() : memref<32xf32>56 %cst_1 = arith.constant dense<[57 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,58 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0,59 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0,60 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0]> : vector<32xf32>61 %cst_2 = arith.constant dense<2.000000e+00> : vector<32xf32>62 // init the buffers.63 vector.transfer_write %cst_1, %0[%c0] {in_bounds = [true]} : vector<32xf32>, memref<32xf32>64 vector.transfer_write %cst_2, %1[%c0] {in_bounds = [true]} : vector<32xf32>, memref<32xf32>65 %3 = memref.cast %0 : memref<32xf32> to memref<*xf32>66 gpu.host_register %3 : memref<*xf32>67 %5 = memref.cast %1 : memref<32xf32> to memref<*xf32>68 gpu.host_register %5 : memref<*xf32>69 call @gpu_func(%0, %1) : (memref<32xf32>, memref<32xf32>) -> ()70 %6 = vector.transfer_read %0[%c0], %cst : memref<32xf32>, vector<32xf32>71 vector.print %6 : vector<32xf32>72 return73}74 75// CHECK: ( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 )76