Why does fflags serialize independent fmadd.s instructions in the same warp?
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- performance
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
Tested on Vortex commit 1061088aa91bd6f295d91945832acdc8408223c4
- Dominant language
- Verilog
- Stars
- 2.4k
- Forks
- 563
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 71
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vortexgpgpu/vortex
-
RV64 signed DIV/REM restores the sign from bit 31Possibly taken @zzf2024 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vortexgpgpu/vortex#501 · 1 comment ·
Maintainers usually reply within 1 day
-
fpu: sign-extend RV64 FCVT.WU positive overflow resultsPossibly taken @zzf2024 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
vortexgpgpu/vortex#499 · 1 comment ·
Maintainers usually reply within 1 day
-
WGMMA: the next kernel can compute with the previous kernel's B row left in the B buffer (rtlsim)Possibly taken @youzi27 claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vortexgpgpu/vortex#558 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
vortexgpgpu/vortex#521 ·
Maintainers usually reply within 1 day
-
WGMMA: a block-major B tile can read K-major data left in the B buffer (rtlsim)Possibly taken @youzi27 claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vortexgpgpu/vortex#518 ·
Maintainers usually reply within 1 day
All issues in vortexgpgpu/vortex
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
solidjs/solid-router#757 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
keystonejs/keystone#10143 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
area:server kind:perf priority:p2 ready
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day