From dd6a88406fcb2dd73ad44dfea2cb7b616223d11d Mon Sep 17 00:00:00 2001 From: Michele Ceriotti Date: Thu, 23 Nov 2023 20:28:12 -0800 Subject: [PATCH] Documentation of the profiling examples --- examples/profiling/README.md | 20 ++++++ examples/profiling/classical_md_gas/input.xml | 2 +- examples/profiling/remd_scpimd_gas/init.xyz | 10 +++ examples/profiling/remd_scpimd_gas/input.xml | 67 +++++++++++++++++++ examples/profiling/remd_scpimd_noff/input.xml | 4 +- examples/profiling/run_profiling.sh | 51 ++++++++++++++ 6 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 examples/profiling/README.md create mode 100644 examples/profiling/remd_scpimd_gas/init.xyz create mode 100644 examples/profiling/remd_scpimd_gas/input.xml mode change 100755 => 100644 examples/profiling/remd_scpimd_noff/input.xml create mode 100755 examples/profiling/run_profiling.sh diff --git a/examples/profiling/README.md b/examples/profiling/README.md new file mode 100644 index 000000000..05405e479 --- /dev/null +++ b/examples/profiling/README.md @@ -0,0 +1,20 @@ +Standardized profiling setups for i-PI +====================================== + +This folder contains a few inputs designed to stress-test the i-PI implementation, and determine internal bottlenecks. +To emphasize the overhead associated with the Python implementation and the socket communication, these examples +use dummy drivers that do not compute actual forces, or skip altogether the force evaluation. + +The inputs provided are for very small systems with 8 atoms (so the focus is on the constant overhead of the simulation) +but it's possible to perform runs with an arbitrary number of atoms using `run_profiling.sh natoms`. +The -p option activates wall-clock-time profiling using `yappi`. + +Examples include: + +`classical_md_gas` runs a simple NVE dynamics using an ideal-gas driver + +`classical_md_noff` runs a simple NVE dynamics. sets force weights to zero so there is no forcefield evaluation + +`remd_scpimd_gas` runs a super-duper calculation with replica exchange, constant-pressure NpT ensemble and Suzuki-Chin high-order path integrals + +`remd_scpimd_noff` as above, but without forcefield diff --git a/examples/profiling/classical_md_gas/input.xml b/examples/profiling/classical_md_gas/input.xml index b16572684..d710dd589 100644 --- a/examples/profiling/classical_md_gas/input.xml +++ b/examples/profiling/classical_md_gas/input.xml @@ -1,4 +1,4 @@ - + 1.00000000e-04
gas
diff --git a/examples/profiling/remd_scpimd_gas/init.xyz b/examples/profiling/remd_scpimd_gas/init.xyz new file mode 100644 index 000000000..f2f3870f8 --- /dev/null +++ b/examples/profiling/remd_scpimd_gas/init.xyz @@ -0,0 +1,10 @@ +8 +# CELL(abcABC): 50.0 50.0 50.0 90.00000 90.00000 90.00000 +H 0 0 0 +H 0 0 1 +H 0 0 2 +H 0 0 3 +H 0 0 4 +H 0 0 5 +H 0 0 6 +H 0 0 7 diff --git a/examples/profiling/remd_scpimd_gas/input.xml b/examples/profiling/remd_scpimd_gas/input.xml new file mode 100644 index 000000000..2fb7345c7 --- /dev/null +++ b/examples/profiling/remd_scpimd_gas/input.xml @@ -0,0 +1,67 @@ + + + 1.00000000e-04 +
gas
+ False +
+ + {eps: 0.0, sigma: 1.0} + + 2000 + + positions + [ step, time, conserved, temperature, kinetic_md, potential, pressure_md, volume ] + + + 18885 + + + [ PREFIX, FILENAME, TEMPERATURE, PRESSURE ] + [ REF00, init.xyz, 300, 1 ] + [ REF01, init.xyz, 310, 1 ] + [ REF02, init.xyz, 320, 1 ] + [ REF10, init.xyz, 300, 10 ] + [ REF11, init.xyz, 310, 10 ] + [ REF12, init.xyz, 320, 10 ] + + + + + 2 + + +
diff --git a/examples/profiling/remd_scpimd_noff/input.xml b/examples/profiling/remd_scpimd_noff/input.xml old mode 100755 new mode 100644 index 31c8b09b9..c824bd96e --- a/examples/profiling/remd_scpimd_noff/input.xml +++ b/examples/profiling/remd_scpimd_noff/input.xml @@ -1,4 +1,4 @@ - + {eps: 0.0, sigma: 1.0} @@ -25,6 +25,8 @@ FILENAME + [10.0, 0, 0, 0, 10.0, 0, 0, 0, 10.0] + [1.0] TEMPERATURE diff --git a/examples/profiling/run_profiling.sh b/examples/profiling/run_profiling.sh new file mode 100755 index 000000000..a65faad12 --- /dev/null +++ b/examples/profiling/run_profiling.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# usage: run_profile.sh [-p] natoms +# run a mock simulation using an natoms box, -p activates yappi profiling + +# Default value for natoms +natoms=8 +# Default profiler options +profiler_options="" + +# Process command-line arguments +while getopts ":p" opt; do + case $opt in + p) + profiler_flag=true + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + ;; + esac +done +shift $((OPTIND-1)) + +# Set natoms if provided as an argument +if [ $# -gt 0 ]; then + natoms=$1 +fi + +# Set profiler options if -p flag was used +if [ "$profiler_flag" = true ]; then + profiler_options="-p --profiler-clock=wall --profiler-output=test-$natoms" +fi + +# Create test.xyz file +echo $natoms > test-$natoms.xyz +echo "# dummy input structure" >> test-$natoms.xyz +for (( i=0; i> test-$natoms.xyz +done + +# Replace init.xyz with test.xyz in input.xml and save as test.xml +sed 's/init\.xyz/test-'$natoms'\.xyz/g' input.xml > test-$natoms.xml + +# Run i-pi and i-pi-driver in the background +time i-pi test-$natoms.xml $profiler_options &> test-$natoms.log & +sleep 1 +i-pi-driver -m gas -u -a gas & + +# Wait for all background processes to finish +wait +