S8.14.1 Compare Two Cores Fairly

MediumImplement22 minIcarus Verilog · serverReview the topic

Turn windows read from mcycle into scores per MHz and per second. Then decide which build of ap_rv32 is really faster.

Hardware context: An in-house checksum kernel on both builds of ap_rv32, timed between two reads of mcycle. Benchmarking and core selection

This is the checksum kernel of lesson S8.14 with its inner loop unrolled. It has eight copies of the body and no inner branch. Both builds of ap_rv32 ran it. The table gives the window that each read from mcycle. Each window holds the two counter reads as well.

This worksheet uses named constants. The first three entries show how to record your decisions.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification
Iterations in the runSingle-cycle windowFive-stage window
144 cycles50 cycles
10422 cycles446 cycles
20842 cycles886 cycles
ItemValue
ClocksSingle-cycle 65 MHz, five-stage 100 MHz (exercise values, as in S8.14).
Instructions for each iteration42 on both builds: the same program.
Cycles for each iterationTake two long runs and divide the difference of their windows by the difference of their iterations.
UnitsA score per MHz is iterations for each million cycles. Enter it in hundreds, cut down: 23,456 is 234.

Enter CPI and IPC in hundredths, rounded to the nearest: 1.27 is 127. Enter a core as 1 for the single-cycle core and 2 for the five-stage core.

EntryYour decision
SINGLE_ITERCycles for each iteration on the single-cycle core, in a long run.
FIVE_ITERCycles for each iteration on the five-stage core, in a long run.
FIVE_CPICPI of the five-stage core in a long run, in hundredths.
FIVE_IPCIPC of the five-stage core in a long run, in hundredths.
SINGLE_PER_MHZScore per MHz of the single-cycle core, in hundreds.
FIVE_PER_MHZScore per MHz of the five-stage core, in hundreds.
MHZ_WINNERWhich core has the higher score per MHz?
SECOND_WINNERWhich core has the higher score for each second, at its own clock?
LEAD_PERCENTBy how many percent does that core lead, per second? Cut down to a whole number.
CLOCK_NEEDEDThe lowest whole clock in MHz at which the single-cycle core would match or pass the five-stage core at 100 MHz.
SHORT_PER_MHZA careless test runs one iteration on the five-stage core and uses its whole window. What score per MHz does it report, in hundreds?
LOST_TO_BRANCHHow many cycles of each iteration does the five-stage core lose to taken branches, in a long run?
WINNER_AT_MHZThe five-stage core stays at 100 MHz. The single-cycle core runs at MHZ. Which one has the higher score for each second? 1 for the single-cycle core, 2 for the five-stage core.

Examples

Example 1

SINGLE ITER
Input
Cycles for each iteration on the single-cycle core, in a long run.
Output
matches = 1

842 − 422 = 420 cycles for 10 more iterations.

Example 2

FIVE ITER
Input
Cycles for each iteration on the five-stage core, in a long run.
Output
matches = 1

886 − 446 = 440 cycles for 10 more iterations.

Example 3

FIVE CPI
Input
CPI of the five-stage core in a long run, in hundredths.
Output
matches = 1

44 cycles for 42 instructions is 1.048, rounded 1.05.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For WINNER_AT_MHZ, enter a constant expression using MHZ. Only this entry changes with the parameter. The supported integer range is 65 through 120, inclusive.

Hints

Hint 1

Use two long runs, so that the counter reads cancel out.

Hint 2

Per MHz is 1,000,000 divided by the cycles. Per second multiplies by the clock.

Hint 3

A score per MHz says nothing about the clock that a core reaches.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

13 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 problem on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

SINGLE ITER

Input
Cycles for each iteration on the single-cycle core, in a long run.
Expected output
matches = 1

842 − 422 = 420 cycles for 10 more iterations.

Run samples executes all 3 public checks. Check all tests runs 13 checks on the server.

Icarus Verilog · server