fwi: refactor config generation into common.nix

This commit is contained in:
Rodrigo Arias 2021-04-12 15:01:25 +02:00
parent 9aa07993b2
commit 41665bc6fc
3 changed files with 29 additions and 35 deletions

View File

@ -7,17 +7,29 @@
with stdenv.lib; with stdenv.lib;
# Common definitions used by fwi experiments
rec { rec {
# We split these into a separate group so we can remove the blocksize branchesWithoutBlocksize = [
# later. "garlic/mpi+send+omp+fork"
forkJoinBranches = [ "garlic/mpi+send+omp+fork" ]; "garlic/mpi+send+seq"
];
# Returns true if the given config is in the forkJoinBranches list # Returns true if the given config is in the forkJoinBranches list
isForkJoin = c: any (e: c.gitBranch == e) forkJoinBranches; needsBlocksize = c: ! any (e: c.gitBranch == e) branchesWithoutBlocksize;
# Set the blocksize to null for the fork join branch # Set the blocksize to null for the fork join branch
fixBlocksize = c: if (isForkJoin c) then (c // { blocksize = null; }) else c; 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);
exec = {nextStage, conf, ...}: stages.exec { exec = {nextStage, conf, ...}: stages.exec {
inherit nextStage; inherit nextStage;
@ -35,7 +47,7 @@ rec {
argv = [ argv = [
"${conf.fwiInput}/fwi_params.txt" "${conf.fwiInput}/fwi_params.txt"
"${conf.fwiInput}/fwi_frequencies.txt" "${conf.fwiInput}/fwi_frequencies.txt"
] ++ optional (! isForkJoin 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

View File

@ -19,21 +19,9 @@ let
# Initial variable configuration # Initial variable configuration
varConf = { varConf = {
gitBranch = [ gitBranch = [ "garlic/tampi+isend+oss+task" ];
# "garlic/tampi+send+oss+task"
"garlic/tampi+isend+oss+task"
# "garlic/mpi+send+omp+task"
# "garlic/mpi+send+oss+task"
# "garlic/mpi+send+seq"
# "garlic/oss+task"
# "garlic/omp+task"
# "garlic/seq"
];
blocksize = range2 1 256; blocksize = range2 1 256;
n = [ {nx=100; nz=100; ny=8000; ntpn=2; nodes=1;} ]; n = [ {nx=100; nz=100; ny=8000; ntpn=2; nodes=1;} ];
}; };
machineConfig = targetMachine.config; machineConfig = targetMachine.config;
@ -74,14 +62,13 @@ let
}; };
# Compute the array of configurations
configs = stdexp.buildConfigs {
inherit varConf genConf;
};
common = callPackage ./common.nix {}; common = callPackage ./common.nix {};
inherit (common) fixBlocksize pipeline; inherit (common) getConfigs pipeline;
configs = getConfigs {
inherit varConf genConf;
};
in in

View File

@ -18,8 +18,6 @@ with garlicTools;
let let
common = callPackage ./common.nix {};
inherit (targetMachine) fs; inherit (targetMachine) fs;
# Initial variable configuration # Initial variable configuration
@ -81,17 +79,14 @@ let
tempDir = fs.local.temp; tempDir = fs.local.temp;
}; };
# Compute the array of configurations common = callPackage ./common.nix {};
allConfigs = stdexp.buildConfigs {
inherit (common) getConfigs pipeline;
configs = getConfigs {
inherit varConf genConf; inherit varConf genConf;
}; };
# The unique function ensures that we only run one config for the fork
# join branch, even if we have multiple blocksizes.
configs = unique (map fixBlocksize allConfigs);
inherit (common) fixBlocksize pipeline;
in in
stdexp.genExperiment { inherit configs pipeline; } stdexp.genExperiment { inherit configs pipeline; }