Provide argvWrapper

This commit is contained in:
Rodrigo Arias 2020-08-12 14:00:04 +02:00
parent 338736d257
commit df18435dfc
6 changed files with 122 additions and 42 deletions

25
bsc/garlic/argv.nix Normal file
View File

@ -0,0 +1,25 @@
{
stdenv
}:
{
app
, argv # bash array as string, example: argv=''(-f "file with spaces" -t 10)''
}:
stdenv.mkDerivation {
inherit argv;
name = "${app.name}-argv";
preferLocalBuild = true;
phases = [ "installPhase" ];
dontPatchShebangs = true;
installPhase = ''
mkdir -p $out/bin
cat > $out/bin/run <<EOF
#!/bin/sh
argv=${argv}
exec ${app}/bin/run \''${argv[@]}
EOF
chmod +x $out/bin/run
'';
}

View File

@ -23,10 +23,11 @@ let
gitBranch = "garlic/seq";
};
sbatch = callPackage ./sbatch.nix { };
launcher = callPackage ./launcher.nix { };
control = callPackage ./control.nix { };
nixsetup = callPackage ./nix-setup.nix { };
sbatchWrapper = callPackage ./sbatch.nix { };
launcherWrapper = callPackage ./launcher.nix { };
controlWrapper = callPackage ./control.nix { };
nixsetupWrapper = callPackage ./nix-setup.nix { };
argvWrapper = callPackage ./argv.nix { };
exp = {
nbody = {

View File

@ -3,39 +3,64 @@
, nbody
, genApp
, genConfigs
, sbatch
, launcher
, control
, nixsetup
# Wrappers
, launcherWrapper
, sbatchWrapper
, argvWrapper
, controlWrapper
, nixsetupWrapper
}:
let
# Set the configuration for the experiment
config = {
cc = [ bsc.icc ];
blocksize = [ 1024 2048 4096 ];
blocksize = [ 1024 2048 4096 8192 ];
};
extraConfig = {
particles = 16384;
timesteps = 10;
ntasks = 1;
nnodes = 1;
};
# Compute the cartesian product of all configurations
configList = genConfigs config;
# Generate each app variant via override
appList = genApp nbody configList;
allConfigs = genConfigs config;
# Job generator helper function
genJobs = map (app:
sbatch {
app = (nixsetup (control app));
nixPrefix = "/gpfs/projects/bsc15/nix";
exclusive = false;
ntasks = "1";
chdirPrefix = "/home/bsc15/bsc15557/bsc-nixpkgs/out";
}
);
configs = with builtins; filter (c: c.blocksize <= 4096) allConfigs;
# Generate one job for each app variant
jobList = genJobs appList;
sbatch = conf: app: sbatchWrapper {
app = app;
nixPrefix = "/gpfs/projects/bsc15/nix";
exclusive = false;
ntasks = "${toString conf.ntasks}";
chdirPrefix = "/home/bsc15/bsc15557/bsc-nixpkgs/out";
};
argv = conf: app:
with conf;
argvWrapper {
app = app;
argv = ''(-t ${toString timesteps} -p ${toString particles})'';
};
nbodyFn = conf:
with conf;
nbody.override { inherit cc blocksize; };
pipeline = conf:
sbatch conf (
nixsetupWrapper (
controlWrapper (
argv conf (
nbodyFn conf))));
# Ideally it should look like this:
#pipeline = sbatch nixsetup control argv nbodyFn;
jobs = map (conf: pipeline (conf // extraConfig)) configs;
# And execute them all
main = launcher jobList;
in
main
launcherWrapper jobs

View File

@ -2,7 +2,7 @@
stdenv
}:
apps:
apps: # Each app must be unique
stdenv.mkDerivation {
name = "launcher";
@ -16,7 +16,16 @@ stdenv.mkDerivation {
installPhase = ''
mkdir -p $out/apps
for j in $apps; do
ln -s $j $out/apps/$(basename $j)
target=$out/apps/$(basename $j)
if [ -e $target ]; then
echo "Duplicated app: $j"
echo
echo "Provided apps: "
printf "%s\n" $apps
echo
exit 1
fi
ln -s $j $target
done
mkdir -p $out/bin

29
bsc/garlic/nbody/argv.nix Normal file
View File

@ -0,0 +1,29 @@
{
stdenv
, particles
, timestamps
, program
, config
}:
stdenv.mkDerivation {
inherit program;
passthru = {
inherit config;
};
name = "${program.name}-argv";
preferLocalBuild = true;
phases = [ "installPhase" ];
dontPatchShebangs = true;
installPhase = ''
mkdir -p $out/bin
cat > $out/bin/run <<EOF
#!/bin/sh
exec ${program}/bin/run -p ${toString config.particles} -t ${toString config.timesteps}
EOF
chmod +x $out/bin/run
'';
}

View File

@ -4,16 +4,14 @@
, cflags ? null
, gitBranch
, blocksize ? 2048
, particles ? 16384
, timesteps ? 10
}:
stdenv.mkDerivation {
stdenv.mkDerivation rec {
name = "nbody";
src = builtins.fetchGit {
url = "ssh://git@bscpm02.bsc.es/rarias/nbody.git";
ref = gitBranch;
ref = "${gitBranch}";
};
buildInputs = [
@ -33,15 +31,8 @@ stdenv.mkDerivation {
installPhase = ''
mkdir -p $out/bin
cp nbody $out/bin/
cat > $out/bin/run <<EOF
#!/bin/sh
exec $out/bin/nbody -p ${toString particles} -t ${toString timesteps}
EOF
chmod +x $out/bin/run
cp nbody* $out/bin/${name}
ln -s $out/bin/${name} $out/bin/run
'';
}