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 %s 2// 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 %s 3 4// CHECK-THREADS-LABEL: @one_d_loop 5// CHECK-BLOCKS-LABEL: @one_d_loop 6func.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 : index 9 // CHECK-THREADS-NEXT: %{{.*}} = arith.constant 42 : index 10 // CHECK-THREADS-NEXT: %[[BOUND:.*]] = arith.subi %{{.*}}, %{{.*}} : index 11 // CHECK-THREADS-NEXT: %{{.*}} = arith.constant 1 : index 12 // CHECK-THREADS-NEXT: %[[ONE:.*]] = arith.constant 1 : index 13 // 14 // CHECK-BLOCKS-NEXT: %{{.*}} = arith.constant 0 : index 15 // CHECK-BLOCKS-NEXT: %{{.*}} = arith.constant 42 : index 16 // CHECK-BLOCKS-NEXT: %[[BOUND:.*]] = arith.subi %{{.*}}, %{{.*}} : index 17 // CHECK-BLOCKS-NEXT: %{{.*}} = arith.constant 1 : index 18 // CHECK-BLOCKS-NEXT: %[[ONE:.*]] = arith.constant 1 : index 19 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.terminator 30 // CHECK-BLOCKS: gpu.terminator 31 } 32 return 33} 34 35