Skip to content

Commit

Permalink
use sbatch
Browse files Browse the repository at this point in the history
  • Loading branch information
prudhomm committed Jul 5, 2024
1 parent f376d64 commit 53b2e3e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
4 changes: 2 additions & 2 deletions notebooks/python/lorenz_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

if MPI.COMM_WORLD.Get_rank() == 0 :
# Print the execution time
print(f"Execution Time: {parareal_time} seconds")
print(f"np={MPI.COMM_WORLD.Get_size()},coarse solver={G_solver_name},fine solver={F_solver_name}, Execution Time: {parareal_time} seconds")

# Save the time to a file
with open("execution_times.txt", "a") as f:
with open(f"execution-times-{MPI.COMM_WORLD.Get_size()}-{G_solver_name}-{F_solver_name}.txt", "a") as f:
f.write(f"{MPI.COMM_WORLD.Get_size()},{G_solver_name},{F_solver_name},{parareal_time}\n")
38 changes: 35 additions & 3 deletions notebooks/python/time.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,44 @@ rm -f execution_times.txt
solvers=("explicit_euler" "implicit_euler" "explicit_rk2" "implicit_rk2" "explicit_rk4" "implicit_rk4")

# Iterate over the number of processes
for np in 1 2 4 8 16 32; do
for np in 1 2 4 8 16 32 64 128; do
# Iterate over all combinations of solvers
for G_solver in "${solvers[@]}"; do
for F_solver in "${solvers[@]}"; do
# Run the Python script with the specified number of processes and solvers
mpiexec -n $np python lorenz_parallel.py $G_solver $F_solver

cat > parareal-$G_solver-$F_solver-$np.job <<EOF
#!/bin/bash
#SBATCH -J parareal # name of the job
#SBATCH -N 1 # number of nodes
#SBATCH --ntasks-per-node=$np # number of MPI processes
#SBATCH --exclusive
#SBATCH -t 0:10:00
#SBATCH --threads-per-core=1 # no hyperthreading
#SBATCH --output=run-parareal-$np-$G_solver-$F_solver.out
#SBATCH --error=run-parareal-$np-$G_solver-$F_solver.err
export OMP_NUM_THREADS=1
module load hpcx
mpiexec -bind-to core python lorenz_parallel.py $G_solver $F_solver
EOF

# Submit the job
sbatch parareal-$G_solver-$F_solver-$np.job

# Wait for the job to finish
while [ ! -f execution_times.txt ]; do
sleep 1
done

# Append the execution times to the file
echo "np=$np, G_solver=$G_solver, F_solver=$F_solver" >> execution_times.txt
cat execution_times.txt >> execution_times.txt

# Remove the file
rm -f execution_times.txt
done
done
done

0 comments on commit 53b2e3e

Please sign in to comment.