From d687770660ed17749809b9133d8c779b31e5e222 Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 1 Jun 2025 14:54:32 +0200 Subject: [PATCH] cleanup + creater.py --- lab10/jacobi/creator.py | 32 ++++++++++++++++++++++++++++++++ lab10/jacobi/do_all.sh | 3 ++- lab10/jacobi/slurm.sh | 8 -------- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 lab10/jacobi/creator.py delete mode 100644 lab10/jacobi/slurm.sh diff --git a/lab10/jacobi/creator.py b/lab10/jacobi/creator.py new file mode 100644 index 0000000..c8fe151 --- /dev/null +++ b/lab10/jacobi/creator.py @@ -0,0 +1,32 @@ +import math +import subprocess + +core_counts = [1, 2, 4, 6, 8, 12, 16, 18, 24, 32, 36, 48] +cores_per_node = 12 +max_nodes = 4 + +for y in core_counts: + x = math.ceil(y / cores_per_node) + if x > max_nodes: + print(f"Skipping {y} cores: requires more than {max_nodes} nodes.") + continue + + filename = f"slurm_{y}.sh" + script = f"""#!/bin/bash +#SBATCH --job-name=mpi_g5_{y} +#SBATCH --output=jacobi_{y}.txt +#SBATCH --nodes={x} +#SBATCH --ntasks={y} + +srun --mpi=pmix ./jacobi +""" + + with open(filename, "w") as f: + f.write(script) + + # Submit the job + result = subprocess.run(["sbatch", filename], capture_output=True, text=True) + if result.returncode == 0: + print(f"Submitted {filename}: {result.stdout.strip()}") + else: + print(f"Failed to submit {filename}: {result.stderr.strip()}") diff --git a/lab10/jacobi/do_all.sh b/lab10/jacobi/do_all.sh index 5ff82f6..633ade9 100755 --- a/lab10/jacobi/do_all.sh +++ b/lab10/jacobi/do_all.sh @@ -1,5 +1,6 @@ #!/bin/bash git pull make -sbatch slurm.sh +python3 creator.py +sleep 0.5 squeue diff --git a/lab10/jacobi/slurm.sh b/lab10/jacobi/slurm.sh deleted file mode 100644 index 936ea7f..0000000 --- a/lab10/jacobi/slurm.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -#SBATCH --job-name=G5_jacobi # Name des Jobs -#SBATCH --output=jacobi.txt # Output-Datei (%j = Job-ID) -#SBATCH --nodes=4 # Nutze z. B. 4 Nodes -#SBATCH --ntasks-per-node=12 - -# Programm starten -srun --mpi=pmix ./jacobi