openmpCheckPhaseHook: init (#535725)

This commit is contained in:
Martin Weinelt 2026-06-26 17:19:01 +00:00 committed by GitHub
commit d862c1367f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 68 additions and 101 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

@ -2881,6 +2881,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

@ -89,10 +89,6 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
'';
passthru.updateScript = nix-update-script { };
meta = {

View file

@ -81,10 +81,6 @@ stdenv.mkDerivation (finalAttrs: {
app/tester.py
'';
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Generally Applicable Atomic-Charge Dependent London Dispersion Correction";
changelog = "https://github.com/dftd4/dftd4/releases/tag/${finalAttrs.src.tag}";

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
@ -63,10 +65,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,8 +1,8 @@
{
lib,
callPackage,
makeSetupHook,
stdenv,
openmpCheckPhaseHook,
}:
makeSetupHook {
@ -13,5 +13,9 @@ makeSetupHook {
topology = ./topology.xml;
};
propagatedNativeBuildInputs = [
openmpCheckPhaseHook
];
meta.license = lib.licenses.mit;
} ./mpi-check-hook.sh

View file

@ -80,10 +80,6 @@ stdenv.mkDerivation (finalAttrs: {
echo 'set(custom-lapack_FOUND TRUE)' >> config/cmake/Findcustom-lapack.cmake
'';
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = {
description = "Electronegativity equilibration model for atomic partial charges";
mainProgram = "multicharge";

View file

@ -90,10 +90,6 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
'';
passthru.updateScript = nix-update-script { };
meta = {

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

@ -89,9 +89,6 @@ stdenv.mkDerivation (finalAttrs: {
];
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
'';
passthru.updateScript = nix-update-script {
extraArgs = [ "--version=branch" ];

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

@ -100,10 +100,6 @@ stdenv.mkDerivation (finalAttrs: {
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

@ -52,10 +52,6 @@ buildPythonPackage rec {
scikit-learn
];
preCheck = ''
export OMP_NUM_THREADS=1
'';
disabledTestPaths =
lib.optionals stdenv.hostPlatform.isDarwin [
# These tests may fail if multiple builds run them at the same time due

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

@ -67,8 +67,6 @@ buildPythonPackage (finalAttrs: {
preCheck = ''
rm linearmodels/__init__.py
export OMP_NUM_THREADS=1
'';
disabledTestPaths = [

View file

@ -82,10 +82,6 @@ buildPythonPackage (finalAttrs: {
writableTmpDirAsHomeHook
];
preCheck = ''
export OMP_NUM_THREADS=1
'';
disabledTests = [
# _pickle.PickleError: ScriptFunction cannot be pickled
"test_run_eval_fail_with_wrong_model"

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,
@ -91,10 +93,6 @@ buildPythonPackage (finalAttrs: {
]
++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ mesonEmulatorHook ];
preConfigure = ''
export OMP_NUM_THREADS=$((NIX_BUILD_CORES > 64 ? 64 : NIX_BUILD_CORES))
'';
buildInputs = [
blas
lapack
@ -122,6 +120,10 @@ buildPythonPackage (finalAttrs: {
ln -s ${placeholder "out"}/${finalAttrs.passthru.coreIncludeInnerDir} $out/include
'';
propagatedNativeBuildInputs = [
openmpCheckPhaseHook
];
preCheck = ''
pushd $out
# For numpy-config executable to be available during tests

View file

@ -80,7 +80,6 @@ buildPythonPackage (finalAttrs: {
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

@ -62,10 +62,6 @@ buildPythonPackage (finalAttrs: {
pytestCheckHook
];
preCheck = ''
export OMP_NUM_THREADS=1
'';
# only the $out dir contains the built cython extensions, so we run the tests inside there
enabledTestPaths = [ "${placeholder "out"}/${python.sitePackages}/skbio" ];

View file

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

View file

@ -175,11 +175,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
'';

View file

@ -185,10 +185,6 @@ buildPythonPackage (finalAttrs: {
writableTmpDirAsHomeHook
];
preCheck = ''
export OMP_NUM_THREADS=1
'';
pytestFlags = [
# DeprecationWarning: Failing to pass a value to the 'type_params' parameter of
# 'typing._eval_type' is deprecated, as it leads to incorrect behaviour when calling

View file

@ -42,10 +42,6 @@ buildPythonPackage (finalAttrs: {
nativeCheckInputs = [ pytestCheckHook ];
preCheck = ''
export OMP_NUM_THREADS=1
'';
# RuntimeError: torch.compile is not supported on Python 3.14+
disabledTests = lib.optionals (pythonAtLeast "3.14") [ "test_up" ];