oneMD

0 0
  • 0 Collaborators

Data-parallel molecular dynamics simulator for Intel oneAPI. ...learn more

Project status: Under Development

oneAPI, HPC

Intel Technologies
oneAPI, DPC++, Intel FPGA, DevCloud

Code Samples [1]Links [5]

Overview / Usage

oneMD is a molecular dynamics simulator designed to take advantage of SIMD and GPU and FPGA hardware data parallelism and acceleration. Unlike other molecular dynamics simulators like NAMD or OpenMM which rely on hardware acceleration via OpenMP or CUDA or OpenCL, oneMD is a new simulator written in DPC++ designed especially to utilize diverse kinds of hardware acceleration across multiple architectures .

Many molecular dynamics calculations are highly data-parallel and molecular dynamics simulations appear to benefit tremendously from onboard data parallel hardware accelerators like GPUs, in contrast to other HPC patterns like clusters. E.g. the CHARMM project which uses OpenMM reports using a single workstation with an NVIDIA GTX 980Ti results in more than 3x the performance of a 32-node dual Intel E5-2690 / 8 core cluster on some simulations like DHFR. NVIDIA reports that the ACEMD simulator running DHFR on a single Tesla GPU can simulate 116 ns/day or 3x the performance of 32-node Xeon cluster.

Acceleration of molecular dynamics calculations using GPUs and FPGAs has been a topic of considerable interest for a long time. oneMD explores different kinds of data parallelism for molecular dynamics including the potential of using multiple hardware devices or offloads concurrently and also creating dedicated parallel compute units in FPGAs for executing common operations. The ultimate goal is to implement FPGA-accelerated simulators using SYCL similar to here without requiring any HDL code.

The molecular data and trajectories produced by oneMD are saved in standard PDB and .XTC formats that can be used with other simulators and viewed in programs like VMD.

Requirements

oneMD is cross-platform and cross-arch and can be built on DevCloud or with any well-known C++ compiler including MSVC. If you are using it on your local machine you will need a oneAPI environment setup to build with GPU and FPGA device acceleration. If you don't use a oneAPI environment then only OpenMP host acceleration support will be built.

Installation

  • Clone the project repo including all sub-modules: git clone --recurse-submodules https://github.com/allisterb/oneMD.git
  • Run build.sh on DevCloud or Linux, or build on Windows. This will place a omd executable in the project folder.
  • Run omd --help or ./omd --help from the project folder and you should see the oneMD help screen.

Note that there seems to be a bug when oneMD is built in Release mode on Windows. Run build-debug on Windows if the simulation hangs on Windows and use the debug executable omdd.

Methodology / Approach

Overview

Rather than try to convert CUDA or OneMP code or add oneAPI support to existing molecular dynamics simulators, oneMD is a new C++17 codebase which can utilize different kinds of hardware accelerators and architectures.

Instead of writing optimizations by hand, we can try to specify the problem completely in DPC together with functions from the oneAPI libraries and let the compiler figure out the optimizations targeting a specific architecture. We can use DPC to write code that targets reconfigurable logic devices without incurring the burden of having to design and write HDL code.

oneMD uses as basic starting points the single-file OpenMP simulator by John Burkardt and the OpenMP Lennard-Jones simulator by James W. Barnett . The focus now is on seeing how basic MD models can be implemented in DPC++ and SYCL rather than on implementing more complex models.

Background

A molecular dynamics simulator is a computer program which simulates how a set of atoms or molecules interact with each other in a specific region using an assumption that the equations of classical mechanics are sufficient to model the particle interactions accurately due to properties of the particles like their atomic mass and temperature or their being in a liquid state of matter.

In a molecular dynamics simulation we have a system of N atoms (or molecules) where each atom follows Newton's law relating the force on an individual atom to its mass and acceleration F=ma**. **The simulation calculates the momentum and position of each atom at a microscopic level and then converts this information to macroscopic properties like pressure, energy, etc. using statistical mechanics. The thermodynamic or macroscopic state of the system is calculated by statistical averages over the microscopic state of individual atoms defined by their position and momentum.

The basic algorithm for a oneMD simulation of a system of N particles in a cubic box region is

  • Use a random distribution to assign to assign a velocity and position to each atom.
  • Iterate through a fixed set of time steps and perform the following calculations ay each step:
  • For each atom keep track of neighboring atoms in a neighbor list. Atoms that are too far away to interact (according to the model) should be removed from the neighbor list.
  • For each atom iterate through the neighbor list and calculate the distance between the selected atom and each of its neighbors along with the interaction potential energy using an equation like Lennard-Jones. The force on each atom due to a neighboring atom is found by using the differential of the LJ equation wrt. distance.
  • Use the virial theorem to find the instantaneous kinetic energy of the entire system of atoms as a function of the force due to each neighboring particle and the distance between them.
  • Calculate the instantaneous pressure using the kinetic energy, volume, temperature and Boltzmann's constant.
  • Calculate the next position and velocity of each atom in the next timestep using the Verlet integration method.

Experiences

This was my first time using Intel's oneAPI platform and tackling a modern C++‎ project solo and overall it was a good experience. I had planned to download and install the oneAPI toolkit locally but I realized there's zero advantage to doing this over using DevCloud, unless maybe I was doing graphics programming.

The Remote SSH and C++‎ extensions of Visual Studio Code really impressed me here as to how seamless it made IDE programming with all the conveniences like IntelliSense, on a remote cloud environment. CMake support is really good in Visual Studio Code and I was able to setup a cross-platform build process that supports different toolchains without complications.

Using modern C‏‏‎++‎ ‏‏‎is quite addicting as you can quickly leverage the power and performance of native code and sophisticated libraries without much tedium and bookkeeping. It's quite gratifying to see just how much faster native compiled executables start up and run, compared to executables from other interpreted or managed languages.

The new syntax features and libraries like Parallel STL makes C++‏‏‎ ‎‎feel closer to C# but of course you still have to fix minor platform differences in libraries.

CMake and its modernized syntax makes this relatively easy. I definitely want to start doing more cross-platform projects using C++‎ 17 and CMake instead of .NET and Python.

Converting the existing simulator code to DPC++‎‎ is taking longer than I thought because the code uses a lot of std::vectors which I discovered are pretty much useless for device kernels since all the data storage has to be declared and allocated up front. Fortunately it's trivial to obtain raw host pointers to the data in host-side vectors that can be accessed by device-side code. The ability to drop down to low-level bit-twiddling when needed is what makes the language so powerful compared to C# and Python.

See this CodeProject article on oneMD for a more detailed description of how oneMD was implemented and my overall experiences using modern C++‎, Intel DevCloud and oneAPI.

Technologies Used

C++17

DPC++

OpenMP

oneAPI Base Toolkit

Repository

https://github.com/allisterb/oneMD

Comments (0)