brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.7 KiB · 41b0d85 Raw
141 lines · plain
1// RUN: mlir-opt %s -pass-pipeline='builtin.module(func.func(scf-parallel-loop-tiling{parallel-loop-tile-sizes=1,4}))' -split-input-file | FileCheck %s2 3func.func @parallel_loop(%arg0 : index, %arg1 : index, %arg2 : index,4                    %arg3 : index, %arg4 : index, %arg5 : index,5		    %A: memref<?x?xf32>, %B: memref<?x?xf32>,6                    %C: memref<?x?xf32>, %result: memref<?x?xf32>) {7  scf.parallel (%i0, %i1) = (%arg0, %arg1) to (%arg2, %arg3) step (%arg4, %arg5) {8    %B_elem = memref.load %B[%i0, %i1] : memref<?x?xf32>9    %C_elem = memref.load %C[%i0, %i1] : memref<?x?xf32>10    %sum_elem = arith.addf %B_elem, %C_elem : f3211    memref.store %sum_elem, %result[%i0, %i1] : memref<?x?xf32>12  }13  return14}15 16// CHECK:       #[[$MAP:.*]] = affine_map<(d0, d1, d2) -> (d0, d1 - d2)>17// CHECK-LABEL:   func @parallel_loop(18// CHECK-SAME:                        [[ARG1:%.*]]: index, [[ARG2:%.*]]: index, [[ARG3:%.*]]: index, [[ARG4:%.*]]: index, [[ARG5:%.*]]: index, [[ARG6:%.*]]: index, [[ARG7:%.*]]: memref<?x?xf32>, [[ARG8:%.*]]: memref<?x?xf32>, [[ARG9:%.*]]: memref<?x?xf32>, [[ARG10:%.*]]: memref<?x?xf32>) {19// CHECK:           [[C0:%.*]] = arith.constant 0 : index20// CHECK:           [[C1:%.*]] = arith.constant 1 : index21// CHECK:           [[C4:%.*]] = arith.constant 4 : index22// CHECK:           [[V1:%.*]] = arith.muli [[ARG5]], [[C1]] : index23// CHECK:           [[V2:%.*]] = arith.muli [[ARG6]], [[C4]] : index24// CHECK:           scf.parallel ([[V3:%.*]], [[V4:%.*]]) = ([[ARG1]], [[ARG2]]) to ([[ARG3]], [[ARG4]]) step ([[V1]], [[V2]]) {25// CHECK:             [[V5:%.*]] = affine.min #[[$MAP]]([[V1]], [[ARG3]], [[V3]])26// CHECK:             [[V6:%.*]] = affine.min #[[$MAP]]([[V2]], [[ARG4]], [[V4]])27// CHECK:             scf.parallel ([[V7:%.*]], [[V8:%.*]]) = ([[C0]], [[C0]]) to ([[V5]], [[V6]]) step ([[ARG5]], [[ARG6]]) {28// CHECK:               [[V9:%.*]] = arith.addi [[V7]], [[V3]] : index29// CHECK:               [[V10:%.*]] = arith.addi [[V8]], [[V4]] : index30// CHECK:               [[V11:%.*]] = memref.load [[ARG8]]{{\[}}[[V9]], [[V10]]] : memref<?x?xf32>31// CHECK:               [[V12:%.*]] = memref.load [[ARG9]]{{\[}}[[V9]], [[V10]]] : memref<?x?xf32>32// CHECK:               [[V13:%.*]] = arith.addf [[V11]], [[V12]] : f3233// CHECK:               memref.store [[V13]], [[ARG10]]{{\[}}[[V9]], [[V10]]] : memref<?x?xf32>34// CHECK:             }35// CHECK:           }36// CHECK:           return37 38// -----39 40func.func @static_loop_with_step() {41  %c0 = arith.constant 0 : index42  %c3 = arith.constant 3 : index43  %c22 = arith.constant 22 : index44  %c24 = arith.constant 24 : index45  scf.parallel (%i0, %i1) = (%c0, %c0) to (%c22, %c24) step (%c3, %c3) {46  }47  return48}49 50// CHECK-LABEL:   func @static_loop_with_step() {51// CHECK:           [[C0:%.*]] = arith.constant 0 : index52// CHECK:           [[C3:%.*]] = arith.constant 3 : index53// CHECK:           [[C22:%.*]] = arith.constant 22 : index54// CHECK:           [[C24:%.*]] = arith.constant 24 : index55// CHECK:           [[C0_1:%.*]] = arith.constant 0 : index56// CHECK:           [[C1:%.*]] = arith.constant 1 : index57// CHECK:           [[C4:%.*]] = arith.constant 4 : index58// CHECK:           [[V1:%.*]] = arith.muli [[C3]], [[C1]] : index59// CHECK:           [[V2:%.*]] = arith.muli [[C3]], [[C4]] : index60// CHECK:           scf.parallel ([[V3:%.*]], [[V4:%.*]]) = ([[C0]], [[C0]]) to ([[C22]], [[C24]]) step ([[V1]], [[V2]]) {61// CHECK:             scf.parallel ([[V5:%.*]], [[V6:%.*]]) = ([[C0_1]], [[C0_1]]) to ([[V1]], [[V2]]) step ([[C3]], [[C3]]) {62// CHECK:               = arith.addi [[V5]], [[V3]] : index63// CHECK:               = arith.addi [[V6]], [[V4]] : index64// CHECK:             }65// CHECK:           }66// CHECK:           return67 68// -----69 70func.func @tile_nested_innermost() {71  %c2 = arith.constant 2 : index72  %c0 = arith.constant 0 : index73  %c1 = arith.constant 1 : index74  scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {75    scf.parallel (%k, %l) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {76    }77  }78  scf.parallel (%i, %j) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {79  }80  return81}82 83// CHECK-LABEL:   func @tile_nested_innermost() {84// CHECK:           [[C2:%.*]] = arith.constant 2 : index85// CHECK:           [[C0:%.*]] = arith.constant 0 : index86// CHECK:           [[C1:%.*]] = arith.constant 1 : index87// CHECK:           scf.parallel ([[V1:%.*]], [[V2:%.*]]) = ([[C0]], [[C0]]) to ([[C2]], [[C2]]) step ([[C1]], [[C1]]) {88// CHECK:             [[C0_1:%.*]] = arith.constant 0 : index89// CHECK:             [[C1_1:%.*]] = arith.constant 1 : index90// CHECK:             [[C4:%.*]] = arith.constant 4 : index91// CHECK:             [[V3:%.*]] = arith.muli [[C1]], [[C1_1]] : index92// CHECK:             [[V4:%.*]] = arith.muli [[C1]], [[C4]] : index93// CHECK:             scf.parallel ([[V5:%.*]], [[V6:%.*]]) = ([[C0]], [[C0]]) to ([[C2]], [[C2]]) step ([[V3]], [[V4]]) {94// CHECK:               [[V7:%.*]] = affine.min #{{.*}}([[V4]], [[C2]], [[V6]])95// CHECK:               scf.parallel ([[V8:%.*]], [[V9:%.*]]) = ([[C0_1]], [[C0_1]]) to ([[V3]], [[V7]]) step ([[C1]], [[C1]]) {96// CHECK:                 = arith.addi [[V8]], [[V5]] : index97// CHECK:                 = arith.addi [[V9]], [[V6]] : index98// CHECK:               }99// CHECK:             }100// CHECK:           }101// CHECK:           [[C0_2:%.*]] = arith.constant 0 : index102// CHECK:           [[C1_2:%.*]] = arith.constant 1 : index103// CHECK:           [[C4_1:%.*]] = arith.constant 4 : index104// CHECK:           [[V10:%.*]] = arith.muli [[C1]], [[C1_2]] : index105// CHECK:           [[V11:%.*]] = arith.muli [[C1]], [[C4_1]] : index106// CHECK:           scf.parallel ([[V12:%.*]], [[V13:%.*]]) = ([[C0]], [[C0]]) to ([[C2]], [[C2]]) step ([[V10]], [[V11]]) {107// CHECK:             [[V14:%.*]] = affine.min #{{.*}}([[V11]], [[C2]], [[V13]])108// CHECK:             scf.parallel ([[V15:%.*]], [[V16:%.*]]) = ([[C0_2]], [[C0_2]]) to ([[V10]], [[V14]]) step ([[C1]], [[C1]]) {109// CHECK:               = arith.addi [[V15]], [[V12]] : index110// CHECK:               = arith.addi [[V16]], [[V13]] : index111// CHECK:             }112// CHECK:           }113// CHECK:           return114// CHECK:         }115 116// -----117 118func.func @tile_nested_in_non_ploop() {119  %c0 = arith.constant 0 : index120  %c1 = arith.constant 1 : index121  %c2 = arith.constant 2 : index122  scf.for %i = %c0 to %c2 step %c1 {123    scf.for %j = %c0 to %c2 step %c1 {124      scf.parallel (%k, %l) = (%c0, %c0) to (%c2, %c2) step (%c1, %c1) {125      }126    }127  }128  return129}130 131// CHECK-LABEL: func @tile_nested_in_non_ploop132// CHECK:         scf.for133// CHECK:           scf.for134// CHECK:             scf.parallel135// CHECK:               scf.parallel136// CHECK:               }137// CHECK:             }138// CHECK:           }139// CHECK:         }140// CHECK:       }141