Global control over concurrency ?

129 views
Skip to first unread message

Nicholas Yue

unread,
Nov 9, 2022, 1:08:30 PM11/9/22
to ninja-build
Hi,

  I am attempting to build the Paraview software using cmake on a Jetson Nano (it runs Ubuntu and has 4 cores ARM process, a GPU but only has 4GB of RAM)

  I need to build the software on the hardware itself so that it links with the GPU drivers that matches the Jetson Nano.

  The dependent components of Paraview are automatically built via their default choice of using Ninja, I have no real control over that invocation.

  By default, ninja detects 4 cores and spawns 6 concurrent compilation processes but due to the limited RAM, it quickly overwhelm the Jetson Nano, goes into swap and kills the build process.

  Is there some settings that I get configure e.g. environment variable, that ninja will check, to ensure that regardless of when ninja is invoke, it only uses a maximum of 1 core to build/compile ?

  I know there are command line options on the ninja tool itself but I am trying to avoid modifying a working build system to insert such options and potentially break stuff and sidetrack to troubleshooting a tangential problem.

Cheers

K. Moon

unread,
Nov 9, 2022, 1:34:26 PM11/9/22
to Nicholas Yue, ninja-build
It's typical to set up a cross-compilation environment for developing to a resource-constrained device like this.

That said, the option you want is in ninja --help:
 -j N     run N jobs in parallel (0 means infinity) [default=14 on this system

--
You received this message because you are subscribed to the Google Groups "ninja-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ninja-build/cdcdf20e-7302-4182-b425-52cbaa4fa906n%40googlegroups.com.

Bill Hoffman

unread,
Nov 9, 2022, 1:44:45 PM11/9/22
to ninja...@googlegroups.com

The Kitware fork of ninja has support for jobserver which can be used for this with the paraview superbuild.

https://github.com/Kitware/ninja

I think you use make on the top level then ninja in the sub projects. You might find some help on the paraview discourse.

-Bill

jha...@gmail.com

unread,
Nov 9, 2022, 3:49:35 PM11/9/22
to ninja-build
Ninja itself has no way to configure this with an environment variable. If the components use cmake --build you can use the following environment variable: https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html

If the components call ninja directly, create a script named "ninja", make it executable and paste the following python code:

#!/usr/bin/env python3

import sys
import subprocess

try:
    subprocess.check_call(['/usr/bin/ninja', '-j1'] + sys.argv[1:])
except subprocess.CalledProcessError as e:
    exit(e.returncode)


Hope that works :)
Reply all
Reply to author
Forward
0 new messages