Introduction

GROMACS is a versatile package to perform molecular dynamics, i.e. simulate the Newtonian equations of motion for systems with hundreds to millions of particles and is a community-driven project. It is primarily designed for biochemical molecules like proteins, lipids and nucleic acids that have a lot of complicated bonded interactions, but since GROMACS is extremely fast at calculating the nonbonded interactions (that usually dominate simulations) many groups are also using it for research on non-biological systems, e.g. polymers and fluid dynamics.

Official website for GROMACS: https://www.gromacs.org/

 

Build GROMACS using Spack

Please refer to this link for getting started with spack using AMD Zen Software Studio.

    # Example for building GROMACS with AOCC and AOCL
$ spack install gromacs %aocc ^amdlibflame ^amdblis threads=openmp ^amdfftw ^openmpi fabrics=cma,ucx

Explanation of the command options:

Symbol Meaning
%aocc Build GROMACS with AOCC compiler.
^amdlibflame Use amdlibflame as the LAPACK implementation.
^amdblis threads=openmp Use amdblis as the BLAS implementation with OpenMP support
^amdfftw Use amdfftw as the FFTW implementation. 
^openmpi fabrics=cma,ucx Use OpenMPI as the MPI provider and use the CMA network for efficient intra-node communication, falling back to the UCX network fabric, if required.
Note: It is advised to specifically set the appropriate fabric for the host system if possible. Refer to Open MPI with AMD Zen Software Studio for more guidance.

Running GROMACS

The following example illustrates the running of GROMACS with the commonly used water_GMX50_bare benchmark data set.    

Running GROMACS is a two-step process:

  1. Generating the input file (.tpr)
  2. Running the generated input file (.tpr)

Run Script for AMD EPYC™ Processors

    #!/bin/bash
# Loading GROMACS built with AOCC
spack load gromacs %aocc

# Downloading and setting the standard benchmark "water_GMX50_bare"
wget http://ftp.gromacs.org/pub/benchmarks/water_GMX50_bare.tar.gz
tar -xvf water_GMX50_bare.tar.gz
cd water-cut1.0_GMX50_bare/3072/

# MPI and OMP settings
# MPI_RANKS=Number of cores available in the system
MPI_RANKS=$(nproc)
export OMP_NUM_THREADS=1
MPI_OPTS="-np $MPI_RANKS --bind-to core "

# Generating the .tpr input file using gmx_mpi
gmx_mpi grompp -f pme.mdp -c conf.gro -p topol.top -o water_pme.tpr

# Run Command
mpirun $MPI_OPTS gmx_mpi mdrun -notunepme -dlb yes -v -resethway -noconfout -nsteps 10000 -s water_pme.tpr

# -notunepme -dlb -resethway -noconfout -nsteps are mdrun parameters
# For more details on the mdrun parameters please refer https://manual.gromacs.org/documentation/current/user-guide/mdrun-performance.html

Note: The above build and run steps are tested with GROMACS-2024.3, AOCC-5.0.0, AOCL-5.0.0, and OpenMPI-5.0.5 on Red Hat Enterprise Linux release 8.9 (Ootpa) using Spack v0.23.0.dev0 (commit id : 2da812cbad ).

For technical support on the tools, benchmarks and applications that AMD offers on this page and related inquiries, reach out to us at toolchainsupport@amd.com