74STAGES
The task
Square X, take 7 away, square that, take 20 away, multiply by 3, and take 1 away.
P must receive the result for each X.
a and d are SC-1s, with MUL at 4 cycles. b is an SC-2L, at 2 cycles an instruction.
The board
Key idea
Split the job, not the stream: each core takes a share of the steps, and the line moves at the pace of its slowest core.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Split the job, not the stream: each core does some of the steps to every value.
Hint 2Show
The line moves at the pace of its slowest core, so give each core a fair share of the steps.
Hint 3Show
On an SC-1 a MUL takes 4 cycles; on the SC-2L every step takes 2.
Solution
Reveal the Full SolutionThe complete program for STAGES. Open it only when you want the answer.
The reference program
The game's own solution. It passes every test and scores exactly par on every benchmark.
aSC-1 lite
IN P0
MUL A
OUT P1bSC-2L low power
IN P0
SUB 7
OUT P1cSC-2 standard
IN P0
MUL A
SUB 20
MUL 3
OUT P1dSC-1 lite
IN P0
SUB 1
OUT P1- CYCLES
- 287
- at par
- ENERGY
- 2223
- at par
- NODES
- 4
- at par
- INSTRUCTIONS
- 14
- at par
Another way: Fast c
A second program that also passes. It beats par on CYCLES and gives some back on ENERGY.
A only passes values on and c does four steps: a few cycles faster, for more of the work at 2 energy an instruction.
aSC-1 lite
IN P0
OUT P1bSC-2L low power
IN P0
MUL A
OUT P1cSC-2 standard
IN P0
SUB 7
MUL A
SUB 20
MUL 3
OUT P1dSC-1 lite
IN P0
SUB 1
OUT P1- CYCLES
- 284
- under par
- ENERGY
- 2340
- over par
- NODES
- 4
- at par
- INSTRUCTIONS
- 14
- at par
Another way: Low energy
A second program that also passes. It beats par on ENERGY and gives some back on CYCLES.
Every step on the 1 energy cores and c only passing values on: the least energy there is, but b's two steps hold the whole line back.
aSC-1 lite
IN P0
MUL A
SUB 7
OUT P1bSC-2L low power
IN P0
MUL A
SUB 20
OUT P1cSC-2 standard
IN P0
OUT P1dSC-1 lite
IN P0
MUL 3
SUB 1
OUT P1- CYCLES
- 367
- over par
- ENERGY
- 1872
- under par
- NODES
- 4
- at par
- INSTRUCTIONS
- 14
- at par