Provide argvWrapper
This commit is contained in:
parent
338736d257
commit
df18435dfc
25
bsc/garlic/argv.nix
Normal file
25
bsc/garlic/argv.nix
Normal 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
|
||||||
|
'';
|
||||||
|
}
|
@ -23,10 +23,11 @@ let
|
|||||||
gitBranch = "garlic/seq";
|
gitBranch = "garlic/seq";
|
||||||
};
|
};
|
||||||
|
|
||||||
sbatch = callPackage ./sbatch.nix { };
|
sbatchWrapper = callPackage ./sbatch.nix { };
|
||||||
launcher = callPackage ./launcher.nix { };
|
launcherWrapper = callPackage ./launcher.nix { };
|
||||||
control = callPackage ./control.nix { };
|
controlWrapper = callPackage ./control.nix { };
|
||||||
nixsetup = callPackage ./nix-setup.nix { };
|
nixsetupWrapper = callPackage ./nix-setup.nix { };
|
||||||
|
argvWrapper = callPackage ./argv.nix { };
|
||||||
|
|
||||||
exp = {
|
exp = {
|
||||||
nbody = {
|
nbody = {
|
||||||
|
@ -3,39 +3,64 @@
|
|||||||
, nbody
|
, nbody
|
||||||
, genApp
|
, genApp
|
||||||
, genConfigs
|
, genConfigs
|
||||||
, sbatch
|
|
||||||
, launcher
|
# Wrappers
|
||||||
, control
|
, launcherWrapper
|
||||||
, nixsetup
|
, sbatchWrapper
|
||||||
|
, argvWrapper
|
||||||
|
, controlWrapper
|
||||||
|
, nixsetupWrapper
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
# Set the configuration for the experiment
|
# Set the configuration for the experiment
|
||||||
config = {
|
config = {
|
||||||
cc = [ bsc.icc ];
|
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
|
# Compute the cartesian product of all configurations
|
||||||
configList = genConfigs config;
|
allConfigs = genConfigs config;
|
||||||
# Generate each app variant via override
|
|
||||||
appList = genApp nbody configList;
|
|
||||||
|
|
||||||
# Job generator helper function
|
configs = with builtins; filter (c: c.blocksize <= 4096) allConfigs;
|
||||||
genJobs = map (app:
|
|
||||||
sbatch {
|
sbatch = conf: app: sbatchWrapper {
|
||||||
app = (nixsetup (control app));
|
app = app;
|
||||||
nixPrefix = "/gpfs/projects/bsc15/nix";
|
nixPrefix = "/gpfs/projects/bsc15/nix";
|
||||||
exclusive = false;
|
exclusive = false;
|
||||||
ntasks = "1";
|
ntasks = "${toString conf.ntasks}";
|
||||||
chdirPrefix = "/home/bsc15/bsc15557/bsc-nixpkgs/out";
|
chdirPrefix = "/home/bsc15/bsc15557/bsc-nixpkgs/out";
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
|
||||||
# Generate one job for each app variant
|
argv = conf: app:
|
||||||
jobList = genJobs appList;
|
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
|
in
|
||||||
main
|
launcherWrapper jobs
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
stdenv
|
stdenv
|
||||||
}:
|
}:
|
||||||
|
|
||||||
apps:
|
apps: # Each app must be unique
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "launcher";
|
name = "launcher";
|
||||||
@ -16,7 +16,16 @@ stdenv.mkDerivation {
|
|||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/apps
|
mkdir -p $out/apps
|
||||||
for j in $apps; do
|
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
|
done
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
|
29
bsc/garlic/nbody/argv.nix
Normal file
29
bsc/garlic/nbody/argv.nix
Normal 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
|
||||||
|
'';
|
||||||
|
}
|
@ -4,16 +4,14 @@
|
|||||||
, cflags ? null
|
, cflags ? null
|
||||||
, gitBranch
|
, gitBranch
|
||||||
, blocksize ? 2048
|
, blocksize ? 2048
|
||||||
, particles ? 16384
|
|
||||||
, timesteps ? 10
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation rec {
|
||||||
name = "nbody";
|
name = "nbody";
|
||||||
|
|
||||||
src = builtins.fetchGit {
|
src = builtins.fetchGit {
|
||||||
url = "ssh://git@bscpm02.bsc.es/rarias/nbody.git";
|
url = "ssh://git@bscpm02.bsc.es/rarias/nbody.git";
|
||||||
ref = gitBranch;
|
ref = "${gitBranch}";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
@ -33,15 +31,8 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp nbody $out/bin/
|
cp nbody* $out/bin/${name}
|
||||||
|
ln -s $out/bin/${name} $out/bin/run
|
||||||
cat > $out/bin/run <<EOF
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
exec $out/bin/nbody -p ${toString particles} -t ${toString timesteps}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x $out/bin/run
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user