This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Introduce the concept of DLEN(data path width) into getLMULCost.
ClosedPublic

Authored by craig.topper on Jun 7 2023, 10:24 PM.

Details

Summary

SiFive's x280 CPU has a vector unit that VLEN/2 bits wide. This
means that LMUL=1 operations take 2 to process all VLEN bits.

This patch adds a DLenFactor tuning parameter and applies it to
TuneSiFive7. getLMULCost has been updated to use this factor in
its calculations. I've added an x280 command line to one cost
model test to demonstrate the effect.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 7 2023, 10:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 10:24 PM
craig.topper requested review of this revision.Jun 7 2023, 10:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 10:24 PM
arcbbb accepted this revision.Jun 8 2023, 12:51 AM

LGTM.
The relevant information regarding the 256b ALU pipe can be found in the following link: https://www.sifive.com/cores/intelligence-x280.

This revision is now accepted and ready to land.Jun 8 2023, 12:51 AM
asb added a comment.Jun 12 2023, 7:54 AM

LGTM after you add a doc comment to getDLenFactor.

llvm/lib/Target/RISCV/RISCVSubtarget.h
182

I think we need a comment here to explain the purpose of the method.

reames added inline comments.Jun 12 2023, 7:56 AM
llvm/lib/Target/RISCV/RISCVFeatures.td
808

Can you add a comment here which defines DLEN?

As an organizing principle, I was a bit surprised by the factor description. I was expecting something more along the lines of VLEN (zvlNb) where we have specific sizes and then computed the factor from VLEN/DLEN if needed. Not objecting, just commenting.

835

The default tuning is used for more than the x280, are you sure you want this placement?

llvm/lib/Target/RISCV/RISCVSubtarget.h
182

Needs a comment, and/or a link back to the DLEN definition.

craig.topper added inline comments.Jun 12 2023, 9:51 AM
llvm/lib/Target/RISCV/RISCVFeatures.td
808

Having it as a factor removes the possibility of DLEN > VLEN. It also avoids having one number come from march and one from mtune.

SiFive has 2 CPUs, x280 and p270l, base on the same microarchitecture with different VLEN and DLEN but the factor is 2 for both.

835

We have 2 vector CPUs based on the 7 series microarchitecture. We just haven't put the other in LLVM. They both have factor of 2. So that's what I was thinking when I put this here, but I think I'll move it to x280.

craig.topper planned changes to this revision.Jun 12 2023, 9:51 AM
reames added inline comments.Jun 12 2023, 10:21 AM
llvm/lib/Target/RISCV/RISCVFeatures.td
808

Both pieces make sense, the existence of the sole additional vector cpu with the same property was the context I was missing.

If you want to simply update the comments, I'm fine with the structure given the additional info.

Add comments

This revision is now accepted and ready to land.Jun 12 2023, 7:17 PM