How to build NAMD with Arm Compiler for HPC.


NAMD is a parallel molecular dynamics code designed for high-performance simulation of large biomolecular systems. Leveraging the Charm++ parallel programming framework, NAMD scales to hundreds of cores for typical simulations and beyond 500,000 cores for the largest simulations.

Charm++ is a machine independent parallel programming system. Programs written using this system run unchanged on MIMD machines with or without a shared memory. It provides high-level mechanisms and strategies to facilitate the task of developing even highly complex parallel applications.

For more information on Charm++ or NAMD, visit the Charm++ or NAMD webpages, respectively.

Version information

These instructions focus on building NAMD for a single node, multicore platform.

For the purposes of this build, the following components are used:

NAMD Version 2.12
Charm++ Version 6.8.0
Arm Performance Libraries
Version 18.2
Arm Compiler for HPC
Version 18.2
Operating System
Ubuntu 16.04
Hardware Cavium ThunderX2


The NAMD build instructions are dependent on Charm++. Ensure, Charm++ is built and installed on your system.

Note: Instructions to build and install Charm++ are provided in this tutorial.

Setup directories

Create a new directory called NAMD and change into it:

mkdir ~/NAMD
cd ~/NAMD

Create a new build and install directories, using:

mkdir build
mkdir install

Setup the variables BUILD_DIR and INSTALL_DIR, using:


Compiler configuration

Ensure that your paths are set up appropriately for Arm Compiler for HPC, for example:

export PATH=/path/to/ArmCompiler/bin:$PATH
export LD_LIBRARY_PATH=/path/to/ArmCompiler/lib:$LD_LIBRARY_PATH

To configure your installation of Arm Compiler for HPC, use:

export CC=armclang
export CXX=armclang++
export FC=armflang

(Optional) Set tuning flags:

TUNE="-march=armv8.1-a -mcpu=native -ffp-contract=fast -fsimdmath"

(Optional) Disable some compiler warnings:

WARN="-Wno-parentheses-equality -Wno-writable-strings -Wno-return-type -Wno-logical-op-parentheses -Wno-writable-strings -Wno-deprecated-register "

Download and unpack Charm

Change into your build directory:


Download and unpack the source files for Charm++, using:

tar -jxf charm-6.8.0.tar.bz2

Build and install Charm with Arm Compiler for HPC

  1. Change into the charm-6.8.0 directory, using:

    cd charm-6.8.0
  2. Generate an armclang configuration for the required architecture based on the existing one in src/arch/, for example src/arch/multicore-linux64, using:


    cp -R src/arch/multicore-linux64 src/arch/$CHARMARCH

    sed -i "s|^CMK_CPP_CHARM=.*|CMK_CPP_CHARM='cpp -P'|g" $FILE
    sed -i "s|^CMK_NATIVE_CC=.*|CMK_NATIVE_CC='$CC '|g" $FILE
    sed -i "s|^CMK_NATIVE_CXX=.*|CMK_NATIVE_CXX='$CXX '|g" $FILE
    sed -i "s|^CMK_NATIVE_LD=.*|CMK_NATIVE_LD='$CC '|g" $FILE
    sed -i "s|^CMK_NATIVE_LDXX=.*|CMK_NATIVE_LDXX='$CXX '|g" $FILE
    sed -i "s|^CMK_QT=.*|CMK_QT='generic64-light '|g" $FILE
    sed -i "s|^CMK_CF77=.*|CMK_CF77='$FC '|g" $FILE
    sed -i "s|^CMK_CF90=.*|CMK_CF90='$FC '|g" $FILE
    sed -i "s|^CMK_CF90_FIXED=.*|CMK_CF90_FIXED='$FC -Mfixed '|g" $FILE

    sed -i "/#endif/i #define CMK_THREADS_USE_CONTEXT                            1" ${}.h
    sed -i "/#endif/i #define CMK_THREADS_USE_PTHREADS                           0" ${}.h
    sed -i "/#endif/i #define CMK_64BIT                                          1" ${}.h

    sed -i "s|cc-gcc|cc-armclang|g" $FILE

    cp src/arch/common/ src/arch/common/

    sed -i "s|gcc|armclang|g" src/arch/common/
    sed -i "s|g++|armclang++|g" src/arch/common/
  3. Configure and build Charm++, using:

    mkdir ${INSTALL_DIR}/charm680/
    ./build charm++ $CHARMARCH --with-production --destination=${INSTALL_DIR}/charm680/${CHARMARCH} -j

Download and unpack NAMD

Change into your build directory:


Download and unpack the source files for NAMD, using:

tar -xf NAMD_2.12_Source.tar.gz

Build and install NAMD with Arm Compiler for HPC


This recipe for building NAMD requires you to have previously built and installed Charm++ using the instructions provided in this tutorial.

If you have not already, setup the variables BUILD_DIR and INSTALL_DIR, using:


To build NAMD:

  1. Change into the NAMD_2.12_Source directory, using:

    cd ./NAMD_2.12_Source
  2. Generate an armclang architecture file based on the existing Linux-ARM64-g++.arch file. To generate this file, you need to know the location of the Charm++ build directory NAMD_CHARM_DIR, and the architecture used for the Charm++ build CHARMARCH.

    For example, if Charm++ has been built and installed into ${INSTALL_DIR}/charm680, as described above:

    export CHARMARCH=multicore-linux-aarch64
    export NAMD_CHARM_DIR=${INSTALL_DIR}/charm680

    Copy the Linux-ARM64-g++.arch file, whilst renaming it to Linux-ARM64-armclang.arch using the command:

    cp arch/Linux-ARM64-g++.arch arch/Linux-ARM64-armclang.arch

    and configure this file using:

    sed -i "s|CHARMBASE.*|CHARMBASE = ${NAMD_CHARM_DIR}/|g" Make.charm
    sed -i "s|^CHARMARCH =.*|CHARMARCH = $CHARMARCH|g" arch/Linux-ARM64-armclang.arch
    sed -i "s|^FLOATOPTS =.*|FLOATOPTS = -O3 -fomit-frame-pointer ${WARN} ${TUNE}|g" arch/Linux-ARM64-armclang.arch
    sed -i "s|^CC = gcc|CC = $CC|g" arch/Linux-ARM64-armclang.arch
    sed -i "s|^CXX = g++|CXX = $CXX |g" arch/Linux-ARM64-armclang.arch
  3. NAMD's FFT configuration needs to be set to link to the FFTW interface of the Arm Performance Libraries. Ensure that ARMPL_DIR is set to the location of the installed library, and make a new FFT config file based on the existing x86 one, using:

    cp arch/Linux-x86_64.fftw3 arch/Linux-ARM64.fftw3

    and configure this file using:

    sed -i "s|^FFTDIR=.*|FFTDIR=$ARMPL_DIR|g" arch/Linux-ARM64.fftw3
    sed -i "s|^FFTINCL=.*|FFTINCL=-I$ARMPL_DIR/include|g" arch/Linux-ARM64.fftw3
    sed -i "s|^FFTLIB=.*|FFTLIB=-L$ARMPL_DIR/lib -larmpl -lflang -lflangrti|g" arch/Linux-ARM64.fftw3
  4. Complete the configuration and build NAMD with Arm Compiler for HPC, using:

    ./config Linux-ARM64-armclang --with-fftw3 --without-tcl --charm-arch $CHARMARCH

    cd Linux-ARM64-armclang
    make -j
  5. Create symbolic links to the executables, using:

    ln -s $BUILD_DIR/NAMD_2.12_Source/Linux-ARM64-armclang/charmrun charmrun
    ln -s $BUILD_DIR/NAMD_2.12_Source/Linux-ARM64-armclang/namd2 namd2

Run a simple benchmark

The Apoa1 example is a standard NAMD cross-platform benchmark. For more information on the Apoa1 example, see the NAMD website.

To run the Apoa1 example:

  1. Download the Apoa1 example:

  2. Unpack the example:

    tar -xf apoa1.tar.gz
  3. Edit the Apoa1 deck file apoa1.namd, which is located in the unpacked apoa1 directory, to:

    1. Define the full path of the output directory to print to.

    2. Disable the use of FFTW wisdom (the FFTW interface for Arm Performance Libraries does not generate or utilize the FFTW wisdom files).


    1. outputname /path/to/Apoa1_output_dir/
    2. FFTWEstimate yes
      FFTWUseWisdom no
  4. Configure and run the example, using:

    ${INSTALL_DIR}/namd2 +p${NP} apoa1/apoa1.namd +setcpuaffinity

    Note: Set the number of processors according to your own system availability. In this example, we have run on 16 cores (NP=16).

More resources

For more information on NAMD, visit the NAMD webpage.
For more information on Arm Compiler for HPC, visit the Arm Compiler for HPC page.
For more porting and tuning guides, visit our Porting and Tuning page.