forked from rarias/bscpkgs
WIP stage redesign
This commit is contained in:
74
garlic/exp/nbody/common.nix
Normal file
74
garlic/exp/nbody/common.nix
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
stdenv
|
||||
, nixpkgs
|
||||
, pkgs
|
||||
, stages
|
||||
, machineConf
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
bsc = pkgs.bsc;
|
||||
w = runWrappers;
|
||||
in
|
||||
{
|
||||
/* Returns the path of the executable of a stage */
|
||||
stageProgram = stage:
|
||||
if stage ? programPath
|
||||
then "${stage}${stage.programPath}"
|
||||
else "${stage}";
|
||||
|
||||
/* Takes a list of units and builds an experiment, after executing the
|
||||
trebuchet and the isolate stages. Returns the trebuchet stage. */
|
||||
buildExperiment = {units, conf, ...}: stage.trebuchet {
|
||||
inherit (machineConf) nixPrefix;
|
||||
nextStage = stage.isolate {
|
||||
inherit (machineConf) nixPrefix;
|
||||
nextStage = stage.experiment {
|
||||
inherit units;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
sbatch = {nextStage, 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;
|
||||
} // {
|
||||
exclusive = true;
|
||||
time = "02:00:00";
|
||||
qos = "debug";
|
||||
jobName = "nbody-tampi";
|
||||
inherit nextStage nixPrefix nodes ntasksPerNode;
|
||||
}
|
||||
);
|
||||
|
||||
control = {nextStage, conf, ...}: stages.control {
|
||||
inherit (conf) loops;
|
||||
inherit nextStage;
|
||||
};
|
||||
|
||||
srun = {nextStage, conf, ...}: stages.srun {
|
||||
inherit (conf) nixPrefix cpuBind;
|
||||
inherit nextStage;
|
||||
};
|
||||
|
||||
isolate = {nextStage, conf, ...}: stages.isolate {
|
||||
clusterName = machineConf.name;
|
||||
inherit (conf) nixPrefix;
|
||||
inherit nextStage;
|
||||
};
|
||||
|
||||
stdStages = [
|
||||
sbatch
|
||||
isolate
|
||||
control
|
||||
srun
|
||||
isolate
|
||||
];
|
||||
}
|
||||
75
garlic/exp/nbody/test.nix
Normal file
75
garlic/exp/nbody/test.nix
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
stdenv
|
||||
, stdexp
|
||||
, pkgs
|
||||
, targetMachine
|
||||
, stages
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
bsc = pkgs.bsc;
|
||||
|
||||
# Configurations for each unit (using the cartesian product)
|
||||
confUnit = with bsc; {
|
||||
blocksize = [ 1024 2048 ];
|
||||
};
|
||||
|
||||
# Configuration for the complete experiment
|
||||
confExperiment = with bsc; {
|
||||
# nbody options
|
||||
particles = 1024 * 4;
|
||||
timesteps = 10;
|
||||
cc = icc;
|
||||
mpi = impi;
|
||||
gitBranch = "garlic/mpi+send";
|
||||
|
||||
# Repeat the execution of each unit 30 times
|
||||
loops = 30;
|
||||
|
||||
# Resources
|
||||
ntasksPerNode = 2;
|
||||
nodes = 1;
|
||||
cpuBind = "sockets,verbose";
|
||||
};
|
||||
|
||||
confMachine = targetMachine.config;
|
||||
|
||||
# Compute the array of configurations
|
||||
configs = stdexp.buildConfigs {
|
||||
var = confUnit;
|
||||
fixed = confMachine // confExperiment;
|
||||
};
|
||||
|
||||
exec = {nextStage, conf, ...}: with conf; stages.exec {
|
||||
inherit nextStage;
|
||||
argv = [ "-t" timesteps "-p" particles ];
|
||||
env = "";
|
||||
};
|
||||
|
||||
# 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.
|
||||
program = {nextStage, 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 = stdexp.genPkgs (self: super: {
|
||||
bsc = super.bsc // { mpi = conf.mpi; };
|
||||
});
|
||||
in
|
||||
customPkgs.garlic.nbody.override {
|
||||
inherit cc blocksize mpi gitBranch;
|
||||
};
|
||||
|
||||
# Generate the experimental units
|
||||
units = map (c: stages.unit {
|
||||
conf = c;
|
||||
stages = stdexp.stdStages ++ [ exec program ];
|
||||
}) configs;
|
||||
|
||||
in
|
||||
|
||||
elemAt units 0
|
||||
#buildExperiment units
|
||||
84
garlic/exp/stdexp.nix
Normal file
84
garlic/exp/stdexp.nix
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
stdenv
|
||||
, config
|
||||
, stages
|
||||
, targetMachine
|
||||
, garlicTools
|
||||
}:
|
||||
|
||||
with stdenv.lib;
|
||||
with garlicTools;
|
||||
|
||||
let
|
||||
machineConf = targetMachine.config;
|
||||
in
|
||||
rec {
|
||||
/* Takes a list of units and builds an experiment, after executing the
|
||||
trebuchet and the isolate stages. Returns the trebuchet stage. */
|
||||
buildExperiment = {units, conf, ...}: stage.trebuchet {
|
||||
inherit (machineConf) nixPrefix;
|
||||
nextStage = stage.isolate {
|
||||
inherit (machineConf) nixPrefix;
|
||||
nextStage = stage.experiment {
|
||||
inherit units;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/* Given an attrset of lists `var` and an attrset `fixed`, computes the
|
||||
cartesian product of all combinations of `var` and prepends `fixed`
|
||||
to each. */
|
||||
buildConfigs = {fixed, var}:
|
||||
map (c: fixed // c) (genConfigs var);
|
||||
|
||||
sbatch = {nextStage, conf, ...}: with conf; stages.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 (config ? garlic.sbatch.reservation) {
|
||||
inherit (config.garlic.sbatch) reservation;
|
||||
} // {
|
||||
exclusive = true;
|
||||
time = "02:00:00";
|
||||
qos = "debug";
|
||||
jobName = "nbody-tampi";
|
||||
inherit nextStage nixPrefix nodes ntasksPerNode;
|
||||
}
|
||||
);
|
||||
|
||||
control = {nextStage, conf, ...}: stages.control {
|
||||
inherit (conf) loops;
|
||||
inherit nextStage;
|
||||
};
|
||||
|
||||
srun = {nextStage, conf, ...}: stages.srun {
|
||||
inherit (conf) nixPrefix cpuBind;
|
||||
inherit nextStage;
|
||||
};
|
||||
|
||||
isolate = {nextStage, conf, ...}: stages.isolate {
|
||||
clusterName = machineConf.name;
|
||||
inherit (conf) nixPrefix;
|
||||
inherit nextStage;
|
||||
};
|
||||
|
||||
stdStages = [
|
||||
sbatch
|
||||
isolate
|
||||
control
|
||||
srun
|
||||
isolate
|
||||
];
|
||||
|
||||
# FIXME: Remove this hack and allow custom nixpkgs
|
||||
bscOverlay = import ../../overlay.nix;
|
||||
nixpkgs = import <nixpkgs>;
|
||||
genPkgs = newOverlay: nixpkgs {
|
||||
overlays = [
|
||||
bscOverlay
|
||||
newOverlay
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user