bscpkgs/garlic/exp/saiph/numcomm.nix

189 lines
5.0 KiB
Nix
Raw Normal View History

2020-09-21 17:30:24 +02:00
{
stdenv
, nixpkgs
, pkgs
, genApp
, genConfigs
, runWrappers
}:
with stdenv.lib;
let
# Set variable configuration for the experiment
varConfig = {
devMode = [ true ];
2020-09-22 14:26:01 +02:00
numComm = [ 1 ];
2020-09-21 17:30:24 +02:00
};
# Common configuration
common = {
# Compile time nbody config
gitBranch = "garlic/tampi+isend+oss+task+simd";
2020-09-21 17:30:24 +02:00
mpi = pkgs.bsc.impi;
# Resources
2020-09-21 19:23:17 +02:00
ntasksPerNode = "2";
2020-10-07 11:38:57 +02:00
nodes = "1";
2020-09-21 17:30:24 +02:00
# Stage configuration
enableSbatch = true;
2020-10-07 11:38:57 +02:00
enableControl = true;
2020-09-28 13:06:35 +02:00
enableExtrae = false;
2020-09-21 17:30:24 +02:00
enablePerf = false;
# MN4 path
nixPrefix = "/gpfs/projects/bsc15/nix";
};
# Compute the cartesian product of all configurations
configs = map (conf: conf // common) (genConfigs varConfig);
stageProgram = stage:
if stage ? programPath
then "${stage}${stage.programPath}" else "${stage}";
w = runWrappers;
2020-09-30 18:34:14 +02:00
sbatch = {stage, conf, ...}: with conf; w.sbatch (
# Allow a user to define a custom reservation for the job in MareNostrum4,
# by setting the garlic.sbatch.reservation attribute in the
# ~/.config/nixpkgs/config.nix file. If the attribute is not set, no
# reservation is used. The user reservation may be overwritten by the
# experiment, if the reservation is set like with nodes or ntasksPerNode.
optionalAttrs (pkgs.config ? garlic.sbatch.reservation) {
inherit (pkgs.config.garlic.sbatch) reservation;
} // {
program = stageProgram stage;
exclusive = true;
time = "02:00:00";
qos = "debug";
jobName = "saiph";
inherit nixPrefix nodes ntasksPerNode;
}
);
2020-09-21 17:30:24 +02:00
control = {stage, conf, ...}: with conf; w.control {
2020-10-07 11:38:57 +02:00
program = stageProgram stage;
loops = 100;
2020-09-21 17:30:24 +02:00
};
srun = {stage, conf, ...}: with conf; w.srun {
program = stageProgram stage;
srunOptions = "--cpu-bind=verbose,sockets";
inherit nixPrefix;
};
statspy = {stage, conf, ...}: with conf; w.statspy {
program = stageProgram stage;
};
perf = {stage, conf, ...}: with conf; w.perf {
program = stageProgram stage;
perfArgs = "sched record -a";
};
nixsetup = {stage, conf, ...}: with conf; w.nixsetup {
program = stageProgram stage;
2020-09-22 17:39:26 +02:00
nixsetup = "${nixPrefix}/bin/nix-setup";
2020-09-21 17:30:24 +02:00
};
2020-09-22 14:26:01 +02:00
extrae = {stage, conf, ...}:
let
# We set the mpi implementation to the one specified in the conf, so all
# packages in bsc will use that one.
customPkgs = genPkgs (self: super: {
bsc = super.bsc // { mpi = conf.mpi; };
});
extrae = customPkgs.bsc.extrae;
in
w.extrae {
program = stageProgram stage;
extrae = extrae;
traceLib = "nanosmpi"; # mpi -> libtracempi.so
configFile = ./extrae.xml;
};
2020-09-21 17:30:24 +02:00
bscOverlay = import ../../../overlay.nix;
genPkgs = newOverlay: nixpkgs {
overlays = [
bscOverlay
newOverlay
];
};
2020-09-22 17:39:26 +02:00
# Print the environment to ensure we don't get anything nasty
envRecord = {stage, conf, ...}: w.envRecord {
program = stageProgram stage;
};
broom = {stage, conf, ...}: w.broom {
program = stageProgram stage;
};
2020-09-21 17:30:24 +02:00
# We may be able to use overlays by invoking the fix function directly, but we
# have to get the definition of the bsc packages and the garlic ones as
# overlays.
2020-09-23 13:13:51 +02:00
argv = {stage, conf, ...}: with conf; w.argv {
program = stageProgram stage;
env = ''
2020-10-07 11:38:57 +02:00
export OMP_NUM_THREADS=24
2020-09-23 13:13:51 +02:00
export NANOS6_REPORT_PREFIX="#"
export I_MPI_THREAD_SPLIT=1
2020-09-28 13:07:07 +02:00
export ASAN_SYMBOLIZER_PATH=${pkgs.bsc.clangOmpss2Unwrapped}/bin/llvm-symbolizer
2020-09-23 13:13:51 +02:00
''
+ optionalString enableExtrae
''export NANOS6=extrae
export NANOS6_EXTRAE_AS_THREADS=0
'';
};
2020-09-21 17:30:24 +02:00
saiphFn = {stage, conf, ...}: with conf;
let
# We set the mpi implementation to the one specified in the conf, so all
# packages in bsc will use that one.
customPkgs = genPkgs (self: super: {
bsc = super.bsc // { mpi = conf.mpi; };
});
in
customPkgs.bsc.garlic.saiph.override {
inherit devMode numComm mpi gitBranch;
2020-09-21 17:30:24 +02:00
};
stages = with common; []
2020-09-22 17:39:26 +02:00
# Cleans ALL environment variables
++ [ broom ]
2020-09-21 17:30:24 +02:00
# Use sbatch to request resources first
++ optionals enableSbatch [ sbatch nixsetup ]
2020-09-21 17:30:24 +02:00
2020-09-22 17:39:26 +02:00
# Record the current env vars set by SLURM to verify we don't have something
# nasty (like sourcing .bashrc). Take a look at #26
++ [ envRecord ]
# Repeats the next stages N=30 times
++ optional enableControl control
2020-09-21 17:30:24 +02:00
# Executes srun to launch the program in the requested nodes, and
# immediately after enters the nix environment again, as slurmstepd launches
# the next stages from outside the namespace.
++ [ srun nixsetup ]
# Intrumentation with extrae
++ optional enableExtrae extrae
# Optionally profile the next stages with perf
++ optional enablePerf perf
2020-09-22 18:39:29 +02:00
# Execute the saiph example app
2020-09-23 13:13:51 +02:00
++ [ argv saiphFn ];
2020-09-21 17:30:24 +02:00
# List of actual programs to be executed
jobs = map (conf: w.stagen { inherit conf stages; }) configs;
in
# We simply run each program one after another
w.launch jobs