diff --git a/devices/pc/default.nix b/devices/pc/default.nix index e11ebe29..f9f38df4 100644 --- a/devices/pc/default.nix +++ b/devices/pc/default.nix @@ -127,7 +127,13 @@ inputs: wireguardIp = "192.168.83.3"; }; gamemode = { enable = true; drmDevice = 0; }; - slurm = { enable = true; cpu = { cores = 16; threads = 2; }; memoryMB = 90112; gpus."4060" = 1; }; + slurm = + { + enable = true; + cpu = { cores = 16; threads = 2; mpiThreads = 2; openmpThreads = 4; }; + memoryMB = 90112; + gpus."4060" = 1; + }; xrdp = { enable = true; hostname = [ "pc.chn.moe" ]; }; }; bugs = [ "xmunet" "backlight" "amdpstate" "hibernate-mt7921e" "suspend-hibernate-no-platform" ]; diff --git a/devices/xmupc1/default.nix b/devices/xmupc1/default.nix index 3c2405c2..852c6e1b 100644 --- a/devices/xmupc1/default.nix +++ b/devices/xmupc1/default.nix @@ -76,7 +76,7 @@ inputs: slurm = { enable = true; - cpu = { cores = 16; threads = 2; }; + cpu = { cores = 16; threads = 2; mpiThreads = 3; openmpThreads = 4; }; memoryMB = 94208; gpus = { "2080_ti" = 1; "3090" = 1; "4090" = 1; }; }; diff --git a/devices/xmupc2/default.nix b/devices/xmupc2/default.nix index f056c28a..e1f42581 100644 --- a/devices/xmupc2/default.nix +++ b/devices/xmupc2/default.nix @@ -66,7 +66,7 @@ inputs: slurm = { enable = true; - cpu = { sockets = 2; cores = 22; threads = 2; }; + cpu = { sockets = 2; cores = 22; threads = 2; mpiThreads = 4; openmpThreads = 10; }; memoryMB = 253952; gpus = { "4090" = 1; "p5000" = 1; }; }; diff --git a/modules/services/slurm.nix b/modules/services/slurm.nix index f889acc1..9779c017 100644 --- a/modules/services/slurm.nix +++ b/modules/services/slurm.nix @@ -8,6 +8,8 @@ inputs: sockets = mkOption { type = types.ints.unsigned; default = 1; }; cores = mkOption { type = types.ints.unsigned; }; threads = mkOption { type = types.ints.unsigned; default = 1; }; + mpiThreads = mkOption { type = types.ints.unsigned; default = 1; }; + openmpThreads = mkOption { type = types.ints.unsigned; default = 1; }; }; memoryMB = mkOption { type = types.ints.unsigned; }; gpus = mkOption { type = types.attrsOf types.ints.unsigned; }; @@ -112,6 +114,30 @@ inputs: "slurm/db" = { owner = "slurm"; key = "mariadb/slurm"; }; }; }; - nixos.services.mariadb = { enable = true; instances.slurm = {}; }; + nixos = + { + packages._packages = [(inputs.pkgs.localPackages.sbatch-tui.overrideAttrs (prev: { src = + let device = inputs.pkgs.substituteAll + { + src = "${prev.src}/src/device.cpp.template"; + CpuMpiThreads = slurm.cpu.mpiThreads; + CpuOpenmpThreads = slurm.cpu.openmpThreads; + GpuIds = builtins.concatStringsSep ", " (builtins.map (gpu: ''"${gpu}"'') (builtins.attrNames slurm.gpus)); + }; + in inputs.pkgs.runCommand "src" {} + ''cp -r ${prev.src} $out; chmod +w -R $out; cp ${device} $out/src/device.cpp''; }))]; + user.sharedModules = [{ home.packages = + [ + (inputs.pkgs.writeShellScriptBin "sbatch" + '' + if [ "$#" -eq 0 ]; then + sbatch-tui + else + /run/current-system/sw/bin/sbatch "$@" + fi + '') + ];}]; + services.mariadb = { enable = true; instances.slurm = {}; }; + }; }; }