[Backport staging-next-26.05] openmpCheckPhaseHook: init (#539501)

This commit is contained in:
Doron Behar
2026-07-08 09:20:01 +00:00
committed by GitHub
30 changed files with 68 additions and 68 deletions

View File

@@ -34,6 +34,7 @@ nodejs-install-manuals.section.md
npm-build-hook.section.md
npm-config-hook.section.md
npm-install-hook.section.md
openmp-check-hook.section.md
patch-rc-path-hooks.section.md
perl.section.md
pkg-config.section.md

View File

@@ -0,0 +1,10 @@
# openmpCheckPhaseHook {#setup-hook-omp-check}
This hook can be used to setup a check phase that
requires running a OpenMP application. It mostly
serves to limit `OMP_NUM_THREADS` to avoid overloading
build machines.
This hook will not attempt to override an already existing
definition of `OMP_NUM_THREADS` in the environment.

View File

@@ -2809,6 +2809,9 @@
"setup-hook-mpi-check": [
"index.html#setup-hook-mpi-check"
],
"setup-hook-omp-check": [
"index.html#setup-hook-omp-check"
],
"ninja": [
"index.html#ninja"
],

View File

@@ -3,6 +3,7 @@
stdenv,
lapack-reference,
openblas,
openmpCheckPhaseHook,
isILP64 ? false,
blasProvider ? openblas,
}:
@@ -186,6 +187,10 @@ stdenv.mkDerivation {
"dev"
];
propagatedNativeBuildInputs = [
openmpCheckPhaseHook
];
meta = (blasProvider'.meta or { }) // {
description = "${lib.getName blasProvider} with just the BLAS C and FORTRAN ABI";
};

View File

@@ -82,10 +82,6 @@ stdenv.mkDerivation (finalAttrs: {
app/tester.py
'';
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Generally Applicable Atomic-Charge Dependent London Dispersion Correction";
mainProgram = "dftd4";

View File

@@ -116,9 +116,6 @@ stdenv.mkDerivation (finalAttrs: {
preCheck = ''
#patchShebangs ./
# Run dual threaded
export OMP_NUM_THREADS=2
# Reduce test problem sizes
export TEST_FLAGS="1500 50 16"
'';

View File

@@ -39,7 +39,6 @@ stdenv.mkDerivation (finalAttrs: {
"-lblas"
"-llapack"
];
OMP_NUM_THREADS = 2; # required for check phase
};
enableParallelBuilding = true;

View File

@@ -34,10 +34,6 @@ stdenv.mkDerivation (finalAttrs: {
# Uses a hacky python setup run by cmake, which is hard to get running
doCheck = false;
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Library for Greens function based electronic structure theory calculations";
license = [ lib.licenses.asl20 ];

View File

@@ -10,6 +10,7 @@
pkg-config,
python3,
jonquil,
openmpCheckPhaseHook,
}:
assert (
@@ -43,6 +44,7 @@ stdenv.mkDerivation (finalAttrs: {
gfortran
pkg-config
python3
openmpCheckPhaseHook
]
++ lib.optionals (buildType == "meson") [
meson
@@ -61,10 +63,6 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
'';
postPatch = ''
patchShebangs --build config/install-mod.py
'';

View File

@@ -39,10 +39,6 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Semiempirical quantum chemistry";
homepage = "https://github.com/openmopac/mopac";

View File

@@ -59,8 +59,6 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = true;
preCheck = "export OMP_NUM_THREADS=2";
meta = {
description = "MIT Photonic-Bands: computation of photonic band structures in periodic media";
homepage = "https://mpb.readthedocs.io/en/latest/";

View File

@@ -72,8 +72,5 @@ setupMpiCheck() {
export HWLOC_XMLFILE="@topology@"
;;
esac
# Limit number of OpenMP threads. Default is "all cores".
export OMP_NUM_THREADS=1
}

View File

@@ -1,7 +1,7 @@
{
callPackage,
makeSetupHook,
stdenv,
openmpCheckPhaseHook,
}:
makeSetupHook {
@@ -11,4 +11,8 @@ makeSetupHook {
iface = if stdenv.hostPlatform.isDarwin then "lo0" else "lo";
topology = ./topology.xml;
};
propagatedNativeBuildInputs = [
openmpCheckPhaseHook
];
} ./mpi-check-hook.sh

View File

@@ -71,10 +71,6 @@ stdenv.mkDerivation (finalAttrs: {
patchShebangs --build config/install-mod.py
'';
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Electronegativity equilibration model for atomic partial charges";
mainProgram = "multicharge";

View File

@@ -0,0 +1,11 @@
preCheckHooks+=('setupOmpCheck')
preInstallCheckHooks+=('setupOmpCheck')
setupOmpCheck() {
# Limit number of OpenMP threads. Default is "all cores".
# Using all cores causes high load on builders if checks are executed with NIX_BUILD_CORE parallelism.
# This gets even worse if multiple builds are scheduled on the same machine, potentially growing O(n^3) without explicit core limits.
export OMP_NUM_THREADS="${OMP_NUM_THREADS:-1}"
}

View File

@@ -0,0 +1,12 @@
{
lib,
makeSetupHook,
}:
makeSetupHook {
name = "omp-checkPhase-hook";
__structuredAttrs = true;
meta.license = lib.licenses.mit;
} ./omp-check-hook.sh

View File

@@ -6,6 +6,7 @@
ninja,
pkg-config,
libpng,
openmpCheckPhaseHook,
glib, # just passthru
# for passthru.tests
@@ -46,6 +47,7 @@ stdenv.mkDerivation (finalAttrs: {
meson
ninja
pkg-config
openmpCheckPhaseHook
__flattenIncludeHackHook
];
@@ -61,11 +63,6 @@ stdenv.mkDerivation (finalAttrs: {
"-Dneon=disabled"
];
preConfigure = ''
# https://gitlab.freedesktop.org/pixman/pixman/-/issues/62
export OMP_NUM_THREADS=$((NIX_BUILD_CORES > 184 ? 184 : NIX_BUILD_CORES))
'';
enableParallelBuilding = true;
doCheck = !stdenv.hostPlatform.isDarwin;

View File

@@ -73,9 +73,6 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = true;
checkInputs = [ python3 ];
checkTarget = [ "test-serial" ];
preCheck = ''
export OMP_NUM_THREADS=4
'';
enableParallelBuilding = true;

View File

@@ -19,7 +19,7 @@
ompdSupport ? true,
ompdGdbSupport ? ompdSupport,
getVersionFile,
fetchpatch,
openmpCheckPhaseHook,
}:
assert lib.assertMsg (ompdGdbSupport -> ompdSupport) "OMPD GDB support requires OMPD support!";
@@ -60,6 +60,10 @@ stdenv.mkDerivation (finalAttrs: {
lit
];
propagatedNativeBuildInputs = [
openmpCheckPhaseHook
];
buildInputs = [
llvm
]

View File

@@ -64,9 +64,6 @@ stdenv.mkDerivation rec {
];
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Reimplementation of the DFT-D3 program";

View File

@@ -88,10 +88,6 @@ stdenv.mkDerivation rec {
doCheck = buildType == "meson";
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Light-weight tight-binding framework";
mainProgram = "tblite";

View File

@@ -143,10 +143,6 @@ buildPythonPackage rec {
preCheck = ''
export HOME="$(mktemp -d)"
export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
if [ $OMP_NUM_THREADS -eq 0 ]; then
export OMP_NUM_THREADS=1
fi
# See https://github.com/astropy/astropy/issues/17649 and see
# --hypothesis-profile=ci pytest flag below.

View File

@@ -28,10 +28,6 @@ buildPythonPackage rec {
six
];
preCheck = ''
export OMP_NUM_THREADS=2
'';
nativeCheckInputs = [ pytestCheckHook ];
meta = {

View File

@@ -49,7 +49,6 @@ buildPythonPackage rec {
preCheck = ''
cd $TMPDIR
export HOME=$TMPDIR
export OMP_NUM_THREADS=1
'';
meta = {

View File

@@ -18,6 +18,8 @@
blas,
lapack,
openmpCheckPhaseHook,
# Reverse dependency
sage,
@@ -93,7 +95,6 @@ buildPythonPackage (finalAttrs: {
# see https://github.com/OpenMathLib/OpenBLAS/issues/2993
preConfigure = ''
sed -i 's/-faltivec//' numpy/distutils/system_info.py
export OMP_NUM_THREADS=$((NIX_BUILD_CORES > 64 ? 64 : NIX_BUILD_CORES))
'';
preBuild = ''
@@ -110,6 +111,10 @@ buildPythonPackage (finalAttrs: {
typing-extensions
];
propagatedNativeBuildInputs = [
openmpCheckPhaseHook
];
preCheck = ''
cd "$out"
'';

View File

@@ -19,6 +19,8 @@
coreutils,
lapack,
openmpCheckPhaseHook,
# Reverse dependency
sage,
@@ -86,12 +88,8 @@ buildPythonPackage (finalAttrs: {
]
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ mesonEmulatorHook ];
# we default openblas to build with 64 threads
# if a machine has more than 64 threads, it will segfault
# see https://github.com/OpenMathLib/OpenBLAS/issues/2993
preConfigure = ''
sed -i 's/-faltivec//' numpy/distutils/system_info.py
export OMP_NUM_THREADS=$((NIX_BUILD_CORES > 64 ? 64 : NIX_BUILD_CORES))
'';
buildInputs = [
@@ -113,6 +111,10 @@ buildPythonPackage (finalAttrs: {
typing-extensions
];
propagatedNativeBuildInputs = [
openmpCheckPhaseHook
];
preCheck = ''
pushd $out
# For numpy-config executable to be available during tests

View File

@@ -61,7 +61,6 @@ buildPythonPackage {
preCheck = ''
# Set config used by tests to ensure reproducibility
echo 'pbc_tools_pbc_fft_engine = "NUMPY"' > pyscf/pyscf_config.py
export OMP_NUM_THREADS=1
ulimit -s 20000
export PYSCF_CONFIG_FILE=$(pwd)/pyscf/pyscf_config.py
'';

View File

@@ -62,7 +62,6 @@ buildPythonPackage (finalAttrs: {
# This is due to the Cython-compiled modules not being in the correct location
# of the source tree.
preCheck = ''
export OMP_NUM_THREADS=$NIX_BUILD_CORES
mkdir -p test && cd test
'';

View File

@@ -116,7 +116,6 @@ buildPythonPackage rec {
preCheck = ''
cd $TMPDIR
export HOME=$TMPDIR
export OMP_NUM_THREADS=1
'';
pythonImportsCheck = [ "sklearn" ];

View File

@@ -190,11 +190,6 @@ buildPythonPackage (finalAttrs: {
'';
preCheck = ''
export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
if [ $OMP_NUM_THREADS -eq 0 ]; then
export OMP_NUM_THREADS=1
fi
cd $out
'';