69 lines
1.2 KiB
Nix
69 lines
1.2 KiB
Nix
|
{
|
||
|
stdenv
|
||
|
}:
|
||
|
|
||
|
{
|
||
|
app
|
||
|
, argv ? ""
|
||
|
, binary ? "/bin/run"
|
||
|
, ntasks ? null
|
||
|
, exclusive ? true # By default we run in exclusive mode
|
||
|
, workdir ? "."
|
||
|
, 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 = ''
|
||
|
cat > $out <<EOF
|
||
|
#!/bin/bash
|
||
|
#SBATCH --job-name="${name}"
|
||
|
''
|
||
|
+ sbatchOpt "ntasks" ntasks
|
||
|
+ sbatchOpt "ntasks" ntasks
|
||
|
+ sbatchOpt "workdir" workdir
|
||
|
+ sbatchOpt "output" output
|
||
|
+ sbatchOpt "error" error
|
||
|
+ sbatchEnable "exclusive" exclusive
|
||
|
+ sbatchOpt "time" time
|
||
|
+ sbatchOpt "qos" qos
|
||
|
+ optionalString (extra!=null) extra
|
||
|
+''
|
||
|
|
||
|
numactl -s
|
||
|
|
||
|
#!/bin/bash
|
||
|
exec ${app}${binary} ${argv}
|
||
|
done
|
||
|
EOF
|
||
|
|
||
|
chmod +x $out
|
||
|
'';
|
||
|
}
|