Run each experiment in a unique directory
This commit is contained in:
parent
8db4ef2594
commit
ef1aeb2cfa
@ -24,7 +24,7 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
sbatch = callPackage ./sbatch.nix { };
|
sbatch = callPackage ./sbatch.nix { };
|
||||||
sbatchLauncher = callPackage ./sbatch-launcher.nix { };
|
launcher = callPackage ./launcher.nix { };
|
||||||
|
|
||||||
exp = {
|
exp = {
|
||||||
nbody = {
|
nbody = {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
, genApp
|
, genApp
|
||||||
, genConfigs
|
, genConfigs
|
||||||
, sbatch
|
, sbatch
|
||||||
, sbatchLauncher
|
, launcher
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -23,16 +23,17 @@ let
|
|||||||
genJobs = map (app:
|
genJobs = map (app:
|
||||||
sbatch {
|
sbatch {
|
||||||
app = app;
|
app = app;
|
||||||
prefix = "/gpfs/projects/bsc15/nix";
|
nixPrefix = "/gpfs/projects/bsc15/nix";
|
||||||
exclusive = false;
|
exclusive = false;
|
||||||
ntasks = "1";
|
ntasks = "1";
|
||||||
|
chdirPrefix = "/home/bsc15/bsc15557/bsc-nixpkgs/out";
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
# Generate one job for each app variant
|
# Generate one job for each app variant
|
||||||
jobList = genJobs appList;
|
jobList = genJobs appList;
|
||||||
|
|
||||||
# And merge all jobs in a script to lauch them all with sbatch
|
# And execute them all
|
||||||
launcher = sbatchLauncher jobList;
|
main = launcher jobList;
|
||||||
in
|
in
|
||||||
launcher
|
main
|
||||||
|
@ -2,29 +2,29 @@
|
|||||||
stdenv
|
stdenv
|
||||||
}:
|
}:
|
||||||
|
|
||||||
jobs:
|
apps:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "launcher";
|
name = "launcher";
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
|
|
||||||
buildInputs = [] ++ jobs;
|
buildInputs = [] ++ apps;
|
||||||
jobs = jobs;
|
apps = apps;
|
||||||
phases = [ "installPhase" ];
|
phases = [ "installPhase" ];
|
||||||
|
dontPatchShebangs = true;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/jobs
|
mkdir -p $out/apps
|
||||||
for j in $jobs; do
|
for j in $apps; do
|
||||||
ln -s $j/job $out/jobs/$(basename $j)
|
ln -s $j $out/apps/$(basename $j)
|
||||||
done
|
done
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cat > $out/bin/run <<EOF
|
cat > $out/bin/run <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
for j in $out/jobs/*; do
|
for j in $out/apps/*; do
|
||||||
echo "sbatch \$j"
|
\$j/bin/run
|
||||||
sbatch \$j
|
|
||||||
done
|
done
|
||||||
EOF
|
EOF
|
||||||
|
|
@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
app
|
app
|
||||||
, prefix ? ""
|
, chdirPrefix
|
||||||
|
, nixPrefix ? ""
|
||||||
, argv ? ""
|
, argv ? ""
|
||||||
, binary ? "/bin/run"
|
, binary ? "/bin/run"
|
||||||
, ntasks ? null
|
, ntasks ? null
|
||||||
, exclusive ? true # By default we run in exclusive mode
|
, exclusive ? true # By default we run in exclusive mode
|
||||||
, chdir ? "."
|
|
||||||
, qos ? null
|
, qos ? null
|
||||||
, time ? null
|
, time ? null
|
||||||
, output ? "job_%j.out"
|
, output ? "job_%j.out"
|
||||||
@ -41,15 +41,16 @@ stdenv.mkDerivation rec {
|
|||||||
#SBATCH --ntasks-per-socket=24
|
#SBATCH --ntasks-per-socket=24
|
||||||
#SBATCH --cpus-per-task=1
|
#SBATCH --cpus-per-task=1
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
|
dontPatchShebangs = true;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cat > $out/job <<EOF
|
cat > $out/job <<EOF
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
#SBATCH --job-name="${name}"
|
#SBATCH --job-name="${name}"
|
||||||
''
|
''
|
||||||
+ sbatchOpt "ntasks" ntasks
|
+ sbatchOpt "ntasks" ntasks
|
||||||
+ sbatchOpt "chdir" chdir
|
+ sbatchOpt "chdir" "${chdirPrefix}/$(basename $out)"
|
||||||
+ sbatchOpt "output" output
|
+ sbatchOpt "output" output
|
||||||
+ sbatchOpt "error" error
|
+ sbatchOpt "error" error
|
||||||
+ sbatchEnable "exclusive" exclusive
|
+ sbatchEnable "exclusive" exclusive
|
||||||
@ -58,7 +59,20 @@ stdenv.mkDerivation rec {
|
|||||||
+ optionalString (extra!=null) extra
|
+ optionalString (extra!=null) extra
|
||||||
+
|
+
|
||||||
''
|
''
|
||||||
srun ${prefix}${app}${binary} ${argv}
|
srun ${nixPrefix}${app}${binary} ${argv}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cat > $out/bin/run <<EOF
|
||||||
|
#!/bin/sh
|
||||||
|
if [ -e "${chdirPrefix}/$(basename $out)" ]; then
|
||||||
|
>&2 echo "Execution aborted: '${chdirPrefix}/$(basename $out)' already exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mkdir -p "${chdirPrefix}/$(basename $out)"
|
||||||
|
echo sbatch ${nixPrefix}$out/job
|
||||||
|
sbatch ${nixPrefix}$out/job
|
||||||
|
EOF
|
||||||
|
chmod +x $out/bin/run
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user