This is an archive of the discontinued LLVM Phabricator instance.

[X86] Support AMX-FP16
ClosedPublic

Authored by xiangzhangllvm on Oct 13 2022, 10:07 PM.

Details

Summary

Support Intel AMX-FP16 instruction

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 10:07 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
xiangzhangllvm requested review of this revision.Oct 13 2022, 10:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 13 2022, 10:07 PM
pengfei added inline comments.Oct 13 2022, 10:36 PM
clang/lib/Basic/Targets/X86.cpp
785

This can be removed.

clang/lib/Headers/immintrin.h
511

Remove

513

Remove

clang/lib/Sema/SemaChecking.cpp
5031

This can be merged together?

pengfei added inline comments.Oct 13 2022, 10:44 PM
clang/test/CodeGen/amx_fp16.c
8

Remove

clang/test/CodeGen/amx_fp16_errors.c
7 ↗(On Diff #467683)

Remove

llvm/lib/Support/X86TargetParser.cpp
586

It should not relate to AVX512FP16.

llvm/lib/Target/X86/X86ISelLowering.cpp
36990–36991

Format the code?

llvm/test/CodeGen/X86/amx_fp16_intrinsics.ll
2

Maybe auto gen it?

2

Why need +avx512f

2

Why need -O0?

6

The comment seems meaningless.

10–11

ditto here.

16–17

ditto here.

pengfei added inline comments.Oct 13 2022, 10:50 PM
clang/test/Driver/x86-target-features.c
293

Change to --target=i386

294

Don't need here.

295–296

ditto.

llvm/include/llvm/IR/IntrinsicsX86.td
5121

Remove

RKSimon added inline comments.Oct 14 2022, 1:15 AM
clang/test/CodeGen/amx_fp16_errors.c
2 ↗(On Diff #467683)

Add 32-bit test coverage to ensure the intrinsics aren't visible?

clang/test/CodeGen/amx_fp16_errors.c
2 ↗(On Diff #467683)

That is better, but let me merge this test into X86/amx_errors.c first : )

llvm/lib/Target/X86/X86ISelLowering.cpp
36990–36991

Make sense, but let's sync with the upper code ? Seems that style is good to reduce line num of the big file. All other comments will be updated soon. thanks a lot!

xiangzhangllvm marked 12 inline comments as done.
LuoYuanke added inline comments.Oct 17 2022, 12:11 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
36986

This code may be merged to int8 and bf16 case.

case X86::PTDPBSSD:
case X86::PTDPBSUD:
case X86::PTDPBUSD:
case X86::PTDPBUUD:
case X86::PTDPBF16PS:
case X86::PTDPFP16PS:
xiangzhangllvm marked 3 inline comments as done.Oct 17 2022, 12:16 AM
xiangzhangllvm added inline comments.
clang/test/Driver/x86-target-features.c
293

It is not good for amx use i386 testing. We need to update the other amx too.

xiangzhangllvm marked an inline comment as done.Oct 17 2022, 12:57 AM
xiangzhangllvm added inline comments.
llvm/lib/Target/X86/X86ISelLowering.cpp
36986

Good catch!

xiangzhangllvm marked an inline comment as done.
RKSimon added inline comments.Oct 17 2022, 1:57 AM
clang/docs/ReleaseNotes.rst
598

Probably mention that this is the for the _tile_dpfp16ps instruction?

llvm/test/MC/Disassembler/X86/x86-64AmxTileFP16-att.txt
4 ↗(On Diff #468130)

in some MC tests we handle att + intel tests in the same file - should we be doing that for all new tests?

LuoYuanke added inline comments.Oct 17 2022, 2:23 AM
llvm/test/MC/X86/x86-64AmxFP16-att.s
2 ↗(On Diff #468130)

There is "test/MC/X86/AMX/" folder. Probably move the test case to that folder or maybe merge the test case to test/MC/X86/AMX/x86-64-amx-bf16-att.s

clang/docs/ReleaseNotes.rst
598

Yes, that is more clear!

llvm/test/MC/Disassembler/X86/x86-64AmxTileFP16-att.txt
4 ↗(On Diff #468130)

That is make sense before, but we begin to use tool to auto generate the tests, it is easy to split them for tool, and we have do that for x86-64-avx512bf16-att/intel.txt x86-64-avx512bf16vl-att/intel.txt x86-64-avx512vp2intersectvl-att/intel.txt and also KEYLOCKER tests.

llvm/test/MC/X86/x86-64AmxFP16-att.s
2 ↗(On Diff #468130)

let me put it into "test/MC/X86/AMX/" folder. And keep the tools generated file. That is more clear.

xiangzhangllvm marked an inline comment as done.
RKSimon added inline comments.Oct 19 2022, 7:55 AM
llvm/test/MC/X86/AMX/x86-64-amx-fp16-att.s
6

merge att/intel testing into the same file and use --check-prefix to test them

RKSimon added inline comments.Oct 20 2022, 8:15 AM
llvm/test/MC/Disassembler/X86/x86-64AmxTileFP16-att.txt
4 ↗(On Diff #468130)

OK - I don't suppose you could ads att/intel functionality to your tool?

xiangzhangllvm added inline comments.Oct 20 2022, 5:11 PM
llvm/test/MC/X86/AMX/x86-64-amx-fp16-att.s
6

Yes, that is our previous action, I think the most benefit is that we can easy to cmp them for same encoding (put them together) not reduce file number.
but now we are try to use tools auto generate/verify them. So split them is more easy/clear for tools generating/verify. (I think it is complex to let tools “by turns” generate same encoding for different style instructions.)
So should we change the old way to let tools easy to auto-gen tests? (And I found we have split them in llvm/test/MC/X86/AMX/ before.)
Thanks again for careful reviewing.

xiangzhangllvm added inline comments.Oct 20 2022, 5:12 PM
llvm/test/MC/Disassembler/X86/x86-64AmxTileFP16-att.txt
4 ↗(On Diff #468130)

The tools is not developed by me, I just use it : )

LuoYuanke added inline comments.Oct 20 2022, 6:46 PM
llvm/test/MC/Disassembler/X86/x86-64AmxTileFP16-intel.txt
1 ↗(On Diff #468421)

Move the test case to test/MC/Disassembler/X86/AMX/?

xiangzhangllvm added inline comments.Oct 20 2022, 6:58 PM
llvm/test/MC/Disassembler/X86/x86-64AmxTileFP16-att.txt
4 ↗(On Diff #468130)

The tools is not developed by me, I just use it : )

Let me sync with the tools' developer, thanks : )

LuoYuanke added inline comments.Oct 20 2022, 7:03 PM
llvm/test/MC/X86/AMX/x86-64-amx-fp16-att.s
6

This is encoding test, it seems we are not able to merge them into one file as below?

// RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding %s | FileCheck %s --check-prefix=ATT-CHECK
// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s --check-prefix=INTEL-CHECK

// ATT-CHECK:      tdpfp16ps       %tmm5, %tmm4, %tmm3
// ATT-CHECK: encoding: [0xc4,0xe2,0x53,0x5c,0xdc]
               tdpfp16ps       %tmm5, %tmm4, %tmm3

// INTEL-CHECK:      tdpfp16ps       tmm3, tmm4, tmm5
// INTEL-CHECK: encoding: [0xc4,0xe2,0x53,0x5c,0xdc]
               tdpfp16ps       tmm3, tmm4, tmm5
pengfei added inline comments.Oct 20 2022, 8:35 PM
llvm/test/MC/X86/AMX/x86-64-amx-fp16-att.s
6

Yes, the tool just fold disassemble test.

yes, so the *.s must be split with intel and att.
So let make same way for disassemble.
Let me first move them into AMX directory.

merge disassembler tests

pengfei accepted this revision.Oct 21 2022, 1:22 AM

LGTM.

This revision is now accepted and ready to land.Oct 21 2022, 1:22 AM
pengfei added inline comments.Oct 21 2022, 1:25 AM
clang/include/clang/Driver/Options.td
4527

This seems a typo?

4531–4532

Better to move them below amx_bf16 for ordering.

clang/lib/Basic/Targets/X86.cpp
891

ditto.

xiangzhangllvm added inline comments.Oct 21 2022, 1:43 AM
clang/include/clang/Driver/Options.td
4527

I think so, should fix in another patch.

4531–4532

let me reorder it when commit. thanks!

LuoYuanke added inline comments.Oct 21 2022, 6:19 AM
clang/include/clang/Driver/Options.td
4531–4532

I fixed it at rG3770d2b9cad9

Hi @RKSimon , I sync with Freddy who also use this tool, we decide to merge the disassembler tests. thanks : )

clang/include/clang/Driver/Options.td
4531–4532

quick action! : )

This revision was landed with ongoing or failed builds.Oct 21 2022, 5:06 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 5:06 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript