View Issue Details

IDProjectCategoryView StatusLast Update
0036517FPCCompilerpublic2020-05-06 14:55
ReporterNoName Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionno change required 
Product Version3.3.1 
Summary0036517: Add AMD CPU Ryzen target
DescriptionThe XCHG optimisation (https://bugs.freepascal.org/view.php?id=36511 - thx J. Gareth Moreton!) makes assumptions on the CPU target but unfortunately there is no AMD Ryzen target.
Might also makes sense for other optimizations as AMD != Intel and therefore several instructions are faster/slower or should be avoided (e.g. RDRAND on unpatched CPU firmwares).
Steps To ReproduceAccording to https://www.agner.org/optimize/instruction_tables.pdf the XCHG is as fast as the MOV operation (tested on first gen of AMD Ryzen).
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

J. Gareth Moreton

2020-01-05 01:58

developer   ~0120225

Last edited: 2020-01-05 01:59

View 2 revisions

I did notice that XCHG was generally better-implemented on AMD processors than Intel. For the case of XCHG, I think Ryzen will get the XCHG optimisation because it's considered "greater than" Core I.

One thing to be careful of though is that the processors are internally listed in order of earliest to latest, so if Ryzen appears, it has to be treated as better at everything or worse at everything compared to another entry.

Still, sometimes people might know the AMD processors better than the Intel ones, and Ryzen can be internally considered a synonym to Cascade Lake, for example. Might need some discussion though to decide exactly how this should be implemented.

P.S. I've been using Agner as my reference as well.

Thaddy de Koning

2020-01-05 09:59

reporter   ~0120227

IIRC AMD uses register renaming for xchg and always did.

Florian

2020-01-06 22:21

administrator   ~0120243

So far, there are no specific optimizations for Ryzen, for all Zen based AMD CPUs and Intel Haswell and newer, using -CpCOREAVX2 -OpCOREAVX2 is fine.

Issue History

Date Modified Username Field Change
2020-01-04 23:42 NoName New Issue
2020-01-05 01:58 J. Gareth Moreton Note Added: 0120225
2020-01-05 01:59 J. Gareth Moreton Note Edited: 0120225 View Revisions
2020-01-05 09:59 Thaddy de Koning Note Added: 0120227
2020-01-06 22:21 Florian Assigned To => Florian
2020-01-06 22:21 Florian Status new => resolved
2020-01-06 22:21 Florian Resolution open => no change required
2020-01-06 22:21 Florian FPCTarget => -
2020-01-06 22:21 Florian Note Added: 0120243
2020-05-06 14:55 NoName Status resolved => closed