This is an archive of the discontinued LLVM Phabricator instance.

[mlir][AMDGPU] 8-bit float usage in the AMDGPU dialect
ClosedPublic

Authored by krzysz00 on Feb 13 2023, 3:18 PM.

Details

Summary

Upcoming AMD hardware will include functions that accept 8-bit floats.
Specifically, there are MFMA instructions that accept 8-bit floats,
either using the same or mixed formats. This patch adds MLIR wrappers
for these intrinsics and explicitly adds support for 8-bit floats in
the gpu-to-rocdl conversion by way of amdgpu-to-rocdl.

Since LLVM does not have f8 types, when targeting LLVM for compilation
on an AMD GPU, both f8 types used on AMD hardware (f8E5M2FNUZ and
f8E4M3FNUZ) are rewritten to i8.

This patch also relaxes the restriction that the types of both source
operands to a amdgpu.mfma instructions match exactly, as this is not
necessarily required for the bf8 (f8E5M2FNUZ) and fp8 (f8E4M3FNUZ)
instructions. In addition, since the buffer_{load,store} operations
maintain a whitelist of permitted types, we add the relevant f8 types
to that list.

This patch does not add any implementations of arithmetic operations
for f8 types.

Diff Detail

Event Timeline

krzysz00 created this revision.Feb 13 2023, 3:18 PM
Herald added a project: Restricted Project. · View Herald Transcript
krzysz00 requested review of this revision.Feb 13 2023, 3:18 PM
jakeh-gc accepted this revision.Feb 15 2023, 3:28 AM
jakeh-gc added a subscriber: jakeh-gc.
jakeh-gc added inline comments.
mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp
411

typo: varifier -> verifier.

This revision is now accepted and ready to land.Feb 15 2023, 3:28 AM
krzysz00 marked an inline comment as done.Feb 15 2023, 8:45 AM
This revision was landed with ongoing or failed builds.Feb 15 2023, 8:46 AM
This revision was automatically updated to reflect the committed changes.