This is an archive of the discontinued LLVM Phabricator instance.

[schedtool] Add schedtool to generate x86 schedmodel automatically
Needs ReviewPublic

Authored by HaohaiWen on Aug 1 2022, 6:09 AM.

Details

Reviewers
RKSimon
Summary

Manually writing/maintaining schedule model is time-consuming and
error-prone. This patch introduces list of tools that help to auto
generate x86 schedule model. Currently, it's only capable to generate
alderlake-p schedmodel. However, it's easy to extend it to support more
target. Read llvm/utils/schedtool/README.md for more details.

Diff Detail

Event Timeline

HaohaiWen created this revision.Aug 1 2022, 6:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 6:09 AM
HaohaiWen requested review of this revision.Aug 1 2022, 6:09 AM
RKSimon added a subscriber: RKSimon.Aug 1 2022, 7:59 AM
RKSimon added inline comments.
llvm/utils/schedtool/xed-patch/0001-Dump-eosz-and-operand-s-xtype-width-when-verbosity-i.patch
14

TBH I don't think its acceptable to include patches for another project inside llvm

HaohaiWen added inline comments.Aug 2 2022, 3:27 AM
llvm/utils/schedtool/xed-patch/0001-Dump-eosz-and-operand-s-xtype-width-when-verbosity-i.patch
14

I'm planning to put this tool in a single git repo. But it may takes a few weeks even several months to request...
So I put this tool in here first as a workaround so that people who are interested in it can discuss here.

Matt added a subscriber: Matt.Aug 2 2022, 10:15 PM
HaohaiWen updated this revision to Diff 449619.Aug 3 2022, 3:07 AM

Rename alderlake to alderlake-p

HaohaiWen edited the summary of this revision. (Show Details)Aug 3 2022, 3:08 AM
HaohaiWen planned changes to this revision.Sep 4 2022, 5:55 PM
HaohaiWen updated this revision to Diff 472856.Nov 3 2022, 12:39 AM

Rebase patch

HaohaiWen updated this revision to Diff 472857.Nov 3 2022, 12:41 AM

Remove old alderlake.td template file

@HaohaiWen Something I've noticed is that the autogen AlderlakeP model has a LOT of single match instregex entries (and in fact the regex is written to be a single match) - which are a lot slower to match/compile in llvm-tblgen than instr equivalents - see https://github.com/llvm/llvm-project/issues/35303

I added a dbg dump to InstRegexOp::apply to warn about single intregex matches and many of them are coming from AlderlakeP.

Completely random example (it was just where the I paused the debugger):

def ADLPWriteResGroup222 : SchedWriteRes<[ADLPPort00_01, ADLPPort00_01_05, ADLPPort00_06, ADLPPort01_05]> {
  let ResourceCycles = [2, 2, 1, 2];
  let Latency = 6;
  let NumMicroOps = 7;
}
def : InstRW<[ADLPWriteResGroup222], (instregex "^SHA1MSG2rr$")>;

That could just as well be (instrs SHA1MSG2rr)

HaohaiWen updated this revision to Diff 474767.Nov 11 2022, 7:52 AM

Replace simple instregex with instrs to boost tblgen match speed

HaohaiWen updated this revision to Diff 474768.Nov 11 2022, 7:55 AM
HaohaiWen marked an inline comment as done.

Delete misadded files

def ADLPWriteResGroup222 : SchedWriteRes<[ADLPPort00_01, ADLPPort00_01_05, ADLPPort00_06, ADLPPort01_05]> {
  let ResourceCycles = [2, 2, 1, 2];
  let Latency = 6;
  let NumMicroOps = 7;
}
def : InstRW<[ADLPWriteResGroup222], (instregex "^SHA1MSG2rr$")>;

That could just as well be (instrs SHA1MSG2rr)

Fixed

HaohaiWen planned changes to this revision.Nov 24 2022, 5:05 AM
craig.topper added inline comments.
llvm/utils/schedtool/README.md
2

coolection -> collection

52

matachable -> matchable

craig.topper added inline comments.Nov 24 2022, 5:43 PM
llvm/utils/schedtool/lib/info_parser.py
20

Unknow->Unknown

26

Unknow->Unknown

llvm/utils/schedtool/lib/target.py
21

Unknown*

llvm/utils/schedtool/llvm-patch/0003-Add-gen-x86-inst-sched-info-to-emit-x86-instruction-.patch
164

Unknown*

172

Unknown*

180

Unknown*

200

Unknown*

346

Unknown*

HaohaiWen planned changes to this revision.Nov 25 2022, 12:58 AM
HaohaiWen marked 10 inline comments as done.
HaohaiWen updated this revision to Diff 479532.Dec 2 2022, 12:24 AM

Generate asm string for CodeGenOnly but encodable instructions

HaohaiWen planned changes to this revision.Dec 2 2022, 12:24 AM
HaohaiWen updated this revision to Diff 480010.Dec 5 2022, 12:59 AM

Don't match CodeGenOnly opcodes by default

HaohaiWen planned changes to this revision.Dec 5 2022, 12:59 AM
HaohaiWen updated this revision to Diff 486471.Jan 4 2023, 9:57 PM

Don't match CodeGenOnly instructions with lock prefix. Add default LoadUOps argument.

HaohaiWen planned changes to this revision.Jan 4 2023, 10:00 PM
HaohaiWen updated this revision to Diff 488432.Jan 11 2023, 5:17 PM

Support sapphirerapids target

HaohaiWen updated this revision to Diff 500033.Feb 23 2023, 6:34 PM

Fix conflict and update proc resource group in alderlake-p template

HaohaiWen planned changes to this revision.Feb 23 2023, 6:35 PM
HaohaiWen updated this revision to Diff 520350.May 8 2023, 6:38 AM

Rebase llvm-patch and fix confliction

HaohaiWen planned changes to this revision.May 8 2023, 6:40 AM
HaohaiWen updated this revision to Diff 520575.May 8 2023, 8:15 PM

Add IcelakeServer target

HaohaiWen updated this revision to Diff 520577.May 8 2023, 8:29 PM

[add_smv_uopsinfo] Fix resource mapping which never worked before

Just found this bug. It's important to map ports from older arch to new arch

HaohaiWen updated this revision to Diff 520591.May 8 2023, 10:15 PM

Remove port237 in AlderlakeP template