bscpkgs/garlic/apps/fwi/default.nix

75 lines
1.8 KiB
Nix
Raw Normal View History

2020-07-20 12:58:54 +02:00
{
stdenv
2020-10-30 15:21:23 +01:00
, mpi ? null
, tampi ? null
, mcxx ? null
, cc
, gitBranch ? "garlic/tampi+send+oss+task"
2021-04-19 13:32:43 +02:00
, gitCommit ? null
, fwiParams
2021-04-19 13:32:43 +02:00
, garlicTools
2020-07-20 12:58:54 +02:00
}:
2020-10-30 15:21:23 +01:00
with stdenv.lib;
assert !(tampi != null && mcxx == null);
2021-04-19 13:32:43 +02:00
let
gitSource = garlicTools.fetchGarlicApp {
appName = "fwi";
inherit gitCommit gitBranch;
gitTable = import ./git-table.nix;
2020-07-20 12:58:54 +02:00
};
2021-04-19 13:32:43 +02:00
in
stdenv.mkDerivation rec {
name = "fwi";
inherit (gitSource) src gitBranch gitCommit;
enableParallelBuilding = false;
2020-07-20 12:58:54 +02:00
2021-04-19 13:32:43 +02:00
buildInputs = [
cc
]
++ optional (mpi != null) mpi
++ optional (tampi != null) tampi
++ optional (mcxx != null) mcxx;
2020-07-20 12:58:54 +02:00
2021-04-19 13:32:43 +02:00
# FIXME: Correct this on the Makefile so we can just type "make fwi"
# FIXME: Allow multiple MPI implementations
postPatch = ''
sed -i 's/= OPENMPI$/= INTEL/g' Makefile
sed -i 's/USE_O_DIRECT ?= NO/USE_O_DIRECT ?= YES/g' Makefile || true
'';
2021-04-19 13:32:43 +02:00
# FIXME: This is an ugly hack.
# When using _GNU_SOURCE or any other definition used in features.h, we need
# to define them before mcc includes nanos6.h from the command line. So the
# only chance is by setting it at the command line with -D. Using the DEFINES
# below, reaches the command line of the preprocessing stage with gcc.
preConfigure = ''
export DEFINES=-D_GNU_SOURCE
2020-07-20 12:58:54 +02:00
2021-04-19 13:32:43 +02:00
make depend
2021-04-19 13:32:43 +02:00
cp ${fwiParams}/generated_model_params.h src/
'';
2021-04-19 13:32:43 +02:00
# We compile the ModelGenerator using gcc *only*, as otherwise it will
# be compiled with nanos6, which requires access to /sys to determine
# hardware capabilities. So it will fail in the nix-build environment,
# as there is no /sys mounted.
makeFlags = [
#"COMPILER=GNU"
#"CC=${cc.cc.CC}"
"fwi"
];
2021-04-19 13:32:43 +02:00
installPhase = ''
mkdir -p $out/bin
cp fwi $out/bin
'';
2020-10-30 15:21:23 +01:00
2021-04-19 13:32:43 +02:00
programPath = "/bin/fwi";
}