mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-22 23:39:02 +08:00
try to use intel vasp
This commit is contained in:
parent
b275b831c0
commit
037d226585
@ -46,7 +46,9 @@ inputs:
|
||||
}
|
||||
// (if nixpkgs.march == null then {} else
|
||||
{
|
||||
oneapiArch = let match = { znver3 = "CORE-AVX2"; znver4 = "CORE-AVX512"; };
|
||||
# TODO: change znver4 after update oneapi
|
||||
# TODO: test znver3 do use AVX
|
||||
oneapiArch = let match = { znver3 = "CORE-AVX2"; znver4 = "znver3"; };
|
||||
in match.${nixpkgs.march} or nixpkgs.march;
|
||||
nvhpcArch = nixpkgs.march;
|
||||
# contentAddressedByDefault = true;
|
||||
|
@ -52,9 +52,9 @@ inputs: rec
|
||||
nvidia = inputs.pkgs.callPackage ./vasp/nvidia
|
||||
{ inherit lmod nvhpc vtst src; hdf5 = hdf5-nvhpc; };
|
||||
intel = inputs.pkgs.callPackage ./vasp/intel
|
||||
{ inherit lmod oneapi vtst src; hdf5 = hdf5-oneapi; };
|
||||
{ inherit vtst src; inherit (inputs.pkgs.intelPackages_2023) stdenv; hdf5 = hdf5-oneapi; };
|
||||
hdf5-nvhpc = inputs.pkgs.callPackage ./vasp/hdf5-nvhpc { inherit lmod nvhpc; inherit (inputs.pkgs.hdf5) src; };
|
||||
hdf5-oneapi = inputs.pkgs.callPackage ./vasp/hdf5-oneapi { inherit lmod oneapi; inherit (inputs.pkgs.hdf5) src; };
|
||||
hdf5-oneapi = inputs.pkgs.hdf5.override { inherit (inputs.pkgs.intelPackages_2023) stdenv; };
|
||||
vtst = (inputs.pkgs.callPackage ./vasp/vtst.nix {});
|
||||
vtstscripts = inputs.pkgs.callPackage ./vasp/vtstscripts.nix {};
|
||||
};
|
||||
|
@ -1,48 +0,0 @@
|
||||
{
|
||||
buildFHSEnv, writeScript, stdenvNoCC, symlinkJoin,
|
||||
src,
|
||||
oneapi, lmod, cmake, gcc, glibc, binutils,
|
||||
config, oneapiArch ? config.oneapiArch or "SSE3"
|
||||
}:
|
||||
let
|
||||
gccFull = symlinkJoin { name = "gcc"; paths = [ gcc gcc.cc gcc.cc.lib glibc.dev binutils.bintools ]; };
|
||||
buildEnv = buildFHSEnv
|
||||
{
|
||||
name = "buildEnv";
|
||||
targetPkgs = pkgs: with pkgs; [ zlib (writeTextDir "etc/release" "") gccFull ];
|
||||
extraBwrapArgs = [ "--bind" "$out" "$out" ];
|
||||
};
|
||||
buildScript = writeScript "build"
|
||||
''
|
||||
. ${lmod}/share/lmod/lmod/init/bash
|
||||
module use ${oneapi}/share/intel/modulefiles
|
||||
module load tbb compiler-rt oclfpga # dependencies
|
||||
module load mpi mkl compiler
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=$out -DHDF5_INSTALL_CMAKE_DIR=$out/lib/cmake \
|
||||
-DHDF5_BUILD_FORTRAN=ON -DHDF5_ENABLE_PARALLEL=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=OFF \
|
||||
-DBUILD_TESTING=OFF ..
|
||||
make -j$NIX_BUILD_CORES
|
||||
make install
|
||||
'';
|
||||
in stdenvNoCC.mkDerivation
|
||||
{
|
||||
name = "hdf5-oneapi";
|
||||
inherit src;
|
||||
dontConfigure = true;
|
||||
enableParallelBuilding = true;
|
||||
nativeBuildInputs = [ cmake ];
|
||||
I_MPI_CC = "icx";
|
||||
I_MPI_CXX = "icpx";
|
||||
I_MPI_FC = "ifx";
|
||||
I_MPI_F90 = "ifx";
|
||||
buildPhase =
|
||||
''
|
||||
mkdir -p $out
|
||||
${buildEnv}/bin/buildEnv ${buildScript}
|
||||
'';
|
||||
dontInstall = true;
|
||||
dontFixup = true;
|
||||
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
|
||||
}
|
@ -1,33 +1,13 @@
|
||||
{
|
||||
buildFHSEnv, writeScript, stdenvNoCC, substituteAll, symlinkJoin, writeTextDir, src,
|
||||
config, oneapiArch ? config.oneapiArch or "SSE3",
|
||||
oneapi, gcc, glibc, lmod, rsync, which, wannier90, binutils, hdf5, zlib, vtst
|
||||
}:
|
||||
let
|
||||
buildEnv = buildFHSEnv
|
||||
{
|
||||
name = "buildEnv";
|
||||
# make "module load mpi" success
|
||||
targetPkgs = _: [ zlib (writeTextDir "etc/release" "") gccFull ];
|
||||
};
|
||||
buildScript = writeScript "build"
|
||||
''
|
||||
. ${lmod}/share/lmod/lmod/init/bash
|
||||
module use ${oneapi}/share/intel/modulefiles
|
||||
module load tbb compiler-rt oclfpga # dependencies
|
||||
module load mpi mkl compiler
|
||||
make DEPS=1 -j$NIX_BUILD_CORES
|
||||
'';
|
||||
include = substituteAll { src = ./makefile.include; inherit oneapiArch; };
|
||||
gccFull = symlinkJoin { name = "gcc"; paths = [ gcc gcc.cc gcc.cc.lib glibc.dev binutils.bintools ]; };
|
||||
vasp = stdenvNoCC.mkDerivation
|
||||
stdenv, src, rsync, which, wannier90, hdf5, vtst
|
||||
}: stdenv.mkDerivation
|
||||
{
|
||||
name = "vasp-intel";
|
||||
inherit src;
|
||||
# patches = [ ../vtst.patch ];
|
||||
configurePhase =
|
||||
''
|
||||
cp ${include} makefile.include
|
||||
cp ${./makefile.include} makefile.include
|
||||
chmod +w makefile.include
|
||||
cp ${../constr_cell_relax.F} src/constr_cell_relax.F
|
||||
# cp -r ${vtst}/* src
|
||||
@ -36,7 +16,6 @@ let
|
||||
nativeBuildInputs = [ rsync which ];
|
||||
HDF5_ROOT = hdf5;
|
||||
WANNIER90_ROOT = wannier90;
|
||||
buildPhase = "${buildEnv}/bin/buildEnv ${buildScript}";
|
||||
installPhase =
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
@ -45,63 +24,4 @@ let
|
||||
ln -s ${src} $out/src/vasp
|
||||
ln -s ${vtst} $out/src/vtst
|
||||
'';
|
||||
dontFixup = true;
|
||||
requiredSystemFeatures = [ "gccarch-exact-${stdenvNoCC.hostPlatform.gcc.arch}" "big-parallel" ];
|
||||
};
|
||||
startScript = variant: writeScript "vasp-intel"
|
||||
''
|
||||
. ${lmod}/share/lmod/lmod/init/bash
|
||||
module use ${oneapi}/share/intel/modulefiles
|
||||
module load tbb compiler-rt oclfpga # dependencies
|
||||
module load mpi mkl compiler
|
||||
|
||||
# if OMP_NUM_THREADS is not set, set it according to SLURM_CPUS_PER_TASK or to 1
|
||||
if [ -z "''${OMP_NUM_THREADS-}" ]; then
|
||||
if [ -n "''${SLURM_CPUS_PER_TASK-}" ]; then
|
||||
OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
|
||||
else
|
||||
OMP_NUM_THREADS=1
|
||||
fi
|
||||
fi
|
||||
export OMP_NUM_THREADS
|
||||
|
||||
# if I_MPI_PIN_PROCESSOR_LIST is not set, set it to allcores
|
||||
if [ -z "''${I_MPI_PIN_PROCESSOR_LIST-}" ]; then
|
||||
I_MPI_PIN_PROCESSOR_LIST=allcores
|
||||
fi
|
||||
export I_MPI_PIN_PROCESSOR_LIST
|
||||
|
||||
# set I_MPI_PIN I_MPI_PIN_DOMAIN I_MPI_DEBUG if not set
|
||||
export I_MPI_PIN=''${I_MPI_PIN-yes}
|
||||
export I_MPI_PIN_DOMAIN=''${I_MPI_PIN_DOMAIN-omp}
|
||||
export I_MPI_DEBUG=''${I_MPI_DEBUG-4}
|
||||
|
||||
# fork to bootstrap, do not use srun, causing it could not find proper ld
|
||||
export I_MPI_HYDRA_BOOTSTRAP=''${I_MPI_HYDRA_BOOTSTRAP-fork}
|
||||
|
||||
# set OMP_STACKSIZE if not set
|
||||
export OMP_STACKSIZE=''${OMP_STACKSIZE-512M}
|
||||
|
||||
${
|
||||
if variant == "env" then ''exec "$@"''
|
||||
else
|
||||
''
|
||||
if [ -n "''${SLURM_JOB_ID-}" ]; then
|
||||
exec mpirun -n $SLURM_NTASKS ${vasp}/bin/vasp-${variant}
|
||||
else
|
||||
exec mpirun -n 1 ${vasp}/bin/vasp-${variant}
|
||||
fi
|
||||
''
|
||||
}
|
||||
'';
|
||||
runEnv = variant: buildFHSEnv
|
||||
{
|
||||
name = "vasp-intel${if variant == "" then "" else "-${variant}"}";
|
||||
targetPkgs = _: [ zlib vasp (writeTextDir "etc/release" "") gccFull ];
|
||||
runScript = startScript (if variant == "" then "std" else variant);
|
||||
};
|
||||
in symlinkJoin
|
||||
{
|
||||
name = "vasp-intel";
|
||||
paths = builtins.map (variant: runEnv variant) [ "" "env" "std" "gam" "ncl" ];
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ LLIBS = -lstdc++
|
||||
|
||||
# When compiling on the target machine itself, change this to the
|
||||
# relevant target when cross-compiling for another architecture
|
||||
VASP_TARGET_CPU ?= -x@oneapiArch@
|
||||
FFLAGS += $(VASP_TARGET_CPU)
|
||||
# VASP_TARGET_CPU ?= -x@oneapiArch@
|
||||
# FFLAGS += $(VASP_TARGET_CPU)
|
||||
|
||||
# Intel MKL (FFTW, BLAS, LAPACK, and scaLAPACK)
|
||||
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
|
||||
|
Loading…
Reference in New Issue
Block a user