fwi: generate the input at runtime

This commit is contained in:
Rodrigo Arias 2021-04-12 17:46:07 +02:00
parent 419e7f95cc
commit 47b326c646
5 changed files with 61 additions and 33 deletions

View File

@ -40,41 +40,85 @@ rec {
ntasksPerNode = hw.cpusPerNode; ntasksPerNode = hw.cpusPerNode;
}; };
srun = {nextStage, conf, ...}:
let
fwiParams = bsc.apps.fwi.params.override {
inherit (conf) nx ny nz;
};
in
stdexp.stdStages.srun {
inherit nextStage conf;
# Now we add some commands to execute before calling srun. These will
# only run in one rank (the first in the list of allocated nodes)
preSrun = ''
export GARLIC_FWI_SRUNDIR=$(pwd)
export GARLIC_FWI_EXECDIR="${conf.tempDir}/out/$GARLIC_USER/$GARLIC_UNIT/$GARLIC_RUN"
mkdir -p "$GARLIC_FWI_EXECDIR"
export GARLIC_FWI_PARAMS="${fwiParams}/fwi_params.txt"
export GARLIC_FWI_FREQ="${fwiParams}/fwi_frequencies.txt"
# We cannot change the working directory of srun, so we use a
# subshell to ignore the cd
(
# Generate the input dataset
>&2 echo "generating the input dataset"
cd "$GARLIC_FWI_EXECDIR"
${fwiParams}/bin/ModelGenerator \
-m "$GARLIC_FWI_PARAMS" "$GARLIC_FWI_FREQ"
)
'';
postSrun = optionalString (conf.enableCTF) ''
# Save the traces
mv "$GARLIC_FWI_EXECDIR"/trace_* .
'' + ''
# Remove everything else
rm -rf "$GARLIC_FWI_EXECDIR"
'';
};
exec = {nextStage, conf, ...}: stages.exec { exec = {nextStage, conf, ...}: stages.exec {
inherit nextStage; inherit nextStage;
# FIXME: FWI should allow the I/O directory to be specified as a
# parameter
pre = '' pre = ''
CDIR=$(pwd) # Run fwi at the in a directory with fast local storage
EXECDIR="${conf.tempDir}/out/$GARLIC_USER/$GARLIC_UNIT/$GARLIC_RUN" cd "$GARLIC_FWI_EXECDIR"
mkdir -p "$EXECDIR"
cd "$EXECDIR" echo >&2 "Current dir: $(pwd)"
ln -fs ${conf.fwiInput}/InputModels InputModels || true echo >&2 "Using PARAMS=$GARLIC_FWI_PARAMS and FREQ=$GARLIC_FWI_FREQ"
'' + optionalString (conf.enableCTF) '' '' + optionalString (conf.enableCTF) ''
export NANOS6_CONFIG_OVERRIDE="version.instrument=ctf" export NANOS6_CONFIG_OVERRIDE="version.instrument=ctf"
''; '';
argv = [ argv = [
"${conf.fwiInput}/fwi_params.txt" ''"$GARLIC_FWI_PARAMS"''
"${conf.fwiInput}/fwi_frequencies.txt" ''"$GARLIC_FWI_FREQ"''
] ++ optional (needsBlocksize conf) conf.blocksize ++ [ ] ++ optional (needsBlocksize conf) conf.blocksize ++ [
"-1" # Fordward steps "-1" # Fordward steps
"-1" # Backward steps "-1" # Backward steps
conf.ioFreq # Write/read frequency conf.ioFreq # Write/read frequency
]; ];
post = ''
rm -rf Results || true
'' + optionalString (conf.enableCTF) ''
mv trace_* "$CDIR"
'';
}; };
apps = bsc.garlic.apps; apps = bsc.garlic.apps;
# FWI program # FWI program
program = {nextStage, conf, ...}: apps.fwi.solver.override { program = {nextStage, conf, ...}:
inherit (conf) gitBranch fwiInput; let
}; fwiParams = bsc.apps.fwi.params.override {
inherit (conf) nx ny nz;
};
in
apps.fwi.solver.override {
inherit (conf) gitBranch;
inherit fwiParams;
};
pipeline = stdexp.stdPipeline ++ [ exec program ]; pipeline = stdexp.stdPipelineOverride {
# Replace the stdandard srun stage with our own
overrides = { inherit srun; };
} ++ [ exec program ];
} }

View File

@ -37,10 +37,6 @@ let
inherit (c) gitBranch blocksize; inherit (c) gitBranch blocksize;
inherit (c.n) nx ny nz ntpn nodes; inherit (c.n) nx ny nz ntpn nodes;
fwiInput = bsc.apps.fwi.input.override {
inherit (c.n) nx ny nz;
};
# Other FWI parameters # Other FWI parameters
ioFreq = -1; ioFreq = -1;

View File

@ -60,10 +60,6 @@ let
inherit (c) gitBranch blocksize; inherit (c) gitBranch blocksize;
inherit (c.n) nx ny nz; inherit (c.n) nx ny nz;
fwiInput = bsc.apps.fwi.input.override {
inherit (c.n) nx ny nz;
};
# Repeat the execution of each unit several times # Repeat the execution of each unit several times
loops = 10; loops = 10;

View File

@ -59,10 +59,6 @@ let
inherit (c) gitBranch blocksize; inherit (c) gitBranch blocksize;
inherit (c.n) nx ny nz; inherit (c.n) nx ny nz;
fwiInput = bsc.apps.fwi.input.override {
inherit (c.n) nx ny nz;
};
# Other FWI parameters # Other FWI parameters
ioFreq = -1; ioFreq = -1;

View File

@ -54,10 +54,6 @@ let
inherit (c) gitBranch blocksize; inherit (c) gitBranch blocksize;
inherit (c.n) nx ny nz; inherit (c.n) nx ny nz;
fwiInput = bsc.apps.fwi.input.override {
inherit (c.n) nx ny nz;
};
# Other FWI parameters # Other FWI parameters
ioFreq = c.ioFreq; ioFreq = c.ioFreq;