Commit fa16fa55

fa16fa55d4e2Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

build: split bootstrap into per-binary targets for parallel build

The previous bootstrap target ran analyze and codegen pipelines serially via a single multi-recipe rule. The two pipelines are independent though -- analyze.rb's compilation doesn't depend on codegen.rb's IR or vice versa -- so the analyze and codegen sides of round 2 (and round 3) can run concurrently under make -j.

Split each pipeline step into its own target with explicit dependencies:

build/analyze2.ir : analyze.ast spinel_analyze build/analyze2.c : analyze.ast analyze2.ir spinel_codegen build/bin2_analyze : analyze2.c sp_runtime_lib

build/codegen2.ir : codegen.ast spinel_analyze build/codegen2.c : codegen.ast codegen2.ir spinel_codegen build/bin2_codegen : codegen2.c sp_runtime_lib

build/analyze3.{ir,c} : ... bin2_analyze, bin2_codegen build/codegen3.{ir,c} : ... bin2_analyze, bin2_codegen

bootstrap : analyze3.c codegen3.c (runs the four diffs, copies bin2_* to spinel_*)

Wall-clock on a 24-core box:

make -j1 bootstrap ~118 s (serial; original behaviour) make bootstrap ~61 s (-j default; new parallel shape, ~48% faster)

The fixpoint coverage stays identical -- the four diff lines at the end of the bootstrap target produce the same analyze.rb: IR fixpoint OK / analyze.rb: C fixpoint OK / codegen.rb: IR fixpoint OK / codegen.rb: C fixpoint OK messages they always did.

Details

Commit
fa16fa55d4e2
Parent
2bbda3308498

MakefilemodifiedView file

@@ -238,19 +238,43 @@
238238 # analysis IR and the emitted C, so any drift in either phase is
239239 # caught.
240240
241-bootstrap: spinel_analyze$(EXE) spinel_codegen$(EXE)
242- @echo "=== Bootstrap round 2: analyze + codegen with spinel_{analyze,codegen} ==="
241+# Round 2: gen1 binaries (spinel_{analyze,codegen}) compile each .rb
242+# source into a fresh `bin2_*` binary. The analyze and codegen sources
243+# are independent, so the two pipelines are split into per-binary
244+# targets that `make -j` can run in parallel. Same for the round 3
245+# verify step.
246+
247+build/analyze2.ir: build/analyze.ast spinel_analyze$(EXE)
243248 ./spinel_analyze$(EXE) build/analyze.ast build/analyze2.ir
249+
250+build/analyze2.c: build/analyze.ast build/analyze2.ir spinel_codegen$(EXE)
244251 ./spinel_codegen$(EXE) build/analyze.ast build/analyze2.ir build/analyze2.c
252+
253+build/bin2_analyze$(EXE): build/analyze2.c $(SP_RT_LIB)
245254 $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/analyze2.c $(LDFLAGS) -lm -o build/bin2_analyze$(EXE)
255+
256+build/codegen2.ir: build/codegen.ast spinel_analyze$(EXE)
246257 ./spinel_analyze$(EXE) build/codegen.ast build/codegen2.ir
258+
259+build/codegen2.c: build/codegen.ast build/codegen2.ir spinel_codegen$(EXE)
247260 ./spinel_codegen$(EXE) build/codegen.ast build/codegen2.ir build/codegen2.c
261+
262+build/bin2_codegen$(EXE): build/codegen2.c $(SP_RT_LIB)
248263 $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/codegen2.c $(LDFLAGS) -lm -o build/bin2_codegen$(EXE)
249- @echo "=== Bootstrap round 3: analyze + codegen with bin2_* — verify ==="
264+
265+build/analyze3.ir: build/analyze.ast build/bin2_analyze$(EXE)
250266 ./build/bin2_analyze$(EXE) build/analyze.ast build/analyze3.ir
267+
268+build/analyze3.c: build/analyze.ast build/analyze3.ir build/bin2_codegen$(EXE)
251269 ./build/bin2_codegen$(EXE) build/analyze.ast build/analyze3.ir build/analyze3.c
270+
271+build/codegen3.ir: build/codegen.ast build/bin2_analyze$(EXE)
252272 ./build/bin2_analyze$(EXE) build/codegen.ast build/codegen3.ir
273+
274+build/codegen3.c: build/codegen.ast build/codegen3.ir build/bin2_codegen$(EXE)
253275 ./build/bin2_codegen$(EXE) build/codegen.ast build/codegen3.ir build/codegen3.c
276+
277+bootstrap: build/analyze3.c build/codegen3.c
254278 @diff build/analyze2.ir build/analyze3.ir > /dev/null && echo "analyze.rb: IR fixpoint OK" || (echo "BOOTSTRAP FAILED: analyze.rb IR diverged" && exit 1)
255279 @diff build/analyze2.c build/analyze3.c > /dev/null && echo "analyze.rb: C fixpoint OK" || (echo "BOOTSTRAP FAILED: analyze.rb C diverged" && exit 1)
256280 @diff build/codegen2.ir build/codegen3.ir > /dev/null && echo "codegen.rb: IR fixpoint OK" || (echo "BOOTSTRAP FAILED: codegen.rb IR diverged" && exit 1)