Skip to content

Commit

Permalink
Use nproc --all to determine number of processors (#272)
Browse files Browse the repository at this point in the history
* Use nproc --all to determine number of processors

For some reason, nproc looks at the value (if any) of OMP_NUM_THREADS
and OMP_THREAD_LIMIT in the environment to constrain the result. If we
don't pass --all and we have one of those environment variables set,
then build parallelism is incorrectly limited to nproc=1.

* bump feature versions

---------

Co-authored-by: ptaylor <paul.e.taylor@me.com>
  • Loading branch information
wence- and trxcllnt authored Apr 19, 2024
1 parent d776a3b commit 7e84a15
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 38 deletions.
2 changes: 1 addition & 1 deletion features/src/rapids-build-utils/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "NVIDIA RAPIDS devcontainer build utilities",
"id": "rapids-build-utils",
"version": "24.6.8",
"version": "24.6.9",
"description": "A feature to install the RAPIDS devcontainer build utilities",
"containerEnv": {
"BASH_ENV": "/etc/bash.bash_env"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ checkout_same_branch() {
eval "$(_parse_args "$@" <&0)";

eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc)} \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc --all)} \
rapids-get-num-archs-jobs-and-load --archs 0 "$@" \
)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ get_num_archs_jobs_and_load() {
# shellcheck disable=SC1091
. devcontainer-utils-debug-output 'rapids_build_utils_debug' 'get-num-archs-jobs-and-load';

local -r n_cpus="$(nproc)";
# The return value of nproc is (who knew!) constrained by the
# values of OMP_NUM_THREADS and/or OMP_THREAD_LIMIT
# Since we want the physical number of processors here, pass --all
local -r n_cpus="$(nproc --all)";

if test ${#j[@]} -gt 0 && test -z "${j:-}"; then
j="${n_cpus}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ merge_compile_commands_json() {

readarray -t dirs < <( \
_list_repo_paths \
| xargs -r -I% -P$(nproc) \
| xargs -r -I% -P$(nproc --all) \
rapids-get-cmake-build-dir --skip-links --skip-build-type -- % \
| xargs -r -I% sh -c 'if test -e %; then echo %/; fi' \
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ build_${CPP_LIB}_cpp() {
local -;
set -euo pipefail;

eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc --all)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
)";

local -a cmake_args_="(${CMAKE_ARGS:-})";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ configure_${CPP_LIB}_cpp() {
local -;
set -euo pipefail;

eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc --all)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
)";

local -a cmake_args_="(${CMAKE_ARGS:-})";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# Options that require values:
# -j,--parallel <num> Use <num> threads to compress in parallel
# (default: $(nproc))
# (default: $(nproc --all))
# -o,--out-dir <dir> copy cpack'd TGZ file into <dir>
# (default: none)
# @_include_value_options rapids-select-cmake-install-args -h | tail -n-5 | head -n-2;
Expand All @@ -34,7 +34,7 @@ cpack_${CPP_LIB}_cpp() {
fi

eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc)} \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc --all)} \
rapids-get-num-archs-jobs-and-load --archs 0 "$@" \
)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ build_${PY_LIB}_python_wheel() {
local -;
set -euo pipefail;

eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc --all)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
)";

local py_lib="${PY_LIB}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ install_${PY_LIB}_python() {
local -;
set -euo pipefail;

eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
eval "$( \
PARALLEL_LEVEL=${PARALLEL_LEVEL:-$(nproc --all)} \
rapids-get-num-archs-jobs-and-load "$@" \
2>/dev/null \
)";

local py_lib="${PY_LIB}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ clone_${NAME}() {

echo 'Cloning ${NAME}' 1>&2;

devcontainer-utils-clone-${GIT_HOST}-repo \
--tags \
--branch "${branch}" \
--ssh-url "${ssh_url}" \
--https-url "${https_url}" \
--recurse-submodules \
-j ${n_jobs:-$(nproc --ignore=1)} \
-c checkout.defaultRemote=upstream \
"${OPTS[@]}" \
-- \
"${upstream}" \
"${directory}" \
devcontainer-utils-clone-${GIT_HOST}-repo \
--tags \
--branch "${branch}" \
--ssh-url "${ssh_url}" \
--https-url "${https_url}" \
--recurse-submodules \
-j ${n_jobs:-$(nproc --all --ignore=1)} \
-c checkout.defaultRemote=upstream \
"${OPTS[@]}" \
-- \
"${upstream}" \
"${directory}" \
;

git -C "${SRC_PATH}" config --add remote.upstream.fetch '^refs/heads/pull-request/*';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# Options that require values:
# -j,--parallel <num> Use <num> threads to compress in parallel.
# (default: $(nproc))
# (default: $(nproc --all))
# -o,--out-dir <dir> Copy cpack'd TGZ file into <dir>.
# (default: none)
# @_include_value_options rapids-select-cmake-install-args -h | tail -n-5 | head -n-2;
Expand Down
5 changes: 3 additions & 2 deletions features/src/ucx/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "UCX",
"id": "ucx",
"version": "24.6.0",
"version": "24.6.1",
"description": "A feature to install UCX",
"options": {
"version": {
"type": "string",
"proposals": [
"latest",
"1.15.0-rc3",
"1.16.0",
"1.15.0",
"1.14.1"
],
"default": "latest",
Expand Down
2 changes: 1 addition & 1 deletion features/src/ucx/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ build_and_install_ucx() {
--with-rdmacm \
${cuda:+--with-cuda=${CUDA_HOME:-/usr/local/cuda}};

make -j$(nproc);
make -j$(nproc --all);
make install;
)

Expand Down

0 comments on commit 7e84a15

Please sign in to comment.