brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · acde601 Raw
81 lines · plain
1// RUN: mlir-opt %s -pass-pipeline='builtin.module(func.func(scf-forall-to-parallel))' -split-input-file | FileCheck %s2 3func.func private @callee(%i: index, %j: index)4 5// CHECK-LABEL: @two_iters6// CHECK-SAME: %[[UB1:.+]]: index, %[[UB2:.+]]: index7func.func @two_iters(%ub1: index, %ub2: index) {8  scf.forall (%i, %j) in (%ub1, %ub2) {9    func.call @callee(%i, %j) : (index, index) -> ()10  }11 12  // CHECK: scf.parallel (%[[IV1:.+]], %[[IV2:.+]]) = (%{{.*}}, %{{.*}}) to (%[[UB1]], %[[UB2]])13  // CHECK:   func.call @callee(%[[IV1]], %[[IV2]]) : (index, index) -> ()14  // CHECK:   scf.reduce15  return16}17 18// -----19 20func.func private @callee(%i: index, %j: index)21 22// CHECK-LABEL: @repeated23// CHECK-SAME: %[[UB1:.+]]: index, %[[UB2:.+]]: index24func.func @repeated(%ub1: index, %ub2: index) {25  scf.forall (%i, %j) in (%ub1, %ub2) {26    func.call @callee(%i, %j) : (index, index) -> ()27  }28 29  // CHECK: scf.parallel (%[[IV1:.+]], %[[IV2:.+]]) = (%{{.*}}, %{{.*}}) to (%[[UB1]], %[[UB2]])30  // CHECK:   func.call @callee(%[[IV1]], %[[IV2]]) : (index, index) -> ()31  // CHECK:   scf.reduce32  scf.forall (%i, %j) in (%ub1, %ub2) {33    func.call @callee(%i, %j) : (index, index) -> ()34  }35 36  // CHECK: scf.parallel (%[[IV3:.+]], %[[IV4:.+]]) = (%{{.*}}, %{{.*}}) to (%[[UB1]], %[[UB2]])37  // CHECK:   func.call @callee(%[[IV3]], %[[IV4]])38  // CHECK:   scf.reduce39  return40}41 42// -----43 44func.func private @callee(%i: index, %j: index, %k: index, %l: index)45 46// CHECK-LABEL: @nested47// CHECK-SAME: %[[UB1:.+]]: index, %[[UB2:.+]]: index, %[[UB3:.+]]: index, %[[UB4:.+]]: index48func.func @nested(%ub1: index, %ub2: index, %ub3: index, %ub4: index) {49  // CHECK: scf.parallel (%[[IV1:.+]], %[[IV2:.+]]) = (%{{.*}}, %{{.*}}) to (%[[UB1]], %[[UB2]]) step (%{{.*}}, %{{.*}}) {50  // CHECK:   scf.parallel (%[[IV3:.+]], %[[IV4:.+]]) = (%{{.*}}, %{{.*}}) to (%[[UB3]], %[[UB4]]) step (%{{.*}}, %{{.*}}) {51  // CHECK:     func.call @callee(%[[IV1]], %[[IV2]], %[[IV3]], %[[IV4]])52  // CHECK:     scf.reduce53  // CHECK:   }54  // CHECK:   scf.reduce55  // CHECK: }56  scf.forall (%i, %j) in (%ub1, %ub2) {57    scf.forall (%k, %l) in (%ub3, %ub4) {58      func.call @callee(%i, %j, %k, %l) : (index, index, index, index) -> ()59    }60  }61  return62}63 64// -----65 66// CHECK-LABEL: @mapping_attr67func.func @mapping_attr() -> () {68  // CHECK: scf.parallel69  // CHECK:   scf.reduce70  // CHECK: {mapping = [#gpu.thread<x>]}71 72  %num_threads = arith.constant 100 : index73 74  scf.forall (%thread_idx) in (%num_threads) {75    scf.forall.in_parallel {76    }77  } {mapping = [#gpu.thread<x>]}78  return79 80}81