1 // RUN: mlir-opt -convert-affine-for-to-gpu="gpu-block-dims=1 gpu-thread-dims=1" %s | FileCheck %s
3 // CHECK-LABEL: @step_var
4 func @step_var(%A : memref<?x?xf32>, %B : memref<?x?xf32>) {
5 // Check that we divide by step.
6 // CHECK: %[[range_i:.*]] = arith.divsi {{.*}}, %{{.*}}
7 // CHECK: %[[range_j:.*]] = arith.divsi {{.*}}, %{{.*}}
10 // CHECK-SAME: blocks(%{{[^)]*}}, %{{[^)]*}}, %{{[^)]*}}) in (%{{[^)]*}} = %[[range_i]], %{{[^)]*}} = %{{[^)]*}}, %{{[^)]*}} = %{{[^)]*}})
11 // CHECK-SAME: threads(%{{[^)]*}}, %{{[^)]*}}, %{{[^)]*}}) in (%{{[^)]*}} = %[[range_j]], %{{[^)]*}} = %{{[^)]*}}, %{{[^)]*}} = %{{[^)]*}})
12 affine.for %i = 5 to 15 step 4 {
13 affine.for %j = 3 to 19 step 7 {
14 // Loop induction variable remapping:
15 // iv = thread(block)_id * step + lower_bound
16 // CHECK: %[[prod_i:.*]] = arith.muli %{{.*}}, %{{.*}} : index
17 // CHECK-NEXT: %[[i:.*]] = arith.addi %{{.*}}, %[[prod_i]] : index
18 // CHECK-NEXT: %[[prod_j:.*]] = arith.muli %{{.*}}, %{{.*}} : index
19 // CHECK-NEXT: %[[j:.*]] = arith.addi %{{.*}}, %[[prod_j]] : index
21 // CHECK: {{.*}} = memref.load %{{.*}}[%[[i]], %[[j]]] : memref<?x?xf32>
22 %0 = memref.load %A[%i, %j] : memref<?x?xf32>
23 // CHECK: memref.store {{.*}}, %{{.*}}[%[[i]], %[[j]]] : memref<?x?xf32>
24 memref.store %0, %B[%i, %j] : memref<?x?xf32>