Skip to content

topology: cmake: build topologies in parallel, add -s to force sequen… - #11119

Open
ujfalusi wants to merge 1 commit into
thesofproject:mainfrom
ujfalusi:peter/pr/parallel-tplg-build
Open

topology: cmake: build topologies in parallel, add -s to force sequen…#11119
ujfalusi wants to merge 1 commit into
thesofproject:mainfrom
ujfalusi:peter/pr/parallel-tplg-build

Conversation

@ujfalusi

Copy link
Copy Markdown
Contributor

…tial

alsatplg custom commands were marked USES_TERMINAL. With the Ninja generator this places them in the single-job "console" pool, which serializes every topology build regardless of the -j value passed to ninja. Building all 579 topologies therefore never used more than one core, even on a many-core machine.

Drop USES_TERMINAL by default so Ninja can run alsatplg invocations in parallel, controlled by a new TPLG_SEQUENTIAL_BUILD CMake option (default OFF).

Add a -s flag to build-tools.sh that sets TPLG_SEQUENTIAL_BUILD=ON, to restore the old, easier to debug one-at-a-time behavior when needed. It updates the CMake cache in place, so it also works on an existing incremental build tree without deleting it.

Results
Sequential (before this patch or with -T -s with this patch): ./scripts/build-tools.sh -T -s 19.30s user 2.34s system 99% cpu 21.817 total

Parallel:
rm -rf tools/build_tools; time ./scripts/build-tools.sh -T ./scripts/build-tools.sh -T 33.79s user 3.52s system 986% cpu 3.783 total

The build time changes from ~22s to ~4s

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enables parallel topology builds by default while adding an opt-in sequential debugging mode.

Changes:

  • Makes topology command serialization conditional.
  • Adds TPLG_SEQUENTIAL_BUILD and the build-tools.sh -s option.
  • Supports updating existing build trees.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Summary Final comments
tools/topology/CMakeLists.txt Controls topology build parallelism. None
scripts/build-tools.sh Adds sequential-build configuration and CLI handling. Document -s in scripts/README.md (nit, 2 votes). Reset the cached option when -s is omitted (moderate, 4 votes).
Suppressed comments (1)

tools/topology/CMakeLists.txt:8

  • The new public build control is missing from the repository's existing topology documentation: scripts/README.md:45-55 lists the build-tools.sh options but omits -s, and tools/topology/README.md:14-22 does not explain the sequential/parallel CMake option. Please update those READMEs so users can discover and understand this behavior.
option(TPLG_SEQUENTIAL_BUILD "Build topologies one at a time (for debugging)" OFF)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/build-tools.sh
Comment on lines +28 to +29
-s Force sequential (one at a time) topology builds, for debugging.
Normally topologies build in parallel with -j "$NO_PROCESSORS".
Comment thread scripts/build-tools.sh Outdated
Comment on lines +169 to +172
# -s must apply even to an already configured, incremental build tree.
if [ "$TPLG_SEQUENTIAL_BUILD" = ON ]; then
update_sequential_build_option
fi
@ujfalusi
ujfalusi force-pushed the peter/pr/parallel-tplg-build branch from bd98ca2 to 04a133f Compare August 25, 2026 07:14
…tial

alsatplg custom commands were marked USES_TERMINAL. With the Ninja
generator this places them in the single-job "console" pool, which
serializes every topology build regardless of the -j value passed to
ninja. Building all 579 topologies therefore never used more than one
core, even on a many-core machine.

Drop USES_TERMINAL by default so Ninja can run alsatplg invocations in
parallel, controlled by a new TPLG_SEQUENTIAL_BUILD CMake option
(default OFF).

Add a -s flag to build-tools.sh that sets TPLG_SEQUENTIAL_BUILD=ON, to
restore the old, easier to debug one-at-a-time behavior when needed.
It updates the CMake cache in place, so it also works on an existing
incremental build tree without deleting it.

Results
Sequential (before this patch or with -T -s with this patch):
./scripts/build-tools.sh -T -s  19.30s user 2.34s system 99% cpu 21.817 total

Parallel:
rm -rf tools/build_tools; time ./scripts/build-tools.sh -T
./scripts/build-tools.sh -T  33.79s user 3.52s system 986% cpu 3.783 total

The build time changes from ~22s to ~4s

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi
ujfalusi force-pushed the peter/pr/parallel-tplg-build branch from 04a133f to fa711da Compare August 25, 2026 07:15
@ujfalusi

Copy link
Copy Markdown
Contributor Author

Changes since v1:

  • Update the README.md
  • always update the parallel/sequential build type

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