2020-07-31 18:47:33 +02:00
|
|
|
{
|
|
|
|
stdenv
|
2020-08-04 11:51:09 +02:00
|
|
|
, numactl
|
2020-07-31 18:47:33 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
{
|
|
|
|
app
|
2020-08-10 14:13:28 +02:00
|
|
|
, prefix ? ""
|
2020-07-31 18:47:33 +02:00
|
|
|
, argv ? ""
|
|
|
|
, binary ? "/bin/run"
|
|
|
|
, ntasks ? null
|
|
|
|
, exclusive ? true # By default we run in exclusive mode
|
2020-08-04 18:38:33 +02:00
|
|
|
, chdir ? "."
|
2020-07-31 18:47:33 +02:00
|
|
|
, qos ? null
|
|
|
|
, time ? null
|
|
|
|
, output ? "job_%j.out"
|
|
|
|
, error ? "job_%j.err"
|
|
|
|
, contiguous ? null
|
|
|
|
, extra ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
let
|
|
|
|
|
|
|
|
sbatchOpt = name: value: optionalString (value!=null)
|
|
|
|
"#SBATCH --${name}=${value}\n";
|
|
|
|
sbatchEnable = name: value: optionalString (value!=null)
|
|
|
|
"#SBATCH --${name}\n";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "${app.name}-job";
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
buildInputs = [ app ];
|
|
|
|
|
|
|
|
#SBATCH --tasks-per-node=48
|
|
|
|
#SBATCH --ntasks-per-socket=24
|
|
|
|
#SBATCH --cpus-per-task=1
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
2020-08-04 18:38:33 +02:00
|
|
|
mkdir -p $out
|
|
|
|
cat > $out/job <<EOF
|
2020-07-31 18:47:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#SBATCH --job-name="${name}"
|
|
|
|
''
|
|
|
|
+ sbatchOpt "ntasks" ntasks
|
2020-08-04 18:38:33 +02:00
|
|
|
+ sbatchOpt "chdir" chdir
|
2020-07-31 18:47:33 +02:00
|
|
|
+ sbatchOpt "output" output
|
|
|
|
+ sbatchOpt "error" error
|
|
|
|
+ sbatchEnable "exclusive" exclusive
|
|
|
|
+ sbatchOpt "time" time
|
|
|
|
+ sbatchOpt "qos" qos
|
|
|
|
+ optionalString (extra!=null) extra
|
2020-08-10 14:13:28 +02:00
|
|
|
+
|
|
|
|
''
|
|
|
|
srun ${prefix}${app}${binary} ${argv}
|
2020-07-31 18:47:33 +02:00
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
}
|