Why does fflags serialize independent fmadd.s instructions in the same warp?

Offen
#503 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
22/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Bereich
performance

Rechercherichtung

This is a microarchitecture question, not a scoped edit. Start by reading the decode-stage reservation of XREG_0 for fflags and the FPU writeback/scoreboard path in the RV32 core; run the attached fflags-repro.zip under rtlsim and reproduce the 16-cycle issue interval. Done means either identifying the ordering constraint that requires serialization or demonstrating a safe overlap that preserves FP flag semantics and measuring it with the same loop.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Hi, I'm trying to get Vortex's FP32 throughput close to its theoretical peak. I noticed a stall while testing a loop of independent FMAs on a 4-wide issue configuration. I reran the loop in rtlsim on the default RV32 core with only one warp active so I could count the cycles between FMAs in the issue trace. Here are two consecutive instructions from the loop.

fmadd.s f8, f0, f1, f2, rne
fmadd.s f9, f0, f1, f2, rne

The second instruction waits for the first one to write back even though they write different registers. In the trace, consecutive FMAs from this warp issue 16 cycles apart. Both reserve XREG_0 for fflags in decode. As a quick test I skipped that reservation for the FMAs and left the FPU flag update alone. The issue interval dropped to 9 cycles.

On some configurations the fflags check barely affects throughput. For example, with all four warps active on the default core, the two-entry FPU queue already limits how fast the core can issue FMAs.

What got me looking at this was trying to keep all four FMA pipelines busy on the 4-wide core. Together they can take four warp FMAs per cycle. With 32 active warps and both the FPU and dispatch queues at depth 8, I measured 1.88 warp FMAs per cycle. Bypassing just the fflags check brought that up to 3.16. That's about 1.3 more FMAs the core could have issued each cycle while those warps were waiting on fflags.

I measured throughput in warp FMAs issued per core cycle. The last column shows the throughput loss relative to the run with the interlock bypassed.

Hardware Active warps Loop Current interlock Bypassed Throughput loss
Default RV32 1 Independent FMAs 0.0623 0.1099 43.3%
Default RV32 4 Independent FMAs 0.1996 0.2000 0.2%
Default RV32, only the FPU queue raised from 2 to 8 4 Independent FMAs 0.2492 0.4389 43.2%
Four 32-lane compute slices, FPU and dispatch queues both at 8 32 Independent FMAs 1.875 3.164 40.7%
Same four-slice core 32 Single-accumulator FMA chain 1.769 1.769 0.0%

I understand why a later frflags has to wait for the flags. What I'm wondering is why the next FMA has to wait too. If the loop never touches the FP CSRs explicitly and the FPU ORs the flags together anyway, is there another ordering constraint I'm missing?

If there's no other reason these FMAs need to serialize, I'd be happy to try a change that lets them overlap.

I've attached the small test and the commands I used to run it.

fflags-repro.zip

Tested on Vortex commit 1061088aa91bd6f295d91945832acdc8408223c4

Vorherrschende Sprache
Verilog
Sterne
2.4k
Forks
563
Ø Merge
2 T. 12 Std.
Gemergte PRs (30 T.)
33

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus vortexgpgpu/vortex

Alle Issues in vortexgpgpu/vortex

Ähnliche Issues

Weitere Issues zu Performance

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.