Skip to content

Commit

Permalink
Adding memref normalization of affine.prefetch (#89675)
Browse files Browse the repository at this point in the history
Added support for memref-normalization for prefetch.

Signed-off-by: Alexandre Eichenberger <[email protected]>
  • Loading branch information
AlexandreEichenberger authored Apr 30, 2024
1 parent 8d28e58 commit a7b968a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,8 @@ def AffineParallelOp : Affine_Op<"parallel",
}

def AffinePrefetchOp : Affine_Op<"prefetch",
[DeclareOpInterfaceMethods<AffineMapAccessInterface>]> {
[DeclareOpInterfaceMethods<AffineMapAccessInterface>,
MemRefsNormalizable]> {
let summary = "affine prefetch operation";
let description = [{
The `affine.prefetch` op prefetches data from a memref location described
Expand Down
16 changes: 16 additions & 0 deletions mlir/test/Dialect/MemRef/normalize-memrefs-ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,19 @@ func.func @test_norm_reinterpret_cast(%arg0 : memref<3xf32, #map_1d_tile>) -> (m
// CHECK: memref.reinterpret_cast %[[v0]] to offset: [0], sizes: [3, 1, 1], strides: [1, 1, 1] : memref<3xf32> to memref<3x1x1xf32>
return %1 : memref<3x1x1xf32>
}


// -----

// Test normalization of memrefs for prefetch.affine

// CHECK-LABEL: func.func @prefetch_normalize
// CHECK-SAME: ([[PARAM_0_:%.+]]: memref<16x32xf32>) {
func.func @prefetch_normalize(%arg0: memref<512xf32, affine_map<(d0) -> (d0 floordiv 32, d0 mod 32)>>) -> () {
// CHECK: affine.for [[I_0_:%.+]] = 0 to 8 {
affine.for %arg3 = 0 to 8 {
// CHECK: affine.prefetch [[PARAM_0_]]{{.}}[[I_0_]] floordiv 32, [[I_0_]] mod 32], read, locality<3>, data : memref<16x32xf32>
affine.prefetch %arg0[%arg3], read, locality<3>, data : memref<512xf32, affine_map<(d0) -> (d0 floordiv 32, d0 mod 32)>>
}
return
}

0 comments on commit a7b968a

Please sign in to comment.