25: Bundles, pt. 2


Now let's think how to use the intra-bundle interactions to determine whether two instructions are in the same bundle.

The most universal approach is to use $c read behavior - initialize a $c bit to 0, choose the first instruction so that it'll set the bit to 1 (or the other way around), choose the second instruction so that its behavior depends on the $c bit. Here goes:

  • first instruction is address - execute add $a0 $c0 $a0 $a0 with $a0 set to 0 to set $c0 bit 9
  • first instruction is scalar - execute add $r31 $c0 $r31 $r31 to set $c0 bit 1
  • first instruction is branch - execute mov $l0 $c0 0 to set $c0 bit 13
  • second instruction is address -  execute add $a2 $a2 (slct $c0 <flag> $a2d) with $a2=0, $a3=1, look at $a2
  • second instruction is scalar -  execute add $r2 $r2 (slct $c0 <flag> $r2d) with $r2=0, $r3=1, look at $r2
  • second instruction is vector - execute vcmpad 3 $vc0 $v0d (slct $c0 <flag> $v2d) with $v0=0, V1=1, $v2=0, $v3=1, look at $vc0
  • second instruction is branch - conditionally branch to mov $r2 1 instruction, initialize $r2=0, look at $r2

This covers all cases except the first instruction being vector (vector instructions don't set $c). Two cases can be tested using $v multiple write behavior:

  • second instruction is address - execute mov $v0 0 with ld $v0 [whatever], making sure the appropriate data store location is initialized to 1, look at $v0 afterwards
  • second instruction is scalar - execute mov $v0 0 with mov $v0 $r0, with $r0 set to 1, look at $v0 afterwards

The one remaining case is first instruction being vector and the second being branch - there seems to be genuinely no way to check for interaction in this case. We'll have to rely on transitivity here - but we won't be able to distinguish between a VB bundle and V + B bundles.

So let's write a program using all that to determine bundling behavior. We'll limit ourselves to 8-instruction samples (that should be enough let us notice if position in the stream makes a difference, but ), and go through all 4**8 (65536) combinations of A/S/V/B instructions (we could try to prune uninteresting variations, but it's more work than it's worth). For each of these combinations, we'll launch 7 tests to check whether instructions i and i+1 are in the same bundle or not (skipping over VB clusters appropriately). This results in 65536 * 7 tests - that's a lot, but managable.

There were no surprises when writing the test, and the results are quite simple:

  • bundles never cross aligned 4-word bounduaries (ie. 4 word bounduary always closes a bundle)
  • the instructions in a bundle always have to be in A, S, V, B order - the first instruction that'd violate this order will start a next bundle instead
  • however, each type of instruction can be skipped - (A, S, B) is a valid bundle, and so is (S, V).
  • each bundle continues for a long as possible according to the above rules - an instruction starts a new bundle iff it's on 4 word bounduary, or is not of a higher kind than the previous one (where A < S < V < B)

This aligns nicely with branch targets being aligned to 4 words - this makes sure that you can't branch into what would otherwise be the middle of a bundle.

That's all there is to bundling. Next step - branches and their delay slots.

Elapsed time: 3h.

Currently unrated


There are currently no comments

New Comment


required (not published)