brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 79eef8a Raw
35 lines · plain
1// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(convert-affine-for-to-gpu{gpu-block-dims=0 gpu-thread-dims=1}))" %s | FileCheck --check-prefix=CHECK-THREADS %s2// RUN: mlir-opt -pass-pipeline="builtin.module(func.func(convert-affine-for-to-gpu{gpu-block-dims=1 gpu-thread-dims=0}))" %s | FileCheck --check-prefix=CHECK-BLOCKS %s3 4// CHECK-THREADS-LABEL: @one_d_loop5// CHECK-BLOCKS-LABEL: @one_d_loop6func.func @one_d_loop(%A : memref<?xf32>, %B : memref<?xf32>) {7  // Bounds of the loop, its range and step.8  // CHECK-THREADS-NEXT: %{{.*}} = arith.constant 0 : index9  // CHECK-THREADS-NEXT: %{{.*}} = arith.constant 42 : index10  // CHECK-THREADS-NEXT: %[[BOUND:.*]] = arith.subi %{{.*}}, %{{.*}} : index11  // CHECK-THREADS-NEXT: %{{.*}} = arith.constant 1 : index12  // CHECK-THREADS-NEXT: %[[ONE:.*]] = arith.constant 1 : index13  //14  // CHECK-BLOCKS-NEXT: %{{.*}} = arith.constant 0 : index15  // CHECK-BLOCKS-NEXT: %{{.*}} = arith.constant 42 : index16  // CHECK-BLOCKS-NEXT: %[[BOUND:.*]] = arith.subi %{{.*}}, %{{.*}} : index17  // CHECK-BLOCKS-NEXT: %{{.*}} = arith.constant 1 : index18  // CHECK-BLOCKS-NEXT: %[[ONE:.*]] = arith.constant 1 : index19 20  // CHECK-THREADS-NEXT: gpu.launch blocks(%[[B0:.*]], %[[B1:.*]], %[[B2:.*]]) in (%{{.*}} = %[[ONE]], %{{.*}} = %[[ONE]], %{{.*}} = %[[ONE]]) threads(%[[T0:.*]], %[[T1:.*]], %[[T2:.*]]) in (%{{.*}} = %[[BOUND]], %{{.*}} = %[[ONE]], %{{.*}} = %[[ONE]])21  // CHECK-BLOCKS-NEXT: gpu.launch blocks(%[[B0:.*]], %[[B1:.*]], %[[B2:.*]]) in (%{{.*}} = %[[BOUND]], %{{.*}} = %[[ONE]], %{{.*}} = %[[ONE]]) threads(%[[T0:.*]], %[[T1:.*]], %[[T2:.*]]) in (%{{.*}} = %[[ONE]], %{{.*}} = %[[ONE]], %{{.*}} = %[[ONE]])22  affine.for %i = 0 to 42 {23  // CHECK-THREADS-NEXT: %[[INDEX:.*]] = arith.addi %{{.*}}, %[[T0]]24  // CHECK-THREADS-NEXT: memref.load %{{.*}}[%[[INDEX]]]25  // CHECK-BLOCKS-NEXT: %[[INDEX:.*]] = arith.addi %{{.*}}, %[[B0]]26  // CHECK-BLOCKS-NEXT: memref.load %{{.*}}[%[[INDEX]]]27    %0 = memref.load %A[%i] : memref<?xf32>28    memref.store %0, %B[%i] : memref<?xf32>29    // CHECK-THREADS: gpu.terminator30    // CHECK-BLOCKS: gpu.terminator31  }32  return33}34 35