Skip to content

Commit 78fc55c

Browse files
authored
Toolchain: Allow controling parallel jobs for ABACUS build after toolchain setup (#7376)
1 parent b0bca19 commit 78fc55c

6 files changed

Lines changed: 137 additions & 12 deletions

File tree

toolchain/build_abacus_aocc-aocl.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ USE_CUDA=OFF # set ON to enable gpu-abacus
3737
# LIBNPY=$INSTALL_DIR/libnpy-1.0.1/include
3838
# DEEPMD=$HOME/apps/anaconda3/envs/deepmd
3939

40+
NUM_JOBS="$(nproc)"
41+
while [[ $# -gt 0 ]]; do
42+
case $1 in
43+
-j)
44+
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
45+
NUM_JOBS="${2}"
46+
shift 2
47+
else
48+
echo "ERROR: -j requires a number argument"
49+
exit 1
50+
fi
51+
;;
52+
-j[0-9]*)
53+
NUM_JOBS="${1#-j}"
54+
shift
55+
;;
56+
*)
57+
echo "ERROR: Unsupported argument: $1" >&2
58+
echo "Usage: $0 [-j N|-jN]" >&2
59+
exit 1
60+
;;
61+
esac
62+
done
63+
4064
# if clang++ have problem, switch back to g++
4165

4266
cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
@@ -66,8 +90,7 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
6690
# -DDeePMD_DIR=$DEEPMD \
6791
# -DENABLE_CUSOLVERMP=ON \
6892

69-
cmake --build $BUILD_DIR -j `nproc`
70-
cmake --install $BUILD_DIR 2>/dev/null
93+
cmake --build $BUILD_DIR --target install -j "${NUM_JOBS}"
7194

7295
# generate abacus_env.sh
7396
cat << EOF > "${TOOL}/abacus_env.sh"

toolchain/build_abacus_gcc-aocl.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ USE_CUDA=OFF # set ON to enable gpu-abacus
3737
# LIBNPY=$INSTALL_DIR/libnpy-1.0.1/include
3838
# DEEPMD=$HOME/apps/anaconda3/envs/deepmd
3939

40+
NUM_JOBS="$(nproc)"
41+
while [[ $# -gt 0 ]]; do
42+
case $1 in
43+
-j)
44+
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
45+
NUM_JOBS="${2}"
46+
shift 2
47+
else
48+
echo "ERROR: -j requires a number argument"
49+
exit 1
50+
fi
51+
;;
52+
-j[0-9]*)
53+
NUM_JOBS="${1#-j}"
54+
shift
55+
;;
56+
*)
57+
echo "ERROR: Unsupported argument: $1" >&2
58+
echo "Usage: $0 [-j N|-jN]" >&2
59+
exit 1
60+
;;
61+
esac
62+
done
63+
4064
cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
4165
-DCMAKE_CXX_COMPILER=g++ \
4266
-DMPI_CXX_COMPILER=mpicxx \
@@ -64,8 +88,7 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
6488
# -DDeePMD_DIR=$DEEPMD \
6589
# -DENABLE_CUSOLVERMP=ON \
6690

67-
cmake --build $BUILD_DIR -j `nproc`
68-
cmake --install $BUILD_DIR 2>/dev/null
91+
cmake --build $BUILD_DIR --target install -j "${NUM_JOBS}"
6992

7093
# generate abacus_env.sh
7194
cat << EOF > "${TOOL}/abacus_env.sh"

toolchain/build_abacus_gcc-mkl.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# load system env modules at first
1111
# module load mkl compiler mpi
12-
# source path/to/setvars.sh
12+
# source path/to/mkl/latest/env/vars.sh
1313

1414
ABACUS_DIR=..
1515
TOOL=$(pwd)
@@ -34,6 +34,30 @@ USE_CUDA=OFF # set ON to enable gpu-abacus
3434
# LIBNPY=$INSTALL_DIR/libnpy-1.0.1/include
3535
# DEEPMD=$HOME/apps/anaconda3/envs/deepmd
3636

37+
NUM_JOBS="$(nproc)"
38+
while [[ $# -gt 0 ]]; do
39+
case $1 in
40+
-j)
41+
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
42+
NUM_JOBS="${2}"
43+
shift 2
44+
else
45+
echo "ERROR: -j requires a number argument"
46+
exit 1
47+
fi
48+
;;
49+
-j[0-9]*)
50+
NUM_JOBS="${1#-j}"
51+
shift
52+
;;
53+
*)
54+
echo "ERROR: Unsupported argument: $1" >&2
55+
echo "Usage: $0 [-j N|-jN]" >&2
56+
exit 1
57+
;;
58+
esac
59+
done
60+
3761
cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
3862
-DCMAKE_CXX_COMPILER=g++ \
3963
-DMPI_CXX_COMPILER=mpicxx \
@@ -60,8 +84,7 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
6084
# -DDeePMD_DIR=$DEEPMD \
6185
# -DENABLE_CUSOLVERMP=ON \
6286

63-
cmake --build $BUILD_DIR -j `nproc`
64-
cmake --install $BUILD_DIR 2>/dev/null
87+
cmake --build $BUILD_DIR --target install -j "${NUM_JOBS}"
6588

6689
# generate abacus_env.sh
6790
cat << EOF > "${TOOL}/abacus_env.sh"

toolchain/build_abacus_gnu.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ USE_CUDA=OFF # set ON to enable gpu-abacus
3535
# LIBNPY=$INSTALL_DIR/libnpy-1.0.1/include
3636
# DEEPMD=$HOME/apps/anaconda3/envs/deepmd #
3737

38+
NUM_JOBS="$(nproc)"
39+
while [[ $# -gt 0 ]]; do
40+
case $1 in
41+
-j)
42+
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
43+
NUM_JOBS="${2}"
44+
shift 2
45+
else
46+
echo "ERROR: -j requires a number argument"
47+
exit 1
48+
fi
49+
;;
50+
-j[0-9]*)
51+
NUM_JOBS="${1#-j}"
52+
shift
53+
;;
54+
*)
55+
echo "ERROR: Unsupported argument: $1" >&2
56+
echo "Usage: $0 [-j N|-jN]" >&2
57+
exit 1
58+
;;
59+
esac
60+
done
61+
3862
cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
3963
-DCMAKE_CXX_COMPILER=g++ \
4064
-DMPI_CXX_COMPILER=mpicxx \
@@ -62,8 +86,7 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
6286
# -DDeePMD_DIR=$DEEPMD \
6387
# -DENABLE_CUSOLVERMP=ON \
6488

65-
cmake --build $BUILD_DIR -j `nproc`
66-
cmake --install $BUILD_DIR 2>/dev/null
89+
cmake --build $BUILD_DIR --target install -j "${NUM_JOBS}"
6790

6891
# generate abacus_env.sh
6992
cat << EOF > "${TOOL}/abacus_env.sh"

toolchain/build_abacus_intel.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ USE_CUDA=OFF # set ON to enable gpu-abacus
3434
# LIBNPY=$INSTALL_DIR/libnpy-1.0.1/include
3535
# DEEPMD=$HOME/apps/anaconda3/envs/deepmd # v3.0 might have problem
3636

37+
NUM_JOBS="$(nproc)"
38+
while [[ $# -gt 0 ]]; do
39+
case $1 in
40+
-j)
41+
if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then
42+
NUM_JOBS="${2}"
43+
shift 2
44+
else
45+
echo "ERROR: -j requires a number argument"
46+
exit 1
47+
fi
48+
;;
49+
-j[0-9]*)
50+
NUM_JOBS="${1#-j}"
51+
shift
52+
;;
53+
*)
54+
echo "ERROR: Unsupported argument: $1" >&2
55+
echo "Usage: $0 [-j N|-jN]" >&2
56+
exit 1
57+
;;
58+
esac
59+
done
60+
3761
# Notice: if you are compiling with AMD-CPU or GPU-version ABACUS, then `icpc` and `mpiicpc` compilers are needed
3862
cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
3963
-DCMAKE_CXX_COMPILER=icpx \
@@ -61,8 +85,7 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \
6185
# -DDeePMD_DIR=$DEEPMD \
6286
# -DENABLE_CUSOLVERMP=ON \
6387

64-
cmake --build $BUILD_DIR -j `nproc`
65-
cmake --install $BUILD_DIR 2>/dev/null
88+
cmake --build $BUILD_DIR --target install -j "${NUM_JOBS}"
6689

6790
# generate abacus_env.sh
6891
cat << EOF > "${TOOL}/abacus_env.sh"

toolchain/scripts/lib/config_manager.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,16 @@ config_parse_arguments() {
711711
return 1
712712
fi
713713
;;
714+
-j[0-9]*)
715+
local nprocs_overwrite="${1#-j}"
716+
if [[ -n "$nprocs_overwrite" && "$nprocs_overwrite" =~ ^[0-9]+$ ]]; then
717+
CONFIG_CACHE["NPROCS_OVERWRITE"]="$nprocs_overwrite"
718+
shift
719+
else
720+
report_error $LINENO "-j requires a number argument"
721+
return 1
722+
fi
723+
;;
714724
--dry-run)
715725
CONFIG_CACHE["dry_run"]="__TRUE__"
716726
shift
@@ -1246,4 +1256,4 @@ config_apply_modes() {
12461256
;;
12471257
esac
12481258
fi
1249-
}
1259+
}

0 commit comments

Comments
 (0)