2021-04-12 14:41:26 +02:00
|
|
|
{
|
|
|
|
stdenv
|
2022-09-01 16:27:29 +02:00
|
|
|
, lib
|
2021-04-12 14:41:26 +02:00
|
|
|
, stdexp
|
|
|
|
, bsc
|
|
|
|
, stages
|
|
|
|
}:
|
|
|
|
|
2022-09-01 16:27:29 +02:00
|
|
|
with lib;
|
2021-04-12 14:41:26 +02:00
|
|
|
|
2021-04-12 15:01:25 +02:00
|
|
|
# Common definitions used by fwi experiments
|
2021-04-12 14:41:26 +02:00
|
|
|
rec {
|
|
|
|
|
2021-04-12 15:01:25 +02:00
|
|
|
branchesWithoutBlocksize = [
|
|
|
|
"garlic/mpi+send+omp+fork"
|
|
|
|
"garlic/mpi+send+seq"
|
|
|
|
];
|
2021-04-12 14:41:26 +02:00
|
|
|
|
|
|
|
# Returns true if the given config is in the forkJoinBranches list
|
2021-04-12 15:01:25 +02:00
|
|
|
needsBlocksize = c: ! any (e: c.gitBranch == e) branchesWithoutBlocksize;
|
2021-04-12 14:41:26 +02:00
|
|
|
|
|
|
|
# Set the blocksize to null for the fork join branch
|
2021-04-12 15:01:25 +02:00
|
|
|
fixBlocksize = c: if (needsBlocksize c) then c
|
|
|
|
else (c // { blocksize = null; });
|
|
|
|
|
|
|
|
# Generate the configs by filtering the unneded blocksizes
|
|
|
|
getConfigs = {varConf, genConf}:
|
|
|
|
let
|
|
|
|
allConfigs = stdexp.buildConfigs { inherit varConf genConf; };
|
|
|
|
in
|
|
|
|
# The unique function ensures that we only run one config for the fork
|
|
|
|
# join branch, even if we have multiple blocksizes.
|
|
|
|
unique (map fixBlocksize allConfigs);
|
2021-04-12 14:41:26 +02:00
|
|
|
|
2021-04-12 15:37:39 +02:00
|
|
|
getResources = {gitBranch, hw}:
|
|
|
|
if (gitBranch == "garlic/mpi+send+seq") then {
|
|
|
|
cpusPerTask = 1;
|
|
|
|
ntasksPerNode = hw.cpusPerNode;
|
2021-04-12 19:31:35 +02:00
|
|
|
} else {
|
|
|
|
cpusPerTask = hw.cpusPerSocket;
|
|
|
|
ntasksPerNode = hw.socketsPerNode;
|
2021-04-12 15:37:39 +02:00
|
|
|
};
|
|
|
|
|
2021-04-12 19:01:10 +02:00
|
|
|
exec = {nextStage, conf, ...}:
|
2021-04-12 17:46:07 +02:00
|
|
|
let
|
|
|
|
fwiParams = bsc.apps.fwi.params.override {
|
|
|
|
inherit (conf) nx ny nz;
|
|
|
|
};
|
2021-04-12 20:09:17 +02:00
|
|
|
|
|
|
|
ioFreq = if (conf.enableIO) then (conf.ioFreq or "-1") else "9999";
|
|
|
|
|
2021-04-12 19:01:10 +02:00
|
|
|
in stages.exec {
|
2021-04-12 14:41:26 +02:00
|
|
|
inherit nextStage;
|
|
|
|
|
2021-04-12 17:46:07 +02:00
|
|
|
# FIXME: FWI should allow the I/O directory to be specified as a
|
|
|
|
# parameter
|
2021-04-12 14:41:26 +02:00
|
|
|
pre = ''
|
2021-04-12 19:01:10 +02:00
|
|
|
FWI_SRUNDIR=$(pwd)
|
|
|
|
FWI_EXECDIR="${conf.tempDir}/out/$GARLIC_USER/$GARLIC_UNIT/$GARLIC_RUN"
|
|
|
|
FWI_PARAMS="${fwiParams}/fwi_params.txt"
|
|
|
|
FWI_FREQ="${fwiParams}/fwi_frequencies.txt"
|
|
|
|
|
|
|
|
# Run fwi in a directory with fast local storage
|
|
|
|
mkdir -p "$FWI_EXECDIR"
|
|
|
|
cd "$FWI_EXECDIR"
|
|
|
|
|
|
|
|
# Only generate the input if we have the CPU 0 (once per node)
|
|
|
|
if grep -o 'Cpus_allowed_list:[[:space:]]0' \
|
|
|
|
/proc/self/status > /dev/null;
|
|
|
|
then
|
|
|
|
FWI_CAPTAIN=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $FWI_CAPTAIN ]; then
|
|
|
|
>&2 echo "generating the input dataset"
|
|
|
|
${fwiParams}/bin/ModelGenerator -m "$FWI_PARAMS" "$FWI_FREQ"
|
|
|
|
fi
|
2021-04-12 17:46:07 +02:00
|
|
|
|
|
|
|
echo >&2 "Current dir: $(pwd)"
|
2021-04-12 19:01:10 +02:00
|
|
|
echo >&2 "Using PARAMS=$FWI_PARAMS and FREQ=$FWI_FREQ"
|
2021-04-12 14:41:26 +02:00
|
|
|
'' + optionalString (conf.enableCTF) ''
|
|
|
|
export NANOS6_CONFIG_OVERRIDE="version.instrument=ctf"
|
|
|
|
'';
|
|
|
|
|
|
|
|
argv = [
|
2021-04-12 19:01:10 +02:00
|
|
|
''"$FWI_PARAMS"''
|
|
|
|
''"$FWI_FREQ"''
|
2021-04-12 15:01:25 +02:00
|
|
|
] ++ optional (needsBlocksize conf) conf.blocksize ++ [
|
2021-04-12 14:41:26 +02:00
|
|
|
"-1" # Fordward steps
|
|
|
|
"-1" # Backward steps
|
2021-04-12 20:09:17 +02:00
|
|
|
ioFreq # Write/read frequency
|
2021-04-12 14:41:26 +02:00
|
|
|
];
|
2021-04-12 19:01:10 +02:00
|
|
|
|
|
|
|
post = ''
|
|
|
|
# Go back to the garlic out directory
|
|
|
|
cd "$FWI_SRUNDIR"
|
|
|
|
|
|
|
|
if [ $FWI_CAPTAIN ]; then
|
|
|
|
'' + optionalString (conf.enableCTF) ''
|
|
|
|
# FIXME: We should specify the path in the nanos6 config, so we
|
|
|
|
# can avoid the race condition while they are generating the
|
|
|
|
# traces
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
# Save the traces
|
|
|
|
mv "$FWI_EXECDIR"/trace_* .
|
|
|
|
'' + ''
|
|
|
|
rm -rf "$FWI_EXECDIR"
|
|
|
|
fi
|
|
|
|
'';
|
2021-04-12 14:41:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
apps = bsc.garlic.apps;
|
|
|
|
|
|
|
|
# FWI program
|
2021-04-12 17:46:07 +02:00
|
|
|
program = {nextStage, conf, ...}:
|
|
|
|
let
|
|
|
|
fwiParams = bsc.apps.fwi.params.override {
|
|
|
|
inherit (conf) nx ny nz;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
apps.fwi.solver.override {
|
|
|
|
inherit (conf) gitBranch;
|
|
|
|
inherit fwiParams;
|
|
|
|
};
|
2021-04-12 14:41:26 +02:00
|
|
|
|
2021-04-12 19:01:10 +02:00
|
|
|
pipeline = stdexp.stdPipeline ++ [ exec program ];
|
2021-04-12 14:41:26 +02:00
|
|
|
}
|