Skip to content

Commit

Permalink
added minbench for allreduce
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-maillou committed Aug 28, 2024
1 parent 888c1db commit c3c1788
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bench/abg_minibench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import numpy as np
from mpi4py import MPI
import time

comm_rank = MPI.COMM_WORLD.Get_rank()
comm_size = MPI.COMM_WORLD.Get_size()


if __name__ == "__main__":
# abg of all reduce
b_sizes = [256, 512, 1024]
n_iterations = 100

timings = np.zeros((len(b_sizes), n_iterations))

print(f"Bench Allreduce for P={comm_size}")
for b_i in b_sizes:
b_init = np.random.rand(b_i)
for i in range(n_iterations):
b = b_init.copy()

tic = time.perf_counter()
MPI.COMM_WORLD.Allreduce(
MPI.IN_PLACE,
b,
op=MPI.SUM,
)
toc = time.perf_counter()

timings[b_i, i] = toc - tic

if comm_rank == 0:
print(f" b_size: {b_i}")
print(f" mean: {np.mean(timings[b_i])}")
print(f" std: {np.std(timings[b_i])}")

np.save(f"abg_allreduce_timings_{comm_size}.npy", timings)
10 changes: 10 additions & 0 deletions bench/slurm_abg_minibench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

#SBATCH --job-name=serinv_generate_dataset
#SBATCH --nodes=1
#SBATCH --gres=gpu:a40:2
#SBATCH --time=00:05:00
#SBATCH --output=%x.%j.out
#SBATCH --error=%x.%j.err

srun python abg_minibench.py

0 comments on commit c3c1788

Please sign in to comment.