about summary refs log tree commit diff
path: root/pkgs/by-name/si/sirius/package.nix
blob: 34ee961d14040a8b472cddf3aeb1c11441042007 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{ stdenv
, lib
, fetchFromGitHub
, cmake
, pkg-config
, mpi
, mpiCheckPhaseHook
, openssh
, gfortran
, blas
, lapack
, gsl
, libxc
, hdf5
, spglib
, spfft
, spla
, costa
, umpire
, scalapack
, boost
, eigen
, libvdwxc
, enablePython ? false
, pythonPackages ? null
, llvmPackages
, cudaPackages
, rocmPackages
, config
, gpuBackend ? (
  if config.cudaSupport
  then "cuda"
  else if config.rocmSupport
  then "rocm"
  else "none"
)
}:

assert builtins.elem gpuBackend [ "none" "cuda" "rocm" ];
assert enablePython -> pythonPackages != null;

stdenv.mkDerivation rec {
  pname = "SIRIUS";
  version = "7.6.1";

  src = fetchFromGitHub {
    owner = "electronic-structure";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-JvI75AbthNThXep2jcriLTPC8GGiPgrg5nYCCbCi+EI=";
  };


  outputs = [ "out" "dev" ];

  nativeBuildInputs = [
    cmake
    gfortran
    pkg-config
  ] ++ lib.optional (gpuBackend == "cuda") cudaPackages.cuda_nvcc;

  buildInputs = [
    blas
    lapack
    gsl
    libxc
    hdf5
    umpire
    mpi
    spglib
    spfft
    spla
    costa
    scalapack
    boost
    eigen
    libvdwxc
  ]
  ++ lib.optionals (gpuBackend == "cuda") [
    cudaPackages.cuda_cudart
    cudaPackages.cuda_profiler_api
    cudaPackages.cudatoolkit
    cudaPackages.libcublas
  ] ++ lib.optionals (gpuBackend == "rocm") [
    rocmPackages.clr
    rocmPackages.rocblas
  ] ++ lib.optionals stdenv.isDarwin [
    llvmPackages.openmp
  ] ++ lib.optionals enablePython (with pythonPackages; [
    python
    pybind11
  ]);

  propagatedBuildInputs = [
    (lib.getBin mpi)
  ] ++ lib.optionals enablePython (with pythonPackages; [
    mpi4py
    voluptuous
    numpy
    h5py
    scipy
    pyyaml
  ]);

  CXXFLAGS = [
    # GCC 13: error: 'uintptr_t' in namespace 'std' does not name a type
    "-include cstdint"
  ];

  cmakeFlags = [
    "-DSIRIUS_USE_SCALAPACK=ON"
    "-DSIRIUS_USE_VDWXC=ON"
    "-DSIRIUS_CREATE_FORTRAN_BINDINGS=ON"
    "-DSIRIUS_USE_OPENMP=ON"
    "-DBUILD_TESTING=ON"
  ] ++ lib.optionals (gpuBackend == "cuda") [
    "-DSIRIUS_USE_CUDA=ON"
    "-DCUDA_TOOLKIT_ROOT_DIR=${cudaPackages.cudatoolkit}"
    (lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaPackages.flags.cmakeCudaArchitecturesString)
  ] ++ lib.optionals (gpuBackend == "rocm") [
    "-DSIRIUS_USE_ROCM=ON"
    "-DHIP_ROOT_DIR=${rocmPackages.clr}"
  ] ++ lib.optionals enablePython [
    "-DSIRIUS_CREATE_PYTHON_MODULE=ON"
  ];

  doCheck = true;

  # Can not run parallel checks generally as it requires exactly multiples of 4 MPI ranks
  # Even cpu_serial tests had to be disabled as they require scalapack routines in the sandbox
  # and run into the same problem as MPI tests
  checkPhase = ''
    runHook preCheck

    ctest --output-on-failure --label-exclude integration_test

    runHook postCheck
  '';

  nativeCheckInputs = [
    mpiCheckPhaseHook
    openssh
  ];

  meta = with lib; {
    description = "Domain specific library for electronic structure calculations";
    homepage = "https://github.com/electronic-structure/SIRIUS";
    license = licenses.bsd2;
    platforms = platforms.linux;
    maintainers = [ maintainers.sheepforce ];
  };
}