This is an archive of the discontinued LLVM Phabricator instance.

[flang] add fused matmul-transpose to the runtime
ClosedPublic

Authored by tblah on Mar 13 2023, 10:09 AM.

Details

Summary

This fused operation should run a lot faster than first transposing the
lhs array and then multiplying the matrices separately.

Based on flang/runtime/matmul.cpp

Depends on D145959

Diff Detail

Event Timeline

tblah created this revision.Mar 13 2023, 10:09 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a subscriber: sunshaoce. · View Herald Transcript
tblah requested review of this revision.Mar 13 2023, 10:09 AM
jeanPerier added a reviewer: klausler.

Can the original MATMUL be extended in place as template(s) with one or two argument transposition flags, so that all the runtime APIs have a common implementation?

flang/runtime/matmul-transpose.cpp
210

Always use braces in the runtime, here and throughout.

tblah updated this revision to Diff 505583.Mar 15 2023, 11:57 AM

Thanks for review. I've updated to initialize using braces.

The original MATMUL could be extended in place but I think it wouldn't share
enough code to be worth the worsened readability. The optimal iteration order
of the loops is different for MatmulTranspose so the implementation would be
entirely separate. The only shared code would be the boilerplate around type
dispatch, which is already duplicated in other runtime functions.

klausler added inline comments.Mar 15 2023, 12:03 PM
flang/runtime/matmul-transpose.cpp
210

I meant braces around the then/else parts of the if statement, not the right-hand sides of the assignment statements.

tblah updated this revision to Diff 505589.Mar 15 2023, 12:14 PM
  • Undo previous change
  • Add braces around if blocks
klausler added inline comments.Mar 15 2023, 12:17 PM
flang/runtime/matmul-transpose.cpp
147

Braced initialization is used in the runtime for improved protection against inadvertent truncation.

klausler accepted this revision.Mar 15 2023, 12:17 PM
This revision is now accepted and ready to land.Mar 15 2023, 12:17 PM
tblah updated this revision to Diff 505749.Mar 16 2023, 3:12 AM

Use braced initialization

This revision was automatically updated to reflect the committed changes.