brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.6 KiB · 79abe8c Raw
142 lines · plain
1// RUN:   mlir-opt %s -async-parallel-for                                      \2// RUN:               -async-to-async-runtime                                  \3// RUN:               -async-runtime-ref-counting                              \4// RUN:               -async-runtime-ref-counting-opt                          \5// RUN:               -convert-async-to-llvm                                   \6// RUN:               -convert-scf-to-cf                                       \7// RUN:               -finalize-memref-to-llvm                                 \8// RUN:               -arith-expand                                            \9// RUN:               -memref-expand                                           \10// RUN:               -convert-func-to-llvm                                    \11// RUN:               -convert-arith-to-llvm                                   \12// RUN:               -convert-cf-to-llvm                                      \13// RUN:               -reconcile-unrealized-casts                              \14// RUN: | mlir-runner                                                      \15// RUN:  -e entry -entry-point-result=void -O0                                 \16// RUN:  -shared-libs=%mlir_runner_utils \17// RUN:  -shared-libs=%mlir_async_runtime\18// RUN: | FileCheck %s --dump-input=always19 20// RUN:   mlir-opt %s -async-parallel-for                                      \21// RUN:               -async-to-async-runtime                                  \22// RUN:               -async-runtime-policy-based-ref-counting                 \23// RUN:               -convert-async-to-llvm                                   \24// RUN:               -convert-scf-to-cf                                       \25// RUN:               -finalize-memref-to-llvm                                 \26// RUN:               -arith-expand                                            \27// RUN:               -memref-expand                                           \28// RUN:               -convert-func-to-llvm                                    \29// RUN:               -convert-arith-to-llvm                                   \30// RUN:               -convert-cf-to-llvm                                      \31// RUN:               -reconcile-unrealized-casts                              \32// RUN: | mlir-runner                                                      \33// RUN:  -e entry -entry-point-result=void -O0                                 \34// RUN:  -shared-libs=%mlir_runner_utils \35// RUN:  -shared-libs=%mlir_async_runtime\36// RUN: | FileCheck %s --dump-input=always37 38// RUN:   mlir-opt %s -async-parallel-for="async-dispatch=false                \39// RUN:                                    num-workers=20                      \40// RUN:                                    min-task-size=1"                    \41// RUN:               -async-to-async-runtime                                  \42// RUN:               -async-runtime-ref-counting                              \43// RUN:               -async-runtime-ref-counting-opt                          \44// RUN:               -convert-async-to-llvm                                   \45// RUN:               -convert-scf-to-cf                                       \46// RUN:               -finalize-memref-to-llvm                                 \47// RUN:               -arith-expand                                            \48// RUN:               -memref-expand                                           \49// RUN:               -convert-func-to-llvm                                    \50// RUN:               -convert-arith-to-llvm                                   \51// RUN:               -convert-cf-to-llvm                                      \52// RUN:               -reconcile-unrealized-casts                              \53// RUN: | mlir-runner                                                      \54// RUN:  -e entry -entry-point-result=void -O0                                 \55// RUN:  -shared-libs=%mlir_runner_utils \56// RUN:  -shared-libs=%mlir_async_runtime\57// RUN: | FileCheck %s --dump-input=always58 59// Suppress constant folding by introducing "dynamic" zero value at runtime.60func.func private @zero() -> index {61  %0 = arith.constant 0 : index62  return %0 : index63}64 65func.func @entry() {66  %c0 = arith.constant 0.0 : f3267  %c1 = arith.constant 1 : index68  %c2 = arith.constant 2 : index69  %c3 = arith.constant 3 : index70 71  %lb = arith.constant 0 : index72  %ub = arith.constant 9 : index73 74  %A = memref.alloc() : memref<9xf32>75  %U = memref.cast %A :  memref<9xf32> to memref<*xf32>76 77  // Initialize memref with zeros because we do load and store to in every test78  // to verify that we process each element of the iteration space once.79  scf.parallel (%i) = (%lb) to (%ub) step (%c1) {80    memref.store %c0, %A[%i] : memref<9xf32>81  }82 83  // 1. %i = (0) to (9) step (1)84  scf.parallel (%i) = (%lb) to (%ub) step (%c1) {85    %0 = arith.index_cast %i : index to i3286    %1 = arith.sitofp %0 : i32 to f3287    %2 = memref.load %A[%i] : memref<9xf32>88    %3 = arith.addf %1, %2 : f3289    memref.store %3, %A[%i] : memref<9xf32>90  }91  // CHECK: [0, 1, 2, 3, 4, 5, 6, 7, 8]92  call @printMemrefF32(%U): (memref<*xf32>) -> ()93 94  scf.parallel (%i) = (%lb) to (%ub) step (%c1) {95    memref.store %c0, %A[%i] : memref<9xf32>96  }97 98  // 2. %i = (0) to (9) step (2)99  scf.parallel (%i) = (%lb) to (%ub) step (%c2) {100    %0 = arith.index_cast %i : index to i32101    %1 = arith.sitofp %0 : i32 to f32102    %2 = memref.load %A[%i] : memref<9xf32>103    %3 = arith.addf %1, %2 : f32104    memref.store %3, %A[%i] : memref<9xf32>105  }106  // CHECK:  [0, 0, 2, 0, 4, 0, 6, 0, 8]107  call @printMemrefF32(%U): (memref<*xf32>) -> ()108 109  scf.parallel (%i) = (%lb) to (%ub) step (%c1) {110    memref.store %c0, %A[%i] : memref<9xf32>111  }112 113  // 3. %i = (-20) to (-11) step (3)114  %lb0 = arith.constant -20 : index115  %ub0 = arith.constant -11 : index116  scf.parallel (%i) = (%lb0) to (%ub0) step (%c3) {117    %0 = arith.index_cast %i : index to i32118    %1 = arith.sitofp %0 : i32 to f32119    %2 = arith.constant 20 : index120    %3 = arith.addi %i, %2 : index121    %4 = memref.load %A[%3] : memref<9xf32>122    %5 = arith.addf %1, %4 : f32123    memref.store %5, %A[%3] : memref<9xf32>124  }125  // CHECK: [-20, 0, 0, -17, 0, 0, -14, 0, 0]126  call @printMemrefF32(%U): (memref<*xf32>) -> ()127 128  // 4. Check that loop with zero iterations doesn't crash at runtime.129  %lb1 = call @zero(): () -> (index)130  %ub1 = call @zero(): () -> (index)131 132  scf.parallel (%i) = (%lb1) to (%ub1) step (%c1) {133    %false = arith.constant 0 : i1134    cf.assert %false, "should never be executed"135  }136 137  memref.dealloc %A : memref<9xf32>138  return139}140 141func.func private @printMemrefF32(memref<*xf32>) attributes { llvm.emit_c_interface }142