From 73ced32df018267f07c34def284b926f632c49a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= Date: Mon, 13 Jan 2020 09:44:11 +0100 Subject: [PATCH] Support all MPI libraries The original implementation only worked for Open MPI. --- maintainer/benchmarks/ferrofluid.py | 22 ++++++++++++---------- maintainer/benchmarks/lj.py | 18 ++++++++++++------ maintainer/benchmarks/p3m.py | 17 +++++++++++------ maintainer/benchmarks/runner.sh | 4 ++-- maintainer/benchmarks/suite.sh | 2 +- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/maintainer/benchmarks/ferrofluid.py b/maintainer/benchmarks/ferrofluid.py index c5ee2669099..3c6a2af8c39 100644 --- a/maintainer/benchmarks/ferrofluid.py +++ b/maintainer/benchmarks/ferrofluid.py @@ -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" @@ -69,6 +67,10 @@ print(espressomd.features()) +# System +############################################################# +system = espressomd.System(box_l=[1, 1, 1]) + # Interaction parameters (Lennard-Jones) ############################################################# @@ -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( @@ -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) ############################################################# @@ -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) diff --git a/maintainer/benchmarks/lj.py b/maintainer/benchmarks/lj.py index 6757d3a5298..8d38dc95f30 100644 --- a/maintainer/benchmarks/lj.py +++ b/maintainer/benchmarks/lj.py @@ -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" @@ -67,6 +65,10 @@ print(espressomd.features()) +# System +############################################################# +system = espressomd.System(box_l=[1, 1, 1]) + # Interaction parameters (Lennard-Jones) ############################################################# @@ -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 @@ -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) diff --git a/maintainer/benchmarks/p3m.py b/maintainer/benchmarks/p3m.py index ca138b34702..a981c28a9c8 100644 --- a/maintainer/benchmarks/p3m.py +++ b/maintainer/benchmarks/p3m.py @@ -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" @@ -67,6 +65,10 @@ print(espressomd.features()) +# System +############################################################# +system = espressomd.System(box_l=[1, 1, 1]) + # Interaction parameters (Lennard-Jones, Coulomb) ############################################################# @@ -83,6 +85,8 @@ # 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 @@ -90,8 +94,9 @@ # 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( @@ -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) diff --git a/maintainer/benchmarks/runner.sh b/maintainer/benchmarks/runner.sh index d27ba956488..3824c9426fc 100644 --- a/maintainer/benchmarks/runner.sh +++ b/maintainer/benchmarks/runner.sh @@ -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 diff --git a/maintainer/benchmarks/suite.sh b/maintainer/benchmarks/suite.sh index ef9da8eff4a..b419742773a 100644 --- a/maintainer/benchmarks/suite.sh +++ b/maintainer/benchmarks/suite.sh @@ -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