From 9f314b7028c90c1600144c7a9b944d04ff6b60ec Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Wed, 15 May 2024 15:01:06 +0200 Subject: [PATCH 1/6] cp2k: remove dev inputs from dependecies --- .../science/chemistry/cp2k/default.nix | 17 +++++++-- .../cp2k/remove-compiler-options.patch | 37 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 pkgs/applications/science/chemistry/cp2k/remove-compiler-options.patch diff --git a/pkgs/applications/science/chemistry/cp2k/default.nix b/pkgs/applications/science/chemistry/cp2k/default.nix index 42bfc6ffe32e..8a831fe23b74 100644 --- a/pkgs/applications/science/chemistry/cp2k/default.nix +++ b/pkgs/applications/science/chemistry/cp2k/default.nix @@ -64,6 +64,12 @@ stdenv.mkDerivation rec { fetchSubmodules = true; }; + patches = [ + # Remove the build command line from the source. + # This avoids dependencies to .dev inputs + ./remove-compiler-options.patch + ]; + nativeBuildInputs = [ python3 which openssh makeWrapper pkg-config ] ++ lib.optional (gpuBackend == "cuda") cudaPackages.cuda_nvcc; @@ -75,6 +81,7 @@ stdenv.mkDerivation rec { libvori libxc libxsmm + mpi spglib scalapack blas @@ -101,7 +108,7 @@ stdenv.mkDerivation rec { ] ; - propagatedBuildInputs = [ mpi ]; + propagatedBuildInputs = [ (lib.getBin mpi) ]; propagatedUserEnvPkgs = [ mpi ]; makeFlags = [ @@ -149,14 +156,16 @@ stdenv.mkDerivation rec { -D__PLUMED2 -D__HDF5 -D__GSL -D__SIRIUS -D__LIBVDWXC -D__SPFFT -D__SPLA \ ${lib.strings.optionalString (gpuBackend == "cuda") "-D__OFFLOAD_CUDA -D__ACC -D__DBCSR_ACC -D__NO_OFFLOAD_PW"} \ ${lib.strings.optionalString (gpuBackend == "rocm") "-D__OFFLOAD_HIP -D__DBCSR_ACC -D__NO_OFFLOAD_PW"} - CFLAGS = -fopenmp -I${lib.getDev hdf5-fortran}/include -I${lib.getDev gsl}/include + CFLAGS = -fopenmp FCFLAGS = \$(DFLAGS) -O2 -ffree-form -ffree-line-length-none \ -ftree-vectorize -funroll-loops -msse2 \ -std=f2008 \ -fopenmp -ftree-vectorize -funroll-loops \ - -I${lib.getDev libint}/include ${lib.optionalString enableElpa "$(pkg-config --variable=fcflags elpa)"} \ + ${lib.optionalString enableElpa "$(pkg-config --variable=fcflags elpa)"} \ + -I${lib.getDev libint}/include \ -I${lib.getDev sirius}/include/sirius \ - -I${lib.getDev libxc}/include -I${lib.getDev libxsmm}/include \ + -I${lib.getDev libxc}/include \ + -I${lib.getDev libxsmm}/include \ -I${lib.getDev hdf5-fortran}/include \ -fallow-argument-mismatch LIBS = -lfftw3 -lfftw3_threads \ diff --git a/pkgs/applications/science/chemistry/cp2k/remove-compiler-options.patch b/pkgs/applications/science/chemistry/cp2k/remove-compiler-options.patch new file mode 100644 index 000000000000..e6cf81494aa3 --- /dev/null +++ b/pkgs/applications/science/chemistry/cp2k/remove-compiler-options.patch @@ -0,0 +1,37 @@ +diff --git a/src/start/cp2k.F b/src/start/cp2k.F +index f69146ea3..a195f0620 100644 +--- a/src/start/cp2k.F ++++ b/src/start/cp2k.F +@@ -58,8 +58,7 @@ PROGRAM cp2k + USE input_cp2k, ONLY: create_cp2k_root_section + USE input_section_types, ONLY: section_release,& + section_type +- USE iso_fortran_env, ONLY: compiler_options,& +- compiler_version ++ USE iso_fortran_env, ONLY: compiler_version + USE kinds, ONLY: default_path_length + USE machine, ONLY: default_output_unit + #include "../base/base_uses.f90" +@@ -70,7 +69,6 @@ PROGRAM cp2k + arg_att, command + CHARACTER(LEN=default_path_length), & + DIMENSION(:, :), ALLOCATABLE :: initial_variables, initial_variables_tmp +- CHARACTER(LEN=:), ALLOCATABLE :: compiler_options_string + INTEGER :: output_unit, l, i, var_set_sep, inp_var_idx + INTEGER :: ierr, i_arg + LOGICAL :: check, usage, echo_input, command_line_error +@@ -328,14 +326,6 @@ PROGRAM cp2k + WRITE (output_unit, "(T2,A)") cp2k_version, & + "Source code revision "//TRIM(compile_revision), & + TRIM(cp2k_flags()) +- compiler_options_string = compiler_options() +- WRITE (output_unit, "(T2,A,A)") "compiler: ", compiler_version() +- WRITE (output_unit, "(T2,A)") "compiler options:" +- DO i = 0, (LEN(compiler_options_string) - 1)/68 +- WRITE (output_unit, "(T4,A)") & +- compiler_options_string(i*68 + 1:MIN(LEN(compiler_options_string), (i + 1)*68)) +- END DO +- DEALLOCATE (compiler_options_string) + END IF + END IF + From d088402121311147d281ec134ef198472666f595 Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Thu, 16 May 2024 11:04:31 +0200 Subject: [PATCH 2/6] pythonPackages.gpaw: fix propagatedBuildInputs --- pkgs/development/python-modules/gpaw/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/gpaw/default.nix b/pkgs/development/python-modules/gpaw/default.nix index 37b12c6f5ed4..033a7a418597 100644 --- a/pkgs/development/python-modules/gpaw/default.nix +++ b/pkgs/development/python-modules/gpaw/default.nix @@ -6,6 +6,7 @@ , blas , lapack , mpi +, fftw , scalapack , libxc , libvdwxc @@ -89,9 +90,9 @@ in buildPythonPackage rec { # execute `rsh` as a side-effect. nativeBuildInputs = [ which inetutils ]; - buildInputs = [ blas scalapack libxc libvdwxc ]; + buildInputs = [ blas scalapack libxc libvdwxc fftw ]; - propagatedBuildInputs = [ ase scipy numpy mpi pyyaml ]; + propagatedBuildInputs = [ ase scipy numpy (lib.getBin mpi) pyyaml ]; patches = [ ./SetupPath.patch ]; From 28ef74d293b70976e653853efdfcd378fc63dc82 Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Thu, 16 May 2024 11:01:32 +0200 Subject: [PATCH 3/6] sirius: split outputs (out,dev) and fix propagatedBuildInputs --- pkgs/by-name/si/sirius/package.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/si/sirius/package.nix b/pkgs/by-name/si/sirius/package.nix index c8e42ff72fc8..c4d4d0506510 100644 --- a/pkgs/by-name/si/sirius/package.nix +++ b/pkgs/by-name/si/sirius/package.nix @@ -47,6 +47,9 @@ stdenv.mkDerivation rec { hash = "sha256-DYie6ufgZNqg7ohlIed3Bo+sqLKHOxWXTwAkea2guLk="; }; + + outputs = [ "out" "dev" ]; + nativeBuildInputs = [ cmake gfortran @@ -60,6 +63,7 @@ stdenv.mkDerivation rec { libxc hdf5 umpire + mpi spglib spfft spla @@ -80,7 +84,7 @@ stdenv.mkDerivation rec { ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp ; - propagatedBuildInputs = [ mpi ]; + propagatedBuildInputs = [ (lib.getBin mpi) ]; CXXFLAGS = [ # GCC 13: error: 'uintptr_t' in namespace 'std' does not name a type From ecd2c2a61eddd31c19c4369591146b91129afb5a Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Thu, 16 May 2024 11:02:42 +0200 Subject: [PATCH 4/6] spfft: do not use propagatedBuildInputs for mpi --- pkgs/by-name/sp/spfft/package.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/by-name/sp/spfft/package.nix b/pkgs/by-name/sp/spfft/package.nix index f7e8b3742581..65e98b92b4f2 100644 --- a/pkgs/by-name/sp/spfft/package.nix +++ b/pkgs/by-name/sp/spfft/package.nix @@ -38,6 +38,7 @@ stdenv.mkDerivation rec { buildInputs = [ fftw + mpi ] ++ lib.optionals (gpuBackend == "cuda") [ cudaPackages.libcufft cudaPackages.cuda_cudart @@ -48,8 +49,6 @@ stdenv.mkDerivation rec { ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp ; - propagatedBuildInputs = [ mpi ]; - cmakeFlags = [ "-DSPFFT_OMP=ON" "-DSPFFT_MPI=ON" From af6e7759a5043ff01032f28fb5f0feb50d90c742 Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Thu, 16 May 2024 11:03:18 +0200 Subject: [PATCH 5/6] spla: split outputs (out,dev); do not use propagatedBuildInputs --- pkgs/by-name/sp/spla/package.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/sp/spla/package.nix b/pkgs/by-name/sp/spla/package.nix index 210fb04af9b8..98222aa7c1f5 100644 --- a/pkgs/by-name/sp/spla/package.nix +++ b/pkgs/by-name/sp/spla/package.nix @@ -31,6 +31,8 @@ stdenv.mkDerivation rec { hash = "sha256-71QpwTsRogH+6Bik9DKwezl9SqwoLxQt4SZ7zw5X6DE="; }; + outputs = [ "out" "dev" ]; + postPatch = '' substituteInPlace src/gpu_util/gpu_blas_api.hpp \ --replace '#include ' '#include ' @@ -43,6 +45,7 @@ stdenv.mkDerivation rec { buildInputs = [ blas + mpi ] ++ lib.optional (gpuBackend == "cuda") cudaPackages.cudatoolkit ++ lib.optionals (gpuBackend == "rocm") [ @@ -51,8 +54,6 @@ stdenv.mkDerivation rec { ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp ; - propagatedBuildInputs = [ mpi ]; - cmakeFlags = [ "-DSPLA_OMP=ON" "-DSPLA_FORTRAN=ON" @@ -65,10 +66,15 @@ stdenv.mkDerivation rec { ++ lib.optional (gpuBackend == "rocm") [ "-DSPLA_GPU_BACKEND=ROCM" ] ; + preFixup = '' + substituteInPlace $out/lib/cmake/SPLA/SPLASharedTargets-release.cmake \ + --replace-fail "\''${_IMPORT_PREFIX}" "$out" + ''; + meta = with lib; { description = "Specialized Parallel Linear Algebra, providing distributed GEMM functionality for specific matrix distributions with optional GPU acceleration"; homepage = "https://github.com/eth-cscs/spla"; license = licenses.bsd3; - maintainers = [ maintainers.sheepforce ];# + maintainers = [ maintainers.sheepforce ]; }; } From e3df5db4604515706d44a662cfe0499838baf5a1 Mon Sep 17 00:00:00 2001 From: Markus Kowalewski Date: Thu, 16 May 2024 11:06:12 +0200 Subject: [PATCH 6/6] libvdwxc: do not use propagatedBuildInputs --- .../libraries/science/chemistry/libvdwxc/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix b/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix index c0da65e7c788..c843d443e81e 100644 --- a/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix +++ b/pkgs/development/libraries/science/chemistry/libvdwxc/default.nix @@ -21,7 +21,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ autoreconfHook gfortran ]; - propagatedBuildInputs = [ mpi fftwMpi ]; + buildInputs = [ mpi fftwMpi ]; preConfigure = '' mkdir build && cd build