Add support in nix for mkl

This commit is contained in:
Alejandro Gallo 2021-10-13 12:22:58 +02:00
parent b72303cad4
commit a9ddbf4f1a
3 changed files with 52 additions and 20 deletions

13
etc/nix/mkl.nix Normal file
View File

@ -0,0 +1,13 @@
{ pkgs, ...}:
{
buildInputs = with pkgs; [
mkl
];
shellHook = ''
export MKL_PATH=${pkgs.mkl}
export LD_LIBRARY_PATH=$MKL_PATH:$LD_LIBRARY_PATH
'';
}

16
etc/nix/openblas.nix Normal file
View File

@ -0,0 +1,16 @@
{ pkgs, ...}:
{
buildInputs = with pkgs; [
openblas
scalapack
];
shellHook = ''
export OPENBLAS_PATH=${pkgs.openblas}
export SCALAPACK_PATH=${pkgs.scalapack}
export LD_LIBRARY_PATH=${pkgs.scalapack}/lib:$LD_LIBRARY_PATH
'';
}

View File

@ -1,7 +1,13 @@
{ pkgs ? import <nixpkgs> {} , with-clang ? false }: { pkgs ? import <nixpkgs> {} , with-clang ? false , with-mkl ? false }:
let let
mkl = import ./etc/nix/mkl.nix { pkgs = (import <nixpkgs> {
config.allowUnfree = true;
}); };
openblas = import ./etc/nix/openblas.nix { inherit pkgs; };
clang = import ./etc/nix/clang.nix { inherit pkgs; }; clang = import ./etc/nix/clang.nix { inherit pkgs; };
compiler-configuration compiler-configuration
@ -13,28 +19,25 @@ in
pkgs.mkShell { pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs
= with pkgs; [
coreutils coreutils
git git
blas
openmpi openmpi
gnumake gnumake
binutils binutils
emacs emacs
]
++ compiler-configuration
++ (if with-mkl then mkl.buildInputs else openblas.buildInputs)
;
] ++ compiler-configuration; shellHook
= (if with-clang then clang.shellHook else "")
shellHook = '' + (if with-mkl then mkl.shellHook else openblas.shellHook)
export LAPACK_PATH=${pkgs.lapack}
export BLAS_PATH=${pkgs.blas}
export OPENBLAS_PATH=${pkgs.openblas}
export SCALAPACK_PATH=${pkgs.scalapack}
export LD_LIBRARY_PATH=${pkgs.scalapack}/lib:$LD_LIBRARY_PATH
''
+ (if with-clang then clang.shellHook else "")
; ;
} }