cleanup + creater.py
This commit is contained in:
32
lab10/jacobi/creator.py
Normal file
32
lab10/jacobi/creator.py
Normal file
@@ -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()}")
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
git pull
|
||||
make
|
||||
sbatch slurm.sh
|
||||
python3 creator.py
|
||||
sleep 0.5
|
||||
squeue
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user