




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





In this paper, we discuss an efficient parallel implementation of the treecode Ewald method for fast evaluation of long-range Coulomb interactions in a periodic system for molecular dynamics simulations. The parallelization is based on an adaptive decomposition scheme using the Morton order of the particles. This decomposition scheme takes advantage of the data locality and involves minimum changes to the original sequential code. The Message Passing Interface (MPI) is used for inter-processor communications, making the code portable to a variety of parallel computing platforms. We also discuss communication and performance models for our parallel algorithm. The predicted communication time and parallel performance from these models match the measured results well. Timing results obtained using a system of water molecules on the IA32 Cluster at the Ohio Supercomputer Center demonstrate high speedup and efficiency of the parallel treecode Ewald method.
The rapid advancement in computational science has dramatically changed the way researchers conduct scientific investigations, particularly in the studies of molecular interactions in a biomolecular system [1]. However, the current modeling and simulation capabilities available to researchers are still vastly inadequate for the study of complex biomolecular systems, although there has been tremendous progress in computer hardware, software, modeling, and algorithm development [1, 2]. For example, the typical time step in a molecular dynamics (MD) simulation is on the order of 10-15^ second, but the time interval of biological interest is typically on the order of 10-6^ - 1 second. This translates to a simulation involving 10^9 - 1015 time steps, where each step includes the computation of short-range interactions and extremely time consuming long-range Coulomb interactions. As a result, the longest simulation time that has ever been reported was 3.8× 10 -5^ seconds [1, 3], which was
achieved using a distributed parallel system with 5000 processors. To bridge the gap between the time interval of biological interest and that accessible by MD simulations, there has been extensive effort to improve the computational efficiency. One approach is to increase the time step size [4]. Another approach is to decrease the time needed for the force evaluations at each time step. This paper is concerned with the second approach. In an MD simulation of a system of N particles, the computational cost is dominated by the frequent force evaluations. The calculation of long-range Coulomb interactions is the most time-consuming part of the evaluations. A straightforward implementation of the calculation requires O( N^2 ) operations. In recent years, several methods have been developed to reduce the cost of computing Coulomb interactions while maintaining accuracy of N -body MD simulations, notably the multipole expansion based tree-codes and Ewald summation based fast algorithms [5-20]. Two of the earliest tree-codes were developed for problems involving gravitational interaction by Appel [7], Barnes and Hut [8]. Both algorithms employed monopole approximations with a complexity of O( N log( N) ). Appel used a cluster-cluster evaluation procedure, while Barnes and Hut used a particle-cluster procedure. Greengard and Rokhlin's fast multipole method reduces the operation count from O( N^2 ) to O( N ) [9]. To obtain higher accuracy, the fast multipole method uses higher order multipole approximations and a procedure for evaluating a multipole approximation by converting it into a local Taylor series. There is much ongoing effort to optimize the performance of the fast multipole method. The latest version of the fast multipole method uses more sophisticated analytical techniques that combine the use of exponential expansions and multipole expansions [10]. The Ewald summation method has been widely used to handle Coulomb interactions for systems with periodic boundary conditions [15, 16]. The method converts a conditionally convergent series into a sum of a constant and two rapidly convergent series, a real space sum and a reciprocal space sum. The relative computational cost of the two series is controlled by an adaptive splitting
parameter α. The popular particle-mesh Ewald method [17] (PME) reduces the complexity of Ewald summation by choosing a large value for a; the real space sum is computed in O( N ) and the cost of evaluating the reciprocal space sum is reduced from O( N^2 ) to O( N log N ) using a particle-mesh interpolation procedure and the fast Fourier transform (FFT). PME was a major success in the field of biomolecular computing, but parallelizing PME has been a great challenge due to the high communication cost of 3D
FFT. With a relative small value of α .? the Ewald summation based tree-code [18] approximates the real space sum using a Barnes-Hut tree and the multipole expansion of the kernel erfc (| x |)/| x | and reduces the computational cost from O( N^2 ) to O( N log( N) ). While parallel implementations of hierarchical tree- codes, including the parallel fast multipole method and the parallel Barnes-Hut tree based multipole method, have been extensively studied [21-26], the parallel implementation of the Ewald summation based treecode [18] for fast evaluation of long-range Coulomb interactions in a periodic system has never been reported. In this paper, we present an efficient parallel implementation of this method. We describe an adaptive decomposition scheme based on the Morton order of the particles. This decomposition scheme takes advantage of the data locality and involves minimum changes to the original sequential code. We then discuss Amdahl’s law and illustrate the performance improvement gained by making a common sequential part faster. The parallel algorithm has been implemented using the Message Passing Interface (MPI), making it portable to a variety of parallel platforms [27, 28]. We then report and discuss detailed numerical results based on the force evaluation for a water system on the IA32 Cluster at the Ohio Supercomputer Center. The next section describes the Ewald summation based treecode. The parallel implementation of the method and timing results are given in Section 3 and Section 4, respectively, followed by the conclusions in Section 5.
The total electrostatic energy of a periodic system of N particles can be described in terms of a conditionally convergent series:
∑ ∑ ∑ = = − +
N
j i j
i j
N
i L
E qq 1 1 |r r n|
(^2) n
where qi is the charge of particle i , L is the size of the simulation box, r i is the position of particle i , | r | denotes the Euclidean norm, n = ( n 1 , n 2 , n 3 ) are integers, and the prime indicates that the i=j terms are omitted when n =0. A detailed description of the Ewald summation method is given in [15]. Essentially, the
method splits the above conditionally convergent series into a sum of a constant, E (^0 ), and two rapidly convergent series, a real space sum E ( r )^ and a reciprocal space sum E ( k ),
where
N
j
1
2 1 / 2
()
∑ ∑ ∑
N
j (^) i j
i j i j
N
1 1
()
2 (^221)
2 2 2
( ) exp | | exp^2 | |
1 2
=
(^) ⋅ ≠
= −
N j j^ L j
q i L L E nr n
n n
k π α
π π (^) 0^ (5)
and a is a positive parameter. The complementary error function in the real space sum and the exponential function in the reciprocal space sum decay rapidly with the index n , therefore cutoffs rc and kc can be used to compute the Ewald sum, i.e. only terms satisfying | r i – r j + L n | ≤ r c (6) for E ( r )^ and | n | ≤ k c (7) for E ( k )^ are retained for the computation. The magnitude of the Ewald parameter a controls the relative rates of convergence of the real space sum and the reciprocal space sum. When a is large, E ( r )^ converges rapidly and can be evaluated to a given accuracy in O( N ) operations using an appropriate cutoff r c; however in this case E ( k )^ converges slowly and O( N^2 ) operations are required since the cutoff k c must be large enough to attain the desired accuracy. The situation is reversed when a is small, and therefore in either case, the classical Ewald method requires O( N^2 ) operations. The cost can be reduced to O( N 3/2) by optimizing the parameters a, r c, k c as a function of N [16]. The hidden constant in front of N 3/2^ can be further reduced using the linked-cell method to reduce the computational cost of locating the particles that are within the cutoff radius of a given particle [6]. The Ewald summation based multipole method is a tree-code [18]. A typical tree-code has three basic features: (a) the particles are divided into nested clusters, (b) the far-field influence of a cluster is approximated using a multipole expansion, and (c) a recursive procedure is applied to evaluate the required force or potential. The Ewald summation based treecode uses an oct-tree data structure and Cartesian multipole expansions to approximate the real space sum in the Ewald summation. With a relatively small value for a and an appropriate cutoff r c, the method reduces the computational complexity of the real space part from O( N^2 ) to O( N log( N) ). The reciprocal part can be computed in O( N ) operations using a cutoff k c. In the Ewald summation based treecode, the oct-tree is a Barnes-Hut tree. The root node is the cubic box
computation of the short-range forces can be achieved through spatial decomposition and exchange of particle positions with neighboring processors [30]. However, parallelizing the computation of long-range forces is a challenge. For the Coulomb interactions, a particle in a charged system interacts with all other particles in the system. This means that to compute the Coulomb interactions, all-to-all data communications between different processors of a parallel computer is required. This situation is even more cumbersome when the simulation system is non-homogeneous and/or a typical pointer-based tree data structure is used. Atom decomposition and spatial decomposition are the two commonly used methods for parallelization of an MD code [30]. In the atom decomposition method (also known as replicated-data method [31]), identical copies of particle information are stored on each processor and a pre-determined set of force evaluations is assigned to each processor for the entire duration of the simulation. The particles assigned to a processor may not have any spatial relationship to each other. One of the main advantages of this method is its simplicity. As a result, it has been widely used by many major MD programs including Amber and Charmm [32, 33]. In addition, because each processor has a copy of the entire data set, the computation of many body effects such as polarizability can be relatively easily added to the simulation. Spatial decomposition is another popular parallelization method [34]. In this method the domain is decomposed spatially and particles are assigned to each processor based on their geometrical positions. One clear advantage of this method is the consideration of the data locality and scalability. The adaptive domain decomposition scheme presented in this paper is a variant of the atom decomposition method, in which the spatial position of each particle is considered in the decomposition to ensure good data locality. The sequential code of the Ewald summation based treecode uses a pointer-based oct-tree. The tree is constructed adaptively to deal with non-homogeneous systems, i.e. tree branches are taller in regions of high particle density and shorter in regions of low density. The implementation of the data structure is achieved by utilizing a list of particles in their Morton order. Based on our experience with the sequential code, the tree construction, even in a straightforward implementation, takes only a very small fraction, typically less than 0.4%, of the total computation time. To obtain an efficient parallel code for a moderate number of processors and minimize changes to the sequential code, we implemented a variant of the atom decomposition method in the parallelization of the Ewald summation based treecode. In our method, particle information, including particle positions and charges as well as input parameters such as the order of
the approximation and multipole acceptance criterion, are replicated on each processor. Each processor constructs its own copy of the oct-tree and computes the multipole moments associated with each node of the tree. As a result, a unique list of the particles in Morton order is obtained on each processor when the tree construction is finished. Through the duplicated tree construction performed on each processor, the cumbersome all-to-all communication of the pointer- based oct-tree structure can be avoided. With the one-dimensional list of the particles in spatial order, the force computation can be distributed across the processors by simply splitting the list into groups of the same computational workload, which can be approximated based on the computational cost of each particle at the previous time step. With our domain decomposition, the actual computation for the particles assigned to each processor can be performed in parallel without exchanging data with any other processors. After the force calculation is complete, each processor sends the computed forces acting on the particles assigned to the processor to all other processors and receives the force acting on other particles from other processors.
Table1. Morton order based atom decomposition algorithm.
Step Description
1
Construct the oct-tree, sort the particles based on their Morton order to form a 1-D list, and compute the multipole moments of each tree node.
2
Compute forces on particles assigned to processor Pi based on the workload in the previous time step. The computation uses the oct-tree structure and the linked cells method. The distant particle-cluster interactions are approximated using multipole expansions.
3 Exchange forces with all other processors
4
Consolidate other parts of the force acting on each particle, integrate the equation of motion, and update the particle positions.
Table 1 outlines the Morton order based atom decomposition algorithm. The cost of the tree construction is of order N log( N) , but as mentioned above, the proportionality constant is very small, making the cost of step 1 only a very small fraction of the total computation time. The second step is the most time consuming part of the computation. Each
processor is responsible for the force calculation of N / P particles, where P is the number of processors. Consequently, the computation time on each processor is proportional to ( N log( N) )/ P. The third step of the algorithm involves an all-to-all communication, but fortunately this is the only communication required in the method. Once the long-range force evaluation is finished, the forces due to other short-range interactions, including the reciprocal part of the Ewald summation, can be added to obtain the total force on each particle. Clearly the cost of this last step is proportional to N. In our parallel implementation of the tree-code, the tree construction part is sequential although the whole computation has substantial parallelism. To minimize the computation in tree construction, we optimized this common sequential part of the tree-code. In the original sequential implementation, eight temporary linked lists are used to construct the tree and sort the particles in Morton order. When a tree node is divided into eight child nodes, the particles belonging to a child node are copied into the corresponding linked list. When the partition is finished, the particles on the eight linked lists are then copied back into the main list according to the order illustrated in Figure 1. In the current implementation, a variant of quicksort partition is used and accordingly the sorting is done in place with no need for any linked lists. This partition technique is an analog of the K-d tree construction technique. The initial list of the particle positions are partitioned along the x -axis into two sublists. Each sublist is then partitioned along y -axis, and then z -axis respectively. The enture process is repeated recursively until the number of particles in each node is less than or equal to a pre-determined number N 0. With this new tree construction technique, a substantial amount of tree construction time can be saved, thereby reducing the sequential computation time in the parallel code. Load balancing is a key issue in the parallelization of any MD code, especially when the simulation systems under consideration are non-homogenous. The workload for computing the force at each particle depends on its local particle density and the particle’s geometrical position. As pointed out earlier, the domain decomposition scheme splits the main list for the simulation system into groups of particles. The number of particles in each group is approximated based on the number of interactions that each particle was involved in the previous time step. With this weighted equal-size splitting technique a good load balancing can be achieved.
The parallel treecode Ewald method is implemented using the C programming language and MPI on the
IA32 Cluster at the Ohio Supercomputing Center [35]. The cluster is a distributed/shared memory hybrid system constructed from commodity PC components running the Linux operating system. Each compute node has two 1.4GHz Athlon MP processors, 2 GB of memory, and 70 GB of local scratch space. The nodes are connected using Myrinet 2000, a switched 2 Gbit/s network. The test data is a set of 15,625 water molecules, which consists of 46,875 particles. The TIP4P water model [36] is used and a 1.6 picosecond molecular dynamics simulation is performed to generate the configurations of the water molecules [37]. The real space part of the potential and forces are computed based on this set of data, and the performance of the parallel implementation of the Ewald summation based treecode is also measured using this set of data. Figure 2 and 3 show the execution times (wall- clock times) of the real space sum calculations for one time step using a = 5.6/ L , r c = L /2, and N 0 =20. The order of the multipole expansion was taken to be p = and p =9 respectively. It is clear that significant reductions in runtime have been achieved as more processors are added. In the case of p =6, the execution time is reduced from about 100 seconds on one processor to less than 2 seconds on 64 processors. In the case of p =9, the execution time is reduced from about 200 seconds on one processor to less than 3. seconds. Note that the higher the order of the multipole approximation, the more computations are needed to calculate the forces while the communication cost remains the same. Hence, we expect better speedup and computational efficiency with higher order multipole approximations.
(^0) 012 4 8 16 32 64
20
40
60
80
100
120
Number of processors
Execution time (s)
Figure 2. Execution time or calculating the real space sum using the parallel tree-code with the order of the multipole approximation p =6.
According to Amdahl’s law [38, 39], the speedup of a parallel implementation of a computation algorithm
Figure 6 shows the ideal, measured, and predicted speedup using Eq. 15 for the force calculation with p =
(^1) 12 4 8 16 32 64 24
8
16
32
64
Number of processors
Speedup relative to one processor
predicted speedupideal speedup measured speedup
Figure 6. Speedup of the parallel tree- code with the order of the multipole approximation p = 9.
It is well known that for a given problem with fixed size, the parallel performance will eventually deteriorate as the number of processors increases. To maintain parallel efficiency, the problem size must increase as more processors are used, and a different measure, such as effective number of floating point operations per second, must be used to measure the parallel efficiency.
The work reported in this paper is a first attempt to parallelize the Ewald summation based treecode for long-range force calculations in a periodic system for molecular dynamics simulations. Our effort focused on portability, simplicity, and efficiency of the parallel code. The predicted results from our communication
and performance models match the measured results well. Timing results obtained using a 46,875-particle water system demonstrates that our parallel algorithm scales well up to 64 processors. We expect the algorithm to maintain this good scalability on more processors with increased problem size. Future work includes investigation of parallel tree construction to increase the fraction f of parallelizable computations, and minimization of communication cost T c to further improve parallel efficiency.
This work was supported in part by NSF Grants ACI-0081303, DMS-0075009, DMS-0107187, a start- up fund from the University of Akron, and Michigan Life Sciences Corridor grant #1515. The authors thank Dr. Timothy O’Neil for helpful discussions and the anonymous referees for their comments on the revision of this paper.
Multipole, and Radiosity, Journal of Parallel and Distributed Computing , 27:118-141, 1995.