brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · be6fadf Raw
83 lines · plain
1// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(convert-affine-for-to-gpu{gpu-block-dims=1 gpu-thread-dims=1}))" %s | FileCheck --check-prefix=CHECK-11 %s2// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(convert-affine-for-to-gpu{gpu-block-dims=2 gpu-thread-dims=2}))" %s | FileCheck --check-prefix=CHECK-22 %s3 4// CHECK-11-LABEL: @step_15// CHECK-22-LABEL: @step_16func.func @step_1(%A : memref<?x?x?x?xf32>, %B : memref<?x?x?x?xf32>) {7  // Bounds of the loop, its range and step.8  // CHECK-11-NEXT: %{{.*}} = arith.constant 0 : index9  // CHECK-11-NEXT: %{{.*}} = arith.constant 42 : index10  // CHECK-11-NEXT: %{{.*}} = arith.subi %{{.*}}, %{{.*}} : index11  // CHECK-11-NEXT: %{{.*}} = arith.constant 1 : index12  //13  // CHECK-22-NEXT: %{{.*}} = arith.constant 0 : index14  // CHECK-22-NEXT: %{{.*}} = arith.constant 42 : index15  // CHECK-22-NEXT: %{{.*}} = arith.subi %{{.*}}, %{{.*}} : index16  // CHECK-22-NEXT: %{{.*}} = arith.constant 1 : index17  affine.for %i = 0 to 42 {18 19    // Bounds of the loop, its range and step.20    // CHECK-11-NEXT: %{{.*}} = arith.constant 0 : index21    // CHECK-11-NEXT: %{{.*}} = arith.constant 10 : index22    // CHECK-11-NEXT: %{{.*}} = arith.subi %{{.*}}, %{{.*}} : index23    // CHECK-11-NEXT: %{{.*}} = arith.constant 1 : index24    //25    // CHECK-22-NEXT: %{{.*}} = arith.constant 0 : index26    // CHECK-22-NEXT: %{{.*}} = arith.constant 10 : index27    // CHECK-22-NEXT: %{{.*}} = arith.subi %{{.*}}, %{{.*}} : index28    // CHECK-22-NEXT: %{{.*}} = arith.constant 1 : index29    affine.for %j = 0 to 10 {30    // CHECK-11: gpu.launch31    // CHECK-11-SAME: blocks32    // CHECK-11-SAME: threads33 34      // Remapping of the loop induction variables.35      // CHECK-11:        %[[i:.*]] = arith.addi %{{.*}}, %{{.*}} : index36      // CHECK-11-NEXT:   %[[j:.*]] = arith.addi %{{.*}}, %{{.*}} : index37 38      // This loop is not converted if mapping to 1, 1 dimensions.39      // CHECK-11-NEXT: affine.for %[[ii:.*]] = 2 to 1640      //41      // Bounds of the loop, its range and step.42      // CHECK-22-NEXT: %{{.*}} = arith.constant 2 : index43      // CHECK-22-NEXT: %{{.*}} = arith.constant 16 : index44      // CHECK-22-NEXT: %{{.*}} = arith.subi %{{.*}}, %{{.*}} : index45      // CHECK-22-NEXT: %{{.*}} = arith.constant 1 : index46      affine.for %ii = 2 to 16 {47        // This loop is not converted if mapping to 1, 1 dimensions.48        // CHECK-11-NEXT: affine.for %[[jj:.*]] = 5 to 1749        //50        // Bounds of the loop, its range and step.51        // CHECK-22-NEXT: %{{.*}} = arith.constant 5 : index52        // CHECK-22-NEXT: %{{.*}} = arith.constant 17 : index53        // CHECK-22-NEXT: %{{.*}} = arith.subi %{{.*}}, %{{.*}} : index54        // CHECK-22-NEXT: %{{.*}} = arith.constant 1 : index55        affine.for %jj = 5 to 17 {56        // CHECK-22: gpu.launch57        // CHECK-22-SAME: blocks58        // CHECK-22-SAME: threads59 60          // Remapping of the loop induction variables in the last mapped scf.61          // CHECK-22:        %[[i:.*]] = arith.addi %{{.*}}, %{{.*}} : index62          // CHECK-22-NEXT:   %[[j:.*]] = arith.addi %{{.*}}, %{{.*}} : index63          // CHECK-22-NEXT:   %[[ii:.*]] = arith.addi %{{.*}}, %{{.*}} : index64          // CHECK-22-NEXT:   %[[jj:.*]] = arith.addi %{{.*}}, %{{.*}} : index65 66          // Using remapped values instead of loop iterators.67          // CHECK-11:        {{.*}} = memref.load %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>68          // CHECK-22:        {{.*}} = memref.load %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>69          %0 = memref.load %A[%i, %j, %ii, %jj] : memref<?x?x?x?xf32>70          // CHECK-11-NEXT:   memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>71          // CHECK-22-NEXT:   memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]], %[[ii]], %[[jj]]] : memref<?x?x?x?xf32>72          memref.store %0, %B[%i, %j, %ii, %jj] : memref<?x?x?x?xf32>73 74          // CHECK-11: gpu.terminator75          // CHECK-22: gpu.terminator76        }77      }78    }79  }80  return81}82 83