Skip to content

[P1] Support Non-Constant Loop Bound Counter Creation #299

@ShangkunLi

Description

@ShangkunLi

In the current taskflow.counter creation, we only support the constant loop bound. We need to support non-constant loop bounds like"

func.func @_Z6kerneliiPfPiS0_PS_S1_(%arg0: i32, %arg1: i32, %arg2: memref<?xf32>, %arg3: memref<?xi32>, %arg4: memref<?xi32>, %arg5: memref<?xmemref<?xf32>>, %arg6: memref<?xmemref<?xf32>>) attributes {llvm.linkage = #llvm.linkage<external>} {
    %c-1 = arith.constant -1 : index
    %c0 = arith.constant 0 : index
    %0 = arith.index_cast %arg1 : i32 to index
    %1 = arith.muli %arg0, %arg1 : i32
    %2 = arith.index_cast %1 : i32 to index
    affine.for %arg7 = 0 to %2 {
      %3 = arith.index_cast %arg7 : index to i32
      %4 = arith.remsi %3, %arg1 : i32
      %5 = arith.cmpi slt, %arg7, %c0 : index
      %6 = arith.subi %c-1, %arg7 : index
      %7 = arith.select %5, %6, %arg7 : index
      %8 = arith.divsi %7, %0 : index
      %9 = arith.subi %c-1, %8 : index
      %10 = arith.select %5, %9, %8 : index
      %11 = memref.load %arg2[%10] : memref<?xf32>
      %12 = memref.load %arg3[%10] : memref<?xi32>
      %13 = arith.index_cast %12 : i32 to index
      %14 = memref.load %arg5[%13] : memref<?xmemref<?xf32>>
      %15 = arith.index_cast %4 : i32 to index
      %16 = memref.load %14[%15] : memref<?xf32>
      %17 = arith.mulf %11, %16 : f32
      %18 = memref.load %arg4[%10] : memref<?xi32>
      %19 = arith.index_cast %18 : i32 to index
      %20 = memref.load %arg6[%19] : memref<?xmemref<?xf32>>
      %21 = memref.load %20[%15] : memref<?xf32>
      %22 = arith.addf %21, %17 : f32
      memref.store %22, %20[%15] : memref<?xf32>
    }
    return
  }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions