Skip to content

Commit

Permalink
Benchmarks: support all MPI libraries (#3412)
Browse files Browse the repository at this point in the history
Get the number of MPI threads from the cell system. Remove the "mpi" column from the benchmark results.
  • Loading branch information
kodiakhq[bot] authored Jan 15, 2020
2 parents 50b25e6 + 73ced32 commit b7ff4b9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
22 changes: 12 additions & 10 deletions maintainer/benchmarks/ferrofluid.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
args = parser.parse_args()

# process and check arguments
n_proc = int(os.environ.get("OMPI_COMM_WORLD_SIZE", 1))
n_part = n_proc * args.particles_per_core
measurement_steps = int(np.round(5e5 / args.particles_per_core, -2))
n_iterations = 20
assert args.volume_fraction > 0, "volume_fraction must be a positive number"
Expand All @@ -69,6 +67,10 @@

print(espressomd.features())

# System
#############################################################
system = espressomd.System(box_l=[1, 1, 1])

# Interaction parameters (Lennard-Jones)
#############################################################

Expand All @@ -79,13 +81,16 @@
# System parameters
#############################################################

n_proc = system.cell_system.get_state()['n_nodes']
n_part = n_proc * args.particles_per_core
# volume of N spheres with radius r: N * (4/3*pi*r^3)
box_l = (n_part * 4. / 3. * np.pi * (lj_sig / 2.)**3
/ args.volume_fraction)**(1. / 3.)

# System
#############################################################
system = espressomd.System(box_l=3 * (box_l,))
system.box_l = 3 * (box_l,)

# PRNG seeds
#############################################################
system.random_number_generator_state = list(range(
Expand Down Expand Up @@ -118,10 +123,7 @@
id=i,
pos=np.random.random(3) *
system.box_l,
rotation=(
1,
1,
1),
rotation=(1, 1, 1),
dipm=args.dipole_moment)

#############################################################
Expand Down Expand Up @@ -184,13 +186,13 @@

# write report
cmd = " ".join(x for x in sys.argv[1:] if not x.startswith("--output"))
report = ('"{script}","{arguments}",{cores},"{mpi}",{mean:.3e},'
report = ('"{script}","{arguments}",{cores},{mean:.3e},'
'{ci:.3e},{n},{dur:.1f}\n'.format(
script=os.path.basename(sys.argv[0]), arguments=cmd,
cores=n_proc, dur=main_tock - main_tick, n=measurement_steps,
mpi="OMPI_COMM_WORLD_SIZE" in os.environ, mean=avg, ci=ci))
mean=avg, ci=ci))
if not os.path.isfile(args.output):
report = ('"script","arguments","cores","MPI","mean","ci",'
report = ('"script","arguments","cores","mean","ci",'
'"nsteps","duration"\n' + report)
with open(args.output, "a") as f:
f.write(report)
Expand Down
18 changes: 12 additions & 6 deletions maintainer/benchmarks/lj.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
args = parser.parse_args()

# process and check arguments
n_proc = int(os.environ.get("OMPI_COMM_WORLD_SIZE", 1))
n_part = n_proc * args.particles_per_core
measurement_steps = int(np.round(5e6 / args.particles_per_core, -2))
n_iterations = 30
assert args.volume_fraction > 0, "volume_fraction must be a positive number"
Expand All @@ -67,6 +65,10 @@

print(espressomd.features())

# System
#############################################################
system = espressomd.System(box_l=[1, 1, 1])

# Interaction parameters (Lennard-Jones)
#############################################################

Expand All @@ -77,18 +79,22 @@
# System parameters
#############################################################

n_proc = system.cell_system.get_state()['n_nodes']
n_part = n_proc * args.particles_per_core
# volume of N spheres with radius r: N * (4/3*pi*r^3)
box_l = (n_part * 4. / 3. * np.pi * (lj_sig / 2.)**3
/ args.volume_fraction)**(1. / 3.)

# System
#############################################################
system = espressomd.System(box_l=3 * (box_l,))
system.box_l = 3 * (box_l,)

# PRNG seeds
#############################################################
system.random_number_generator_state = list(range(
n_proc * (system._get_PRNG_state_size() + 1)))
# np.random.seed(1)

# Integration parameters
#############################################################
system.time_step = 0.01
Expand Down Expand Up @@ -183,13 +189,13 @@

# write report
cmd = " ".join(x for x in sys.argv[1:] if not x.startswith("--output"))
report = ('"{script}","{arguments}",{cores},"{mpi}",{mean:.3e},'
report = ('"{script}","{arguments}",{cores},{mean:.3e},'
'{ci:.3e},{n},{dur:.1f}\n'.format(
script=os.path.basename(sys.argv[0]), arguments=cmd,
cores=n_proc, dur=main_tock - main_tick, n=measurement_steps,
mpi="OMPI_COMM_WORLD_SIZE" in os.environ, mean=avg, ci=ci))
mean=avg, ci=ci))
if not os.path.isfile(args.output):
report = ('"script","arguments","cores","MPI","mean","ci",'
report = ('"script","arguments","cores","mean","ci",'
'"nsteps","duration"\n' + report)
with open(args.output, "a") as f:
f.write(report)
Expand Down
17 changes: 11 additions & 6 deletions maintainer/benchmarks/p3m.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
args = parser.parse_args()

# process and check arguments
n_proc = int(os.environ.get("OMPI_COMM_WORLD_SIZE", 1))
n_part = n_proc * args.particles_per_core
measurement_steps = int(np.round(5e5 / args.particles_per_core, -1))
n_iterations = 30
assert args.prefactor > 0, "prefactor must be a positive number"
Expand All @@ -67,6 +65,10 @@

print(espressomd.features())

# System
#############################################################
system = espressomd.System(box_l=[1, 1, 1])

# Interaction parameters (Lennard-Jones, Coulomb)
#############################################################

Expand All @@ -83,15 +85,18 @@
# System parameters
#############################################################

n_proc = system.cell_system.get_state()['n_nodes']
n_part = n_proc * args.particles_per_core
# volume of N spheres with radius r: N * (4/3*pi*r^3)
lj_sig = (lj_sigmas["cation"] + lj_sigmas["anion"]) / 2
box_l = (n_part * 4. / 3. * np.pi * (lj_sig / 2.)**3
/ args.volume_fraction)**(1. / 3.)

# System
#############################################################
system = espressomd.System(box_l=3 * (box_l,))
system.box_l = 3 * (box_l,)
system.cell_system.set_domain_decomposition(use_verlet_lists=True)

# PRNG seeds
#############################################################
system.random_number_generator_state = list(range(
Expand Down Expand Up @@ -191,13 +196,13 @@

# write report
cmd = " ".join(x for x in sys.argv[1:] if not x.startswith("--output"))
report = ('"{script}","{arguments}",{cores},"{mpi}",{mean:.3e},'
report = ('"{script}","{arguments}",{cores},{mean:.3e},'
'{ci:.3e},{n},{dur:.1f}\n'.format(
script=os.path.basename(sys.argv[0]), arguments=cmd,
cores=n_proc, dur=main_tock - main_tick, n=measurement_steps,
mpi="OMPI_COMM_WORLD_SIZE" in os.environ, mean=avg, ci=ci))
mean=avg, ci=ci))
if not os.path.isfile(args.output):
report = ('"script","arguments","cores","MPI","mean","ci",'
report = ('"script","arguments","cores","mean","ci",'
'"nsteps","duration"\n' + report)
with open(args.output, "a") as f:
f.write(report)
Expand Down
4 changes: 2 additions & 2 deletions maintainer/benchmarks/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ for config in ${configs}; do
# add minimal features for the benchmarks to run
sed -i '1 i\#define ELECTROSTATICS\n#define LENNARD_JONES\n#define MASS\n' "${config}"
# remove checks
sed -ri "s/#define ADDITIONAL_CHECKS//" "${config}"
sed -ri "s/#define\s+ADDITIONAL_CHECKS//" "${config}"
done

cat > benchmarks.csv << EOF
"config","script","arguments","cores","MPI","mean","ci","nsteps","duration"
"config","script","arguments","cores","mean","ci","nsteps","duration"
EOF

# run benchmarks
Expand Down
2 changes: 1 addition & 1 deletion maintainer/benchmarks/suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ cleanup() {
# prepare output files
rm -f benchmarks.log
cat > benchmarks_suite.csv << EOF
"commit","config","script","arguments","cores","MPI","mean","ci","nsteps","duration"
"commit","config","script","arguments","cores","mean","ci","nsteps","duration"
EOF

# run benchmarks
Expand Down

0 comments on commit b7ff4b9

Please sign in to comment.