fwi: split into input and solver

All branches compile with several hacks.
This commit is contained in:
Rodrigo Arias 2021-01-29 15:33:12 +01:00 committed by Aleix Roca Nonell
parent 9bea3cc264
commit bfbbc294ae
5 changed files with 114 additions and 50 deletions

View File

@ -4,7 +4,8 @@
, tampi ? null , tampi ? null
, mcxx ? null , mcxx ? null
, cc , cc
, gitBranch , gitBranch ? "garlic/tampi+send+oss+task"
, fwiInput
}: }:
with stdenv.lib; with stdenv.lib;
@ -12,6 +13,7 @@ with stdenv.lib;
assert !(tampi != null && mcxx == null); assert !(tampi != null && mcxx == null);
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
inherit gitBranch;
name = "fwi"; name = "fwi";
src = builtins.fetchGit { src = builtins.fetchGit {
@ -19,14 +21,20 @@ stdenv.mkDerivation rec {
ref = "${gitBranch}"; ref = "${gitBranch}";
}; };
enableParallelBuilding = true; enableParallelBuilding = false;
buildInputs = [ buildInputs = [
cc cc
] ]
++ optional (mpi != null) mpi ++ optional (mpi != null) mpi
++ optional (tampi != null) tampi ++ optional (tampi != null) tampi
++ optional (mcxx != null) mcxx; ++ optional (mcxx != null) mcxx;
# 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
'';
# FIXME: This is an ugly hack. # FIXME: This is an ugly hack.
# When using _GNU_SOURCE or any other definition used in features.h, we need # When using _GNU_SOURCE or any other definition used in features.h, we need
@ -35,33 +43,25 @@ stdenv.mkDerivation rec {
# below, reaches the command line of the preprocessing stage with gcc. # below, reaches the command line of the preprocessing stage with gcc.
preConfigure = '' preConfigure = ''
export DEFINES=-D_GNU_SOURCE export DEFINES=-D_GNU_SOURCE
export NANOS6_CONFIG_OVERRIDE=version.debug=true
make depend
cp ${fwiInput}/generated_model_params.h src/
''; '';
# We compile the ModelGenerator using gcc *only*, as otherwise it will # We compile the ModelGenerator using gcc *only*, as otherwise it will
# be compiled with nanos6, which requires access to /sys to determine # be compiled with nanos6, which requires access to /sys to determine
# hardware capabilities. So it will fail in the nix-build environment, # hardware capabilities. So it will fail in the nix-build environment,
# as there is no /sys mounted. # as there is no /sys mounted.
preBuild = ''
make COMPILER=GNU ModelGenerator
'';
makeFlags = [ makeFlags = [
"CC=${cc.cc.CC}" #"COMPILER=GNU"
#"CC=${cc.cc.CC}"
"fwi"
]; ];
postBuild = ''
make input
'';
#FIXME split the input in another derivation
installPhase = '' installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
cp fwi $out/bin cp fwi $out/bin
cp ModelGenerator $out/bin
mv InputModels $out/bin
mkdir -p $out/etc/fwi
cp SetupParams/{fwi_frequencies.txt,fwi_params.txt} $out/etc/fwi
''; '';
programPath = "/bin/fwi"; programPath = "/bin/fwi";

40
garlic/apps/fwi/input.nix Normal file
View File

@ -0,0 +1,40 @@
{
stdenv
}:
with stdenv.lib;
stdenv.mkDerivation rec {
name = "fwi-header";
src = builtins.fetchGit {
url = "https://gitlab.com/srodrb/BSC-FWI.git";
ref = "garlic/seq";
};
enableParallelBuilding = false;
# 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
'';
# 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.
# Also, we need to compile it with the builder platform as target, as is going
# to be executed during the build to generate the src/generated_model_params.h
# header.
makeFlags = [ "COMPILER=GNU" "params" "input" ];
installPhase = ''
mkdir -p $out/
cp src/generated_model_params.h $out/
cp -r InputModels $out/
'';
}

View File

@ -53,5 +53,10 @@
hpccg = callPackage ./hpccg/default.nix { }; hpccg = callPackage ./hpccg/default.nix { };
fwi = callPackage ./fwi/default.nix { }; fwi = rec {
input = callPackage ./fwi/input.nix { };
solver = callPackage ./fwi/default.nix {
fwiInput = input;
};
};
} }

View File

@ -11,24 +11,38 @@ with stdenv.lib;
let let
# Initial variable configuration # Initial variable configuration
varConf = { varConf = {
gitBranch = [
"garlic/tampi+send+oss+task"
"garlic/mpi+send+omp+task"
"garlic/mpi+send+oss+task"
"garlic/mpi+send+seq"
"garlic/oss+task"
"garlic/omp+task"
"garlic/seq"
];
}; };
machineConfig = targetMachine.config;
# Generate the complete configuration for each unit # Generate the complete configuration for each unit
genConf = with bsc; c: targetMachine.config // rec { genConf = with bsc; c: targetMachine.config // rec {
# Options for creams expName = "fwi";
cc = icc; unitName = "${expName}-test";
gitBranch = "seq"; inherit (machineConfig) hw;
# Repeat the execution of each unit 30 times cc = icc;
loops = 1; gitBranch = c.gitBranch;
# Repeat the execution of each unit several times
loops = 10;
# Resources # Resources
qos = "debug"; cpusPerTask = hw.cpusPerSocket;
nodes = 1;
time = "02:00:00";
ntasksPerNode = 1; ntasksPerNode = 1;
cpuBind = "rank,verbose"; nodes = 1;
jobName = "fwi-${gitBranch}"; qos = "debug";
time = "02:00:00";
jobName = unitName;
}; };
# Compute the array of configurations # Compute the array of configurations
@ -37,29 +51,30 @@ let
}; };
# Custom stage to copy the FWI input # Custom stage to copy the FWI input
copyInput = {nextStage, conf, ...}: #copyInput = {nextStage, conf, ...}:
let # let
input = bsc.garlic.apps.fwi; # input = bsc.garlic.apps.fwi;
in # in
stages.exec { # stages.exec {
inherit nextStage; # inherit nextStage;
env = '' # env = ''
cp -r ${input}/bin/InputModels . # cp -r ${input}/bin/InputModels .
chmod +w -R . # chmod +w -R .
''; # '';
argv = [ # argv = [
"${input}/etc/fwi/fwi_params.txt" # "${input}/etc/fwi/fwi_params.txt"
"${input}/etc/fwi/fwi_frequencies.txt" # "${input}/etc/fwi/fwi_frequencies.txt"
]; # ];
}; # };
apps = bsc.garlic.apps;
# FWI program # FWI program
program = {nextStage, conf, ...}: with conf; program = {nextStage, conf, ...}: apps.fwi.solver.override {
bsc.garlic.apps.fwi.override { inherit (conf) cc gitBranch;
inherit cc gitBranch; };
};
pipeline = stdexp.stdPipeline ++ [ copyInput program ]; pipeline = stdexp.stdPipeline ++ [ program ];
in in

View File

@ -97,6 +97,10 @@
test = callPackage ./lulesh/test.nix { }; test = callPackage ./lulesh/test.nix { };
}; };
fwi = {
test = callPackage ./fwi/test.nix { };
};
osu = rec { osu = rec {
latency = callPackage ./osu/latency.nix { }; latency = callPackage ./osu/latency.nix { };
latencyShm = latency.override { interNode = false; }; latencyShm = latency.override { interNode = false; };