Skip to content

build: parallelize gpuagent build with correct -j dependency graph - #92

Merged
spraveenio merged 1 commit into
ROCm:mainfrom
spraveenio:build/parallelize-gpuagent
Aug 27, 2026
Merged

build: parallelize gpuagent build with correct -j dependency graph#92
spraveenio merged 1 commit into
ROCm:mainfrom
spraveenio:build/parallelize-gpuagent

Conversation

@spraveenio

@spraveenio spraveenio commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes the build so it can use make -j: object compilation had no dependency edge to the third-party libs or generated protos, so -j raced ahead (compiling before headers/protos existed) and the inner build was invoked without -j at all, forcing serial object compilation across ~hundreds of .cc × 3 variants.
  • inner Makefile: generated *.pb.cc are now declared as grouped-target (&:, GNU Make ≥4.3) outputs so the %.o:%.cc pattern rule resolves every generated .o under -j; order-only edges make objects wait for generated *.pb.h + the lib stamp without forcing recompiles on proto refresh.
  • top Makefile: pass make -j$(GPUAGENT_JOBS) (default nproc, override GPUAGENT_JOBS=N) to the inner build.
  • Makefile.lib: .NOTPARALLEL: keeps the six third-party libs serial across each other (each already runs make -j$(nproc) internally; concurrent libs would oversubscribe and OOM grpc/boost).
  • ci.yml: adds a step summary (per-binary size/sha256) and uploads the 4 binaries + build.log as artifacts (retention 10d, if: always()).

Why

Under -j the object files were only siblings of build-libs/gen-protos in the prerequisite lists — serial builds ordered them by luck, -j did not. On a cold tree this failed at link (missing gogo.grpc.pb.o) because the generated .cc were never declared as buildable targets.

Results

  • Clean -j8 build verified successful end-to-end: all 3 gpuagent variants (gpuagent, gpuagent_gim, gpuagent_mock) + gpuctl.
  • Object+link phase: ~449s serial → ~108s parallel (measured, 8 cores / 23 GB).
  • Third-party libs (~10.4 min) are stamp-cached and unchanged; they already parallelized internally.

Test plan

  • CI make gpuagent (RHEL9 builder) is green and produces all 4 binaries.
  • Confirm the run's step summary table + 5 artifacts (4 binaries + build-log) upload.
  • Optional: local make docker-shell → clean make -j8 -C sw/nic/gpuagent all links successfully.

🤖 Generated with Claude Code

The build could not use make -j: object compilation had no dependency
edge to the third-party libs or generated protos, so -j raced ahead and
compiled gpuagent before headers/protos existed. The inner build was also
invoked without -j at all, forcing serial object compilation (~hundreds of
.cc x 3 variants), which dominated build time.

- inner Makefile: declare generated *.pb.cc as grouped-target (&:) outputs
  so the %.o:%.cc pattern rule can resolve every generated .o under -j;
  add order-only edges so objects wait for generated *.pb.h and the lib
  stamp without forcing recompiles on proto refresh.
- top Makefile: pass make -j$(GPUAGENT_JOBS) (default nproc) to the inner
  build; override with GPUAGENT_JOBS=N.
- Makefile.lib: .NOTPARALLEL: keeps the six third-party libs serial across
  each other (each already runs make -j$(nproc) internally; concurrent libs
  would oversubscribe and OOM grpc/boost).
- ci.yml: add step summary (per-binary size/sha256), upload the 4 binaries
  and build.log as artifacts (retention 10d, if: always()).

Clean -j8 build verified successful end-to-end (all 3 gpuagent variants +
gpuctl); object+link phase ~449s serial -> ~108s parallel.

Co-Authored-By: Claude <noreply@anthropic.com>

@sarat-k sarat-k left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@spraveenio
spraveenio merged commit 1d816bf into ROCm:main Aug 27, 2026
1 check passed
@spraveenio
spraveenio deleted the build/parallelize-gpuagent branch August 27, 2026 22:41
spraveenio added a commit to ROCm/device-metrics-exporter that referenced this pull request Aug 28, 2026
…rallelize staging build (#630)

* [NO-JIRA] bump gpuagent to ROCm/gpu-agent @1d816bfe2b42, parallelize staging build (#1581)

* [NO-JIRA] bump gpuagent to ROCm/gpu-agent main @1d816bfe2b42, parallelize staging build

Bumps GPUAGENT_COMMIT to ROCm/gpu-agent#92 (build: parallelize gpuagent
build with correct -j dependency graph), which fixes the inner Makefile
so object compilation correctly depends on generated protos/third-party
libs and can safely build with -j.

Wires -j$(nproc) into the gpuagent-build Dockerfile stage's
`make -C sw/nic/gpuagent all` so this repo's staging build actually
exercises the new parallel graph instead of building serially.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs: record gpuagent staging build validation + timing

make gpuagent-build succeeded at the new pin; all four binaries produced.
Compile+link step took 1117.3s (~18m37s) under -j8 on an 8-core host.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 7700bdff53f280ba2bf7ae76ec019b0ee544652d)

* Delete docs-internal/knowledge/plans/2026-08-27-gpuagent-bump-1d816bfe2b42-parallel-build.md

---------

Co-authored-by: Praveen Kumar Shanmugam <58961022+spraveenio@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants