Skip to content

Commit

Permalink
Add linalg mlir version of matmul 8x8 kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
compor committed Nov 1, 2023
1 parent 762ad8f commit 7f41e83
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions kernels/matmul/8x8xf64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ include ../../../snitch/Makefile.rules

TESTS =
TESTS += baseline.x
TESTS += linalg.x

include ../../Makefile.kernels
12 changes: 12 additions & 0 deletions kernels/matmul/8x8xf64/linalg.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
func.func public @matmul(%X: memref<8x8xf64>,
%Y: memref<8x8xf64>,
%Z: memref<8x8xf64>) {
"linalg.generic"(%X, %Y, %Z) ({
^bb0(%x: f64, %y: f64, %z: f64):
%r0 = arith.mulf %x, %y : f64
%r1 = arith.addf %z, %r0 : f64
"linalg.yield"(%r1) : (f64) -> ()
}) {indexing_maps = [affine_map<(m, n, k) -> (m, k)>, affine_map<(m, n, k) -> (k, n)>, affine_map<(m, n, k) -> (m,
n)>], iterator_types = [#linalg.iterator_type<parallel>, #linalg.iterator_type<parallel>, #linalg.iterator_type<reduction>], operand_segment_sizes = array<i32: 2, 1>} : (memref<8x8xf64>, memref<8x8xf64>, memref<8x8xf64>) -> ()
func.return
}
11 changes: 11 additions & 0 deletions kernels/matmul/8x8xf64/linalg.xdsl.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
func.func public @matmul(%X: memref<8x8xf64>,
%Y: memref<8x8xf64>,
%Z: memref<8x8xf64>) {
"linalg.generic"(%X, %Y, %Z) ({
^bb0(%x: f64, %y: f64, %z: f64):
%r0 = arith.mulf %x, %y : f64
%r1 = arith.addf %z, %r0 : f64
"linalg.yield"(%r1) : (f64) -> ()
}) {indexing_maps = [affine_map<(m, n, k) -> (m, k)>, affine_map<(m, n, k) -> (k, n)>, affine_map<(m, n, k) -> (m, n)>], iterator_types = [#linalg.iterator_type<parallel>, #linalg.iterator_type<parallel>, #linalg.iterator_type<reduction>], operandSegmentSizes = array<i32: 2, 1>} : (memref<8x8xf64>, memref<8x8xf64>, memref<8x8xf64>) -> ()
func.return
}

0 comments on commit 7f41e83

Please sign in to comment.