bscpkgs/garlic/exp/nbody/bs.nix

179 lines
4.3 KiB
Nix
Raw Normal View History

2020-08-10 21:27:46 +08:00
{
2020-09-16 18:22:55 +08:00
stdenv
, nixpkgs
, pkgs
2020-08-10 21:27:46 +08:00
, genApp
, genConfigs
2020-09-02 23:07:09 +08:00
, runWrappers
2020-08-10 21:27:46 +08:00
}:
2020-09-02 23:07:09 +08:00
with stdenv.lib;
2020-08-10 21:27:46 +08:00
let
2020-09-02 23:07:09 +08:00
# Set variable configuration for the experiment
varConfig = {
2020-09-16 18:22:55 +08:00
cc = [ pkgs.bsc.icc ];
blocksize = [ 1024 ];
2020-08-12 20:00:04 +08:00
};
2020-09-02 23:07:09 +08:00
# Common configuration
common = {
# Compile time nbody config
gitBranch = "garlic/mpi+send";
2020-09-16 18:22:55 +08:00
mpi = pkgs.bsc.impi;
2020-09-02 23:07:09 +08:00
# nbody runtime options
2020-09-23 00:39:11 +08:00
particles = 1024*64;
timesteps = 10;
2020-09-02 23:07:09 +08:00
# Resources
ntasksPerNode = "48";
nodes = "1";
2020-09-02 23:07:09 +08:00
# Stage configuration
enableSbatch = true;
enableControl = true;
enableExtrae = false;
enablePerf = false;
# MN4 path
nixPrefix = "/gpfs/projects/bsc15/nix";
2020-08-10 21:27:46 +08:00
};
# Compute the cartesian product of all configurations
2020-09-02 23:07:09 +08:00
configs = map (conf: conf // common) (genConfigs varConfig);
2020-08-12 20:00:04 +08:00
2020-09-02 23:07:09 +08:00
stageProgram = stage:
if stage ? programPath
then "${stage}${stage.programPath}" else "${stage}";
w = runWrappers;
sbatch = {stage, conf, ...}: with conf; w.sbatch {
program = stageProgram stage;
exclusive = true;
2020-09-02 23:07:09 +08:00
time = "02:00:00";
qos = "debug";
jobName = "nbody-bs";
inherit nixPrefix nodes ntasksPerNode;
2020-08-12 20:00:04 +08:00
};
2020-09-02 23:07:09 +08:00
control = {stage, conf, ...}: with conf; w.control {
program = stageProgram stage;
};
srun = {stage, conf, ...}: with conf; w.srun {
program = stageProgram stage;
2020-09-02 16:44:13 +08:00
srunOptions = "--cpu-bind=verbose,rank";
2020-09-02 23:07:09 +08:00
inherit nixPrefix;
2020-08-18 00:50:18 +08:00
};
2020-09-02 23:07:09 +08:00
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-23 00:39:11 +08:00
nixsetup = "${nixPrefix}/bin/nix-setup";
2020-09-02 23:07:09 +08:00
};
2020-09-23 00:39:11 +08: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 = "mpi"; # mpi -> libtracempi.so
configFile = ./extrae.xml;
};
2020-09-02 23:07:09 +08:00
argv = {stage, conf, ...}: w.argv {
program = stageProgram stage;
env = ''
set -e
export I_MPI_THREAD_SPLIT=1
'';
argv = ''( -t ${toString conf.timesteps}
-p ${toString conf.particles} )'';
};
2020-09-21 20:34:08 +08:00
bscOverlay = import ../../../overlay.nix;
2020-09-16 18:22:55 +08:00
genPkgs = newOverlay: nixpkgs {
overlays = [
bscOverlay
newOverlay
];
2020-09-02 23:07:09 +08:00
};
2020-09-23 00:39:11 +08: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-16 18:22:55 +08: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.
nbodyFn = {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.nbody.override {
inherit cc blocksize mpi gitBranch;
};
2020-09-02 23:07:09 +08:00
stages = with common; []
2020-09-23 00:39:11 +08:00
# Cleans ALL environment variables
++ [ broom ]
2020-09-02 23:07:09 +08:00
# Use sbatch to request resources first
2020-09-23 00:39:11 +08:00
++ optionals enableSbatch [ sbatch nixsetup ]
# 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 ]
2020-09-02 23:07:09 +08:00
2020-09-23 00:39:11 +08:00
# Repeats the next stages N=30 times
++ optional enableControl control
2020-09-02 23:07:09 +08: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
# Execute the nbody app with the argv and env vars
++ [ argv nbodyFn ];
# List of actual programs to be executed
jobs = map (conf: w.stagen { inherit conf stages; }) configs;
2020-08-12 20:00:04 +08:00
2020-08-10 21:27:46 +08:00
in
2020-09-02 23:07:09 +08:00
# We simply run each program one after another
w.launch jobs