Core Clusters: Instruction Issue and the Choice of a Core

Your camera preview has a deadline for every frame, and a cluster can offer two kinds of core. One is wide and hungry, the other narrow and frugal. Which one should run the job?

You Will Be Able To

  • Follow five instructions through a wide out-of-order core and a narrow in-order core, cycle by cycle.
  • Choose a core using the frame deadline and the energy for one completed frame.
  • Tell a pair of cores that share work from a pair that checks itself.
Lesson
S10.13
Time
30 min
Runs on
Your browser
Check
5 questions

The job for one camera frame loads a header, and a pointer to the next buffer. Each load takes six cycles.

A wide core has two slots in every cycle. Does it fill them while a load is out?

Before You Start

You need Beyond Five Stages: issue width, a superscalar core, a dependency, in order.

You need Out-of-Order Execution: an out-of-order core starts an instruction when its inputs are ready.

You need The Reorder Buffer: results retire in program order.

You need The Cache Hierarchy of a Core Cluster: private caches, and what a moved job finds there.

You need Power Modes and the Energy of a Sleep: 1 mW for 1 microsecond is 1 nJ.

Five questions this page answers
Question
1What does a two-wide core do when its oldest instruction waits?
2What does out-of-order issue gain, and what must it keep?
3Why would one cluster hold two kinds of core?
4A job has a deadline. How do you pick the core that runs it?
5Why is a lockstep pair not two workers?

The Idea: Fill the Slots, Meet the Deadline, Count One Worker

A core of a cluster can be built in two ways. A performance core is wide and out of order. It can start two or more instructions in a cycle. When the oldest one waits, younger ready ones go first.

An efficiency core is narrow and in order. It starts one instruction in a cycle, and it stops at every wait. It is smaller, and it draws less power while it runs.

Both kinds still make results final in program order. Software never sees the younger instruction go first.

A cluster that holds both kinds is a mixed cluster. Textbooks call it heterogeneous.

Which core should run a job? Speed alone does not decide, and power alone does not either. Each frame has a frame deadline: the time by which its job must be done.

A core that would finish late is out. Among the cores that are left, the one that spends the least energy on the whole job wins.

There is a third way to use two cores. Both run the same job at the same time, and every result is compared. That is a lockstep pair. It finds a circuit that gives a wrong bit, but it does one job, not two.

One word on the chip. The two kinds of core on this page are a teaching pair. ap_phone, the exercise chip of this module, has 8 equal cores.

New Words

New words on this page
WordMeaning
Issue of an instructionTo send an instruction to the unit that does its work. From then on it runs. Issue width caps how many issue in a cycle.
Issue slotOne place for an instruction in the issue of one cycle. A two-wide core has two slots.
Ready instructionAn instruction whose input has arrived: the result it needs exists.
Performance coreA wide out-of-order core. It finishes a job sooner and draws more power while it runs.
Efficiency coreA narrow in-order core. It takes longer and draws less power while it runs.
Mixed clusterA cluster with more than one kind of core.
Frame jobThe work that software hands to one core for one frame of the camera.
Frame deadlineThe time by which a frame job must be done, counted from its start.
Active powerThe power a core draws while it runs the job.
Energy of a frameActive power times the time that the frame job runs.
Lockstep pairTwo cores that run the same job at the same time, with every result compared.

Units on this page: milliwatts (mW), microseconds and nanojoules (nJ). 1 mW for 1 microsecond is 1 nJ.

One Picture: One Wide Core, Cycle by Cycle

The picture and the lab use five instructions from a frame job. Two of them load from memory, and each load takes 6 cycles.

Five instructions of a frame job
NumberInstructionNeeds the result ofResult after
1load headernothing6 cycles
2test headerinstruction 11 cycle
3load pointernothing6 cycles
4add addressinstruction 31 cycle
5store addressinstruction 41 cycle

Program order is 1 to 5. Instruction 1 is the oldest.

One Wide Core, Cycle by CycleStep through the picture. It follows the five instructions of the hand example through the performance core.
  • Memory
  • Control / FSM
  • Processor
  • Bus
One Wide Core, Cycle by CycleStep through the picture. It follows the five instructions of the hand example through the performance core. component Waitinginstructions fetched, not yetissued, oldest first component Issue two slots in eachcycle component Load unit a result after 6cycles component Adder a result after 1cycle component Reorder buffer keeps program order:S2.32 component Retire up to two finalresults a cycle,oldest first ready onesloadssums and testsresultresultin program order
  1. component Waiting instructionsfetched, not yet issued, oldest first
    • ready ones → Issue
  2. component Issuetwo slots in each cycle
    • loads → Load unit
    • sums and tests → Adder
  3. component Load unita result after 6 cycles
    • result → Reorder buffer
  4. component Addera result after 1 cycle
    • result → Reorder buffer
  5. component Reorder bufferkeeps program order: S2.32
    • in program order → Retire
  6. component Retireup to two final results a cycle, oldest first
  1. Cycle 0: the first slot

    Instruction 1 loads the header. It issues at once. Instruction 2 tests the header, so it must wait for that load.

  2. Cycle 0: the second slot

    An in-order core would leave this slot empty. This core passes instruction 2 and issues 3, the load of the next pointer.

  3. Cycles 1 to 5: two waits at once

    Nothing is ready, so nothing issues. But both loads are on their way, and they wait at the same time.

  4. Cycle 6: both loads answer

    Instruction 2 can test the header, and 4 can add to the pointer. Both issue. Instruction 1 retires.

  5. Cycles 7 and 8: order is kept

    Instruction 3 had its result at cycle 6. It retires at 7, together with 2, which is older. Then 4 and 5 retire.

Read the diagram as text
  • Waiting instructions: fetched, not yet issued, oldest first
  • Issue: two slots in each cycle
  • Load unit: a result after 6 cycles
  • Adder: a result after 1 cycle
  • Reorder buffer: keeps program order: S2.32
  • Retire: up to two final results a cycle, oldest first
  • Waiting instructions → Issue: ready ones
  • Issue → Load unit: loads
  • Issue → Adder: sums and tests
  • Load unit → Reorder buffer: result
  • Adder → Reorder buffer: result
  • Reorder buffer → Retire: in program order

The performance core of the lab. The waits of 6 and 1 cycles are lab choices.

The Smallest Example, Worked by Hand

No simulator yet. The lab has three model cores. Two of them are the kinds of the cluster. The third is there to separate width from order.

The three model cores of the lab
CoreWidthOrderStands for
P2out of orderthe performance core
W2in ordera thought experiment: width without out-of-order issue
E1in orderthe efficiency core

All three retire in program order, as many in a cycle as they can issue.

Follow P, the performance core. In each cycle, list the instructions that are ready, and issue up to two of them, oldest first.

The performance core, cycle by cycle
CycleReady to issueIssuesResults that arriveRetires
01 and 31 and 3
1 to 5nonenone
62 and 42 and 41 and 31
7552 and 42 and 3
854 and 5

Retiring at cycle 8 means the job takes cycles 0 to 8: nine cycles.

Look at cycle 0. Instruction 2 waits for the header. P passes it and issues 3, so the two loads wait together. That overlap is the whole gain.

Look at cycle 7. Instruction 3 has had its result since cycle 6. It still retires after 2, because 2 is older.

Now the frame as a whole. These times and powers are exercise values for one complete frame, memory waits included.

The bill for one frame, by hand
CoreActive powerTimeEnergyOn time for 5 µs?
Performance9 mW4 µs9 × 4 = 36 nJyes
Efficiency4 mW7 µs4 × 7 = 28 nJno: 2 µs late

The efficiency core uses less energy, but it is late. So the performance core runs the frame.

The Rules

  1. Rule 1: A core issues at most its width in a cycle.

    P and W have two slots. E has one.

  2. Rule 2: An instruction may issue once the result it needs has arrived.

    In this lab a load gives its result 6 cycles after it issues, and a sum or a test 1 cycle after.

  3. Rule 3: An in-order core stops at the first instruction that is not ready.

    Younger ones wait behind it, even when they are ready and a slot is free.

  4. Rule 4: An out-of-order core passes a waiting instruction.

    It issues younger ready ones in the free slots. Two slow loads can then wait at the same time.

  5. Rule 5: Every core retires in program order.

    A result becomes final only after every older one. The reorder buffer of S2.32 keeps that order.

  6. Rule 6: The deadline chooses first, and energy second.

    A core that would be late is out. Among the rest, take the least energy for the whole job.

  7. Rule 7: A lockstep pair is one worker.

    It runs one job twice and compares. A difference means a fault.

Sources for These Rules

Rules 1 to 5: Patterson and Hennessy, Computer Organization and Design, ARM edition, section 4.10. It covers multiple issue, dynamic scheduling and in-order commit. Also Harris and Harris, Digital Design and Computer Architecture, ARM edition, sections 7.7.4 and 7.7.5.

A mixed cluster: Harris and Harris, Digital Design and Computer Architecture, ARM edition, section 7.7.8. It describes chips that pair energy-efficient in-order cores with complex out-of-order ones.

Rule 6 is arithmetic on exercise values. Energy as power times time is the rule of S5.13.

Rule 7: Weste and Harris, CMOS VLSI Design, fourth edition, section 7.6.2. It describes copies of hardware that run in lockstep and are compared.

The waits of 6 and 1 cycles, the powers, the times and the deadline are lab choices.

Now Run It

The lab at the end of this page is test code. It holds the five instructions and the rules for one core. It runs them on P, W and E.

Printed by the lab on Icarus: the performance core.
P | 1 load header   | issue  0 | result  6 | retire  6
P | 2 test header   | issue  6 | result  7 | retire  7
P | 3 load pointer  | issue  0 | result  6 | retire  7
P | 4 add address   | issue  6 | result  7 | retire  8
P | 5 store address | issue  7 | result  8 | retire  8
P | width 2, out of order | done in 9 cycles

These are the rows of the hand table, rule 4 at work. Rows 1 and 3 both issue at 0. Row 3 retires at 7, after row 2, as rule 5 says.

The same five instructions on W and on E.
W | 1 load header   | issue  0 | result  6 | retire  6
W | 2 test header   | issue  6 | result  7 | retire  7
W | 3 load pointer  | issue  6 | result 12 | retire 12
W | 4 add address   | issue 12 | result 13 | retire 13
W | 5 store address | issue 13 | result 14 | retire 14
W | width 2, in order | done in 15 cycles
E | 1 load header   | issue  0 | result  6 | retire  6
E | 2 test header   | issue  6 | result  7 | retire  7
E | 3 load pointer  | issue  7 | result 13 | retire 13
E | 4 add address   | issue 13 | result 14 | retire 14
E | 5 store address | issue 14 | result 15 | retire 15
E | width 1, in order | done in 16 cycles

Rule 3, in row 3 of W: issue 6. Instruction 3 needed nothing, yet it waited behind instruction 2. For five cycles W had two free slots and issued nothing.

So width alone saved one cycle: W is done in 15, E in 16. Passing the wait saved six more: P is done in 9.

The lockstep pair: one sum, computed twice.
lockstep | copy A 1040 | copy B 1040 | same: go on
lockstep | copy A 1040 | copy B 1050 | differ: report a fault

Rule 7. Both copies compute 1040 in hex. Then one bit of copy B is flipped, as a fault would do. It says 1050, and the pair reports the fault.

The bill for one frame, and the choice for two deadlines.
performance active_mW=9 time_us=4 energy_nJ=36
efficiency active_mW=4 time_us=7 energy_nJ=28
deadline_us=5 performance=on_time efficiency=late choice=performance
deadline_us=7 performance=on_time efficiency=on_time choice=efficiency

Rule 6. The performance core draws 9 mW for 4 µs: 36 nJ. The efficiency core draws 4 mW for 7 µs: 28 nJ.

With a deadline of 5 µs the efficiency core is late, so the choice is performance. With 7 µs both are on time, and the efficiency core wins by 8 nJ.

The frame times are exercise values, not sums of the five instructions. Those are one small piece of such a frame.

Why It Is Built This Way

ChoiceThe alternativeIts cost
Out-of-order issue in the performance coreIn-order issue onlyEach wait for memory stops all younger work. In the lab, W needs 15 cycles where P needs 9.
A narrow in-order efficiency coreWide out-of-order cores onlyPassing needs a rename table and a reorder buffer (S2.31, S2.32). They cost area and power on every job, even an easy one.
Two kinds of core in one clusterOne kind onlySoftware must now choose a core for each job, and test that choice.
Retire in program orderMake each result final as soon as it is readyA trap or a wrong guess could not be undone cleanly. S2.32 shows the recovery.
A lockstep pair for safety workTwo cores that share the workHalf the throughput. The pair buys a check, not speed.

The second row is why a phone does not run every job on its biggest core. Many jobs have slack, and slack is cheaper on a small core.

This page holds power and time fixed for each core. Power at Scale, later in this module, shows how both change with voltage and clock.

The Trap: Choosing by Watts

A colleague suggests the efficiency core because its active power is lower. At a deadline of 5 µs it finishes at 7, two microseconds late. A frame that misses its slot is lost, whatever it saved.

The second trap is starting the meter after the move. A job that moves finds cold private caches, as S10.2 showed. Charge for the wake and the refills too. The practice problem does exactly that.

The third trap is counting a lockstep pair as two workers. It looks like two cores on the diagram. It finishes one frame, not two.

At Scale

ap_soc~12 blocks
Phone-class SoChundreds of blocks

A large imaging chip meets its frame deadline until a second stream starts. Which measurements do you ask for?

  1. Keep the same frame

    Pin the job to one core and replay the same work. First establish whether the time on that core changed.

  2. Price the move

    Repeat the frame after a move to the other kind of core. Measure the whole frame interval, including the handoff.

  3. Compare equal work

    Then decide whether the quieter core really saves energy for one completed frame, idle time included.

  4. Real cores

    Real out-of-order cores keep far more than five instructions in flight. Widths, waits and powers differ from design to design. None is checked here.

Try It

Run the lab. It prints the three cores, then the lockstep pair, then the bill of one frame.

Make instruction 3 need instruction 2: change its need from 0 to 2. Predict how many cycles P now needs, and say why passing no longer helps.

Keep the active powers fixed and change the efficiency time, e_us. At what whole number of microseconds does its energy first equal the performance row?

Names Printed by the Lab
NameMeaning
P, W, EThe model core: performance, wide in order, efficiency.
issue, result, retireThe cycle in which the instruction starts, its result arrives, and it becomes final.
done inThe cycles from cycle 0 to the last retire, both counted.
copy A, copy BThe address that each core of the lockstep pair computed, in hex.
active_mW, time_us, energy_nJPower while the core runs the frame, the time it runs, and their product.
deadline_us, choiceThe deadline of the frame, and the core that the rule picks.
RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: P | 1 load header | issue 0 | result 6 | retire 6 P | 2 test header | issue 6 | result 7 | retire 7 P | 3 load pointer | issue 0 | result 6 | retire 7 P | 4 add address | issue 6 | result 7 | retire 8 P | 5 store address | issue 7 | result 8 | retire 8 P | width 2, out of order | done in 9 cycles W | 1 load header | issue 0 | result 6 | retire 6 W | 2 test header | issue 6 | result 7 | retire 7 W | 3 load pointer | issue 6 | result 12 | retire 12 W | 4 add address | issue 12 | result 13 | retire 13 W | 5 store address | issue 13 | result 14 | retire 14 W | width 2, in order | done in 15 cycles E | 1 load header | issue 0 | result 6 | retire 6 E | 2 test header | issue 6 | result 7 | retire 7 E | 3 load pointer | issue 7 | result 13 | retire 13 E | 4 add address | issue 13 | result 14 | retire 14 E | 5 store address | issue 14 | result 15 | retire 15 E | width 1, in order | done in 16 cycles lockstep | copy A 1040 | copy B 1040 | same: go on lockstep | copy A 1040 | copy B 1050 | differ: report a fault performance active_mW=9 time_us=4 energy_nJ=36 efficiency active_mW=4 time_us=7 energy_nJ=28 deadline_us=5 performance=on_time efficiency=late choice=performance deadline_us=7 performance=on_time efficiency=on_time choice=efficiency

Check Yourself

Predict the outputIn this run the efficiency core needs 8 microseconds. What is the last line? Its form is: efficiency active_mW=.. time_us=.. energy_nJ=..
module tb;
  // Five instructions of a frame job, in program order, numbered from 1.
  // need[i]: the instruction whose result i uses, or 0 for none.
  // lag[i]: cycles from the issue of i until its result can be used.
  int need [1:5];
  int lag [1:5];
  string what [1:5];

  // The model of one core. Each cycle it first issues, then retires.
  // Issue: look at the instructions not yet issued, oldest first. Start each one whose input is ready,
  //   up to "width" in the cycle. An in-order core stops at the first one that is not ready.
  //   An out-of-order core passes it and goes on to younger ones.
  // Retire: from the oldest instruction not yet retired, retire up to "width" whose results are ready.
  //   Stop at the first one whose result is not ready.
  task automatic run_core(input string name, input int width, input bit out_of_order);
    int issue [1:5];
    int result [1:5];
    int retire [1:5];
    int retired, started, cycle, i, n;
    bit stop;
    string order;
    for (i = 1; i <= 5; i++) begin issue[i] = -1; result[i] = -1; retire[i] = -1; end
    retired = 0;
    for (cycle = 0; retired < 5; cycle++) begin
      started = 0; stop = 0;
      for (i = 1; i <= 5 && started < width && !stop; i++) begin
        if (issue[i] < 0) begin
          n = need[i];
          if (n == 0 || (issue[n] >= 0 && result[n] <= cycle)) begin
            issue[i] = cycle;
            result[i] = cycle + lag[i];
            started++;
          end else if (!out_of_order) stop = 1;   // in order: nothing younger may start
        end
      end
      started = 0; stop = 0;
      for (i = retired + 1; i <= 5 && started < width && !stop; i++) begin
        if (issue[i] >= 0 && result[i] <= cycle) begin
          retire[i] = cycle;
          retired++;
          started++;
        end else stop = 1;                     // retire in order: stop at the first not ready
      end
    end
    for (i = 1; i <= 5; i++)
      $display("%s | %0d %s | issue %2d | result %2d | retire %2d", name, i, what[i], issue[i], result[i], retire[i]);
    if (out_of_order) order = "out of order"; else order = "in order";
    $display("%s | width %0d, %s | done in %0d cycles", name, width, order, retire[5] + 1);
  endtask

  // Two copies compute the same address. One bit of copy B can be flipped, as a fault would.
  task automatic lockstep(input logic [15:0] base, input logic [15:0] flip);
    logic [15:0] a, b;
    string verdict;
    a = base + 16'h0040;
    b = (base + 16'h0040) ^ flip;
    if (a == b) verdict = "same: go on"; else verdict = "differ: report a fault";
    $display("lockstep | copy A %h | copy B %h | %s", a, b, verdict);
  endtask

  // Exercise values for one whole frame on each kind of core, memory waits included.
  int p_mw = 9, p_us = 4, e_mw = 4, e_us = 8;

  task automatic task_cost(input string core_type, input int active_mw, input int runtime_us);
    $display("%s active_mW=%0d time_us=%0d energy_nJ=%0d", core_type, active_mw, runtime_us, active_mw * runtime_us);
  endtask

  // The deadline first: a core that finishes late is out. Then the least energy among the rest.
  task automatic choose(input int deadline_us);
    bit p_ok, e_ok;
    string pick, p_says, e_says;
    p_ok = p_us <= deadline_us;
    e_ok = e_us <= deadline_us;
    if (p_ok && e_ok) pick = (e_mw * e_us < p_mw * p_us) ? "efficiency" : "performance";
    else if (p_ok) pick = "performance";
    else if (e_ok) pick = "efficiency";
    else pick = "none";
    if (p_ok) p_says = "on_time"; else p_says = "late";
    if (e_ok) e_says = "on_time"; else e_says = "late";
    $display("deadline_us=%0d performance=%s efficiency=%s choice=%s", deadline_us, p_says, e_says, pick);
  endtask

  initial begin
    need[1] = 0; lag[1] = 6; what[1] = "load header  ";
    need[2] = 1; lag[2] = 1; what[2] = "test header  ";
    need[3] = 0; lag[3] = 6; what[3] = "load pointer ";
    need[4] = 3; lag[4] = 1; what[4] = "add address  ";
    need[5] = 4; lag[5] = 1; what[5] = "store address";
    task_cost("performance", p_mw, p_us);
    task_cost("efficiency", e_mw, e_us);
  end
endmodule
ConceptThe oldest instruction waits and two younger ones are ready. How many issue on a two-wide in-order core?
ConceptPerformance: 9 mW for 4 µs. Efficiency: 4 mW for 7 µs. The deadline is 5 µs. Which core runs the job?
ConceptOn P, the load of the pointer has its result at cycle 6. The older test has its result at cycle 7. When does the load retire?
ConceptWhat does a lockstep pair of cores add?

Common Mistakes

Wrong Choose a core by watts alone.

A job also keeps the core busy for a time.

Fix Check the deadline, then compare energy over equal work.

Wrong Expect a wider core to fill its slots while the oldest instruction waits.

An in-order core stops there. In the lab, W saved only one cycle over E.

Fix Ask whether the core issues out of order.

Wrong Let a younger instruction change what software sees.

Results still retire in program order.

Fix Issue out of order, retire in order.

Wrong Count a lockstep pair as two workers.

Both cores do the same work, and the results are compared.

Fix Count it as one worker that checks itself.

Remember

  • Issue width says how many instructions can start in a cycle. Out-of-order issue decides whether a waiting one blocks the rest.
  • An out-of-order core still retires in program order.
  • Filter cores by the deadline, then compare the energy of the whole job.
  • A lockstep pair is one worker that checks itself.
  • The pair of core types here is a teaching model. ap_phone has 8 equal cores.

Practice

Report a problem with this page