Multi-level load balancing for parallel particle simulations
Abstract
Ideas from multi-level relaxation methods are combined with load balancing techniques to achieve a convergence acceleration for a homogeneous work load distribution over a given set of processors when the underlying work function is inhomogeneously distributed in space. The algorithm is based on an orthogonal recursive bisection ap- proach which is evaluated via a hierarchically refined coarse integration. The method only requires a minimal information transfer across processors during the tree traversal steps. It is described of how to partition the system of processors to geometrical space, when global information is needed for the spatial tesselation.
Full text
IS - Parallel Algorithms for Particle Systems Multi-Level Load Balancing for Parallel Particle SimulationsG. Sutmann VI International Conference on Particle-based Methods – Fundamentals and Applications PARTICLES 2019 E. O˜nate, M. Bischoff, D.R.J. Owen, P. Wriggers & T. Zohdi (Eds) MULTI-LEVEL LOAD BALANCING FOR PARALLEL PARTICLE SIMULATIONS Godehard Sutmann1,2 1J¨ulich Supercomputing Centre (JSC), Institute for Advanced Simulation (IAS), Forschungszentrum J¨ulich (JSC), D-52425 J¨ulich, Germany e-mail: [email protected] http://www.fz-juelich.de/ias/jsc/staff/g sutmann 2ICAMS, Ruhr-University Bochum, D-44801 Bochum, Germany Key words: Parallel Computing, Particle Methods, Load Balancing, Multi-Level Methods, Multigrid Abstract. Ideas from multi-level relaxation methods are combined with load balancing techniques to achieve a convergence acceleration for a homogeneous work load distribution over a given set of processors when the underlying work function is inhomogeneously distributed in space. The algorithm is based on an orthogonal recursive bisection approach which is evaluated via a hierarchically refined coarse integration. The method only requires a minimal information transfer across processors during the tree traversal steps. It is described of how to partition the system of processors to geometrical space, when global information is needed for the spatial tesselation. 1 INTRODUCTION Load imbalance is a common problem for parallel applications, which often arises when work load distributions are inhomogeneously distributed in the global system setup, or may occur when local inhomogeneities in the work density show up when increasing the number of processors. In fact, for many parallel applications which rely on domain decomposition as a parallel strategy, the processors define a spatial discretisation. Increasing the processor count, the spatial resolution is increased, which resolves density differences (which are often related to differences in work distribution) on a finer scale which consequently lead to runtime differences on the individual processors. Since differences in work load do lead to reduced parallel efficiency, various methods for an improved load balance between the processors have been proposed [1, 2, 3, 4]. In the present article, problems related to particle distributions or mesh vertices are considered. Since vertices might be considered as a kind of abstract particle in the sense that they have properties and relations to their neighbourhood we will use in the present article the notion of particle, which might be understood in a more general context. The problem of load balancing has to consider redistribution of work between processors in such a way that all processors are actively working for a period of time and reaching 1 80
Godehard Sutmann either the end of the program or a synchronization point at almost the same time, so that overhead- and waiting-times are minimized. This either includes active redistribution of work by sending tasks over the network, which reside on the other processors, or by, e.g., work stealing procedures, which includes forth and back communication between processors for both task distribution and gathering of results. In the present article we focus on redistribution of work load such that degrees of freedom (e.g. particles, vertices, etc.) are communicated between processors as a result of redefining the geometry of the domains. The basic principle is therefore a modification of the shape and size of domains such that local work W(n+1) iis increased, if W(n) i<�W�P, where W(n) iis the total work on processor i∈[0,P −1], Pthe number of processors and �W�Pthe average work of a processor. In analogy, W(n+1) jis reduced, if W(n) j>�W�P. The goal is that shapes and sizes of domains are adjusted in such a way that W(n) i=�W�P±δWi, where δWiis a tolerable difference on each processor from the optimal load, for which holds P−1 i=0 δWi= 0. In that sense, the problem of balancing the load between the processors has different levels of complexity: (i) how to properly define the load; (ii) which is the proper shape and size of a domain; (iii) how to control or minimise additional costs, e.g. increased number of communication partners; (iv) how to minimise the procedure of work redistribution, domain size and shape, e.g., with minimal communication costs between the global processor grid. In the present article we will mainly focus on issue (iv), which is related to the computational costs introduced by the chosen load balancing procedure and which should, of course, be much smaller than the computational overhead which is related to the work imbalance, i.e. the overhead which exists without any application of load balancing. Concerning issue (i) we will assume a properly chosen function, which characterises the work and which is properly measurable. In practice, this could be, e.g., the number of particles on each processor, the number of interactions, the total time of interactions or the wall clock time of one full time step. For convenience we choose for discrete systems the number of particles, Ni, on each processor. Concerning issue (ii) there were a number of different approaches discussed in the literature, including (a) orthogonal shapes in the case of orthogonal recursive bisection method [5] or tensor product method [6]; (b) irregular cells in the case of, e.g., Voronoi tesselation [7] or graph partitioning [8]; (c) distorted meshes with conserved topology [9, 10]. These methods differ mainly in how the work is redistributed and which constraints for the individual domains are considered. For most proposed methods the computational costs on the domain are considered, but communication between neighbour domains is neglected or, at least, not minimised. The latter issue usually leads to a coupled problem, which on the one hand increases complexity of the minimisation procedure and, on the other hand, leads sometimes to a non-smooth objective function since communication partners, and therefore also the communication overhead, may change discontinuously when increasing or reducing communication partners during minimisation. This communication overhead is related to the work on each domain after the load balancing step is finished. But the load balancing itself needs information which invokes communication between processors and in the worst case the required information has to be communicated between all processors, 2 81
Godehard Sutmann which especially leads to a big overhead for a large number of processors (i.e. those cases where load balancing is often crucial for a good parallel efficiency). This overhead might get crucial, especially when the load balancing has to be performed frequently in the simulation. This is a common problem for dynamic systems with high density contrasts or regions, which temporally does not contain any load. In such cases, the domain sizes and shapes might be reconstructed frequently, e.g. as it is for graph partitioning methods, or might be smoothly adjusted to a new (smoothly varying in time) work load change, which allows for iterative schemes, following the work load in time. This, however, has an important requirement, namely that the change in work load has a slower relaxation time than the load balancing scheme. Otherwise the load balancing method would lag behind the work load, not reaching an equal distribution of load. The current work does not focus on a new formulation of an objective function for minimising computational work and communication overhead, but on an approach which minimises the communication volume during the load balancing step for the case when global information exchange is necessary within the processor mesh. Necessary global communication in load balancing steps is performed on a hierarchical tree with minimal information exchange. We will focus on the class of Orthogonal Recursive Bisection (ORB), which is by itself a hierarchical scheme. Since the work load on a domain is determined by the local degrees of freedom on each domain, also information about the distribution of work on the domain is necessary, if it cannot be mapped to a simple mask, which could be communicated over the network. Therefore, we consider here an approach, which adapts elements from multigrid method [11], which uses the property that inhomogeneities on small scales are smoothed on a coarser scale. Since the number of degrees of freedom might get large (e.g. N>109) on high processor counts (e.g. P>105), the present approach is formulated in terms of reduced properties, i.e. only local work densities and domain coordinates are required to balance the load quite efficiently, even for very inhomogeneous work distributions, i.e., computational degrees of freedom, e.g. particles, are only exchanged / redistributed on the highest tree level and not explicitly communicated along the tree. The article is organised as follows: In Sec. 2 the method is introduced from a formal point of view. In Sec. 3 results are shown for various test cases, which include exact function descriptions (in order to consider convergence properties) and sample systems, consisting of discrete particle distributions. 2 METHOD 2.1 Multi-Level Description of Workload The goal of the formal characterization of work load is to describe it as hierarchical subdivision, where domains on level l+1 in the hierarchical description are constructed by a bisection of domains of a given level l. In this sense, the coarsest level, l= 0, consists of the whole system, whereas the finest level l=Lconsists of 2Lsub-domains. The original computational domains, which are administered by 2Lprocesses are the target regions for balancing the work load, such that each process has to fulfil the same amount 3 82
Godehard Sutmann of computational work. Therefore, the target work load for each process can be written as the average work on a given level, i.e. �W�l=2 −lW(1) For the highest level Lthe target distribution of work is �W�L=2 −LW(2) =1 P 2L−1 m=0 W(n) L,m (3) =1 PW(4) where W(n) L,m is the work on level Lon preocess mduring multi-level iteration n. Since this represents the total sum over all partial work distributions, this relation holds for each iteration n. Splitting a domain into two sub-domains can therefore be described as W(n) l+1,2k=�W�l+δW(n) l+1,2k(5) W(n) l+1,2k+1 =�W�l+δW(n) l+1,2k+1 (6) where δW(n) l+1,2k=x1/2 0 dx ρ(x|x∈Ω(n) l+1,2k)−δx(n) l+1,2k 0 dx ˆρ(n) l+1,2k(x) (7) =1 2W(n) l+1,2k+W(n) l+1,2k+1− {�} V(n) l+1,�({�})ˆρ(n) l+1,�({�}) (8) with the set {�}(n) l+1,2k={�|Ω(n) L,� ∩Ω(n) l+1,2k/∈ {∅}} (9) meaning that all volume and density contributions from the highest level Lare sampled onto the geometric region 2kwith finite intersection. δx(n) l+1,2kis an approximation for the location of the division point (in 2d division line, in 3d division plane) which subdivides a domain on level linto two sub-domains on level l+1 with approximately equal work load. In this stage, δx(n) l+1,2k, can only be computed approximately, since it is based on an average underlying work density, which does not contain any information about inhomogeneities in work distribution on a given process, i.e., the density ˆρ(n) l+1,2k(x) is constructed as a coarse grain approximation on the highest level L, which is iteratively refined during the multi-level procedure. Within multi-level cycle n, a density map of the system on level l is constructed by concatenating the average densities within the domain geometries, Ω(n) l,k . On the lowest level l= 0 this can be expressed as the complete map ˆρ(n) 0,0(x)= 2L−1 i=0 W(n) L,i V(n) L,i Ω(n) L,i (10) 4 83
Godehard Sutmann This results in a step or plateau function, where constant values are assigned to the density within the domain boarders of each domain on level l=L. This approach offers a low communication approach to the implementation, since only the domain geometries and the local work has to be transferred along the tree traversal. The communication part is described in more detail in the next sections. 2.2 Tree Down-Traversal: Merging domains between two levels The amount of communicated data down the tree is reduced to #(n) l,i = (2 ×d+ 1) × 8×|{�}(n) l,2k|bytes, where dis the dimension of the parallel sub-decomposition and which essentially contains the lower-left- and upper-right-corner of the domain (given that it is an orthogonal decomposition) and the work function value. To describe the basic procedure, we consider for the initial geometry a non-staggered, orthogonal decomposition of domains in 3-dimensional space on level L, which means that each domain has 6 neighbours, separated by domain interfaces. Here, we consider tilings in each cartesian direction which contain domains of multiples of 2, i.e. Ω = Dx⊗Dy⊗Dz, where |Dα|=2 lα(note that other tilings of arbitrary number of domains, including prime numbers, are possible and will be discussed elsewhere [12]). The procedure of merging is then straightforward. We describe each level las combination of levels in cartesian directions, i.e. l=lx+ly+lz(11) If we consider a given level l, the merging of two adjacent sub-domains is performed in one of the cartesian directions α, which reduces the next level by one through l−1=(lα−1) + lβ+lγ(12) where α,β,γ is any permutation of x, y, z. If we denote 2 adjacent index pairs in the multi-level decomposition as ([il]α,[il+ 1]α), which are subject to be merged in direction α, then we can write ix∈[0,2lx−1−1] iy∈[0,2ly−1] iz∈[0,2lz−1] [il]x=2 Lx−lx2ix+2 Lx+Ly−lyiy+2 Lx+Ly+Lz−lziz(13) [il+ 1]x=2 Lx−lx(2ix+1)+2 Lx+Ly−lyily+2 Lx+Ly+Lz−lziz(14) ix∈[0,2lx−1] iy∈[0,2ly−1−1] iz∈[0,2lz−1] [il]y=2 Lx−lxix+2 Lx+Ly−ly2iy+2 Lx+Ly+Lz−lziz(15) [il+ 1]y=2 Lx−lx+2 Lx+Ly−ly(2ily+1)+2 Lx+Ly+Lz−lziz(16) ix∈[0,2lx−1] iy∈[0,2ly−1] iz∈[0,2lz−1−1] [il]z=2 Lx−lxix+2 Lx+Ly−lyiy+2 Lx+Ly+Lz−lz2iz(17) [il+ 1]z=2 Lx−lx+2 Lx+Ly−lyily+2 Lx+Ly+Lz−lz(2iz+ 1) (18) The enumeration of the next lower level is then accordingly [il−1]α=[il]α. Moving down the tree and merging domains in direction α, the separating surface between domains is removed and it is Ωl−1,i =Ω l,i1∪Ωl,i2, with i=[il−1]α,i1=[il]α,i2=[il+ 1]α. 5 84
Godehard Sutmann 0 8 0 8 0 0 4 0 1 2 3 4 5 6 7 8 12 9 13 10 11 14 15 l=4 l=2 l=3 2 4 6 8 10 13 2 6 8 10 12 14 0 0 2 8 10 0 0 0 2 2 4 6 8 10 12 14 1 3 5 7 12 9 11 10 8 14 15 l=2 l=1 l=0 l=0 l=1 l=3 l=4 . . . 0 8 l=1 0 8 0 8 l=1 . . . . . . . . . ×ncycle . . . Figure 1: Schematics of the parallel implementation of the multi-level load balancing scheme. On lower levels, only processors with even indices are active. Merging implies that the domain with index [il]αis the master domain, which combines information of two sub-domains and takes part in the merging process on the next lower level. To have all information available, a communication from [il+ 1]αto [il]αhas to be performed which contains the lower left, upper right coordinates of the domain and its total work. On this stage, also the coarse density field of domains on level L, which overlaps with domain [il+ 1]αis communicated to ensure that on each level in the uptraversal later on the computation of the separating surface can be accomplished. 2.3 Tree Up-Traversal: Splitting domains on a level The density field of work which has to be integrated to find the proper coordinate for domain splitting on level l, is fixed on the highest level Lin the tree, i.e., it contains the average work within the geometry of individual domains in a given iteration step k. For simplicity we first consider a 1-dimensional case. This means that at lower levels, several sub-volumes from the highest level contribute to the work density field, which means that several integrals have to be evaluated to find the location of x1/2={x:P(x)=1/2}, where P(x) is the cumulative distribution function of work on a domain. From Fig. 1 it is understood that x1/2can be found by the geometric consideration x1/2=xk−1+ 1 2−P(xk−1) Wk (xk−xk−1) (19) =xk−1+1 2 1−2P(xk−1) P(xk)−P(xk−1) (xk−xk−1) (20) 6 85
Godehard Sutmann Here kis the domain, for which holds k=k:P(xk−1)<1 2∧P(xk)>1 2(21) In a multi-dimensional setting this is a bit more involved. The splitting of a domain is performed in a given direction nαby an intersection plane, which is orthogonal to the splitting direction. The splitting plane is then introduced at the relative position rα(1/2), for which the integral holds rα(1/2) rα,0 drαrβ,L rβ,0 drβrγ,L rγ,0 drγρ(r)=1 2W(22) In a discrete set of domains, where the density might change abruptly, depending on the work distribution over the processors, one can write for the total work on the domain W= pα−1 iα=0 rα,I[iα+1] rα,I[iα] drα pβ−1 iβ=0 rβ,iβ+1 rβ,iβ drβrγ,L rγ,0 drγ pγ−1 iγ=0 rγ,iγ+1 rγ,iγ drγρiα,iβ,iγ(23) In this formulation, I[i] is an ordered set as such that the domains of the highest level, intersecting with the domain on the coarse level l, are sorted according to their lower boarder in direction nα. Since the densities are approximated as constant over the domains at the highest level, the integrals can be computed exactly. Selecting for the splitting e.g. the z-direction can be formulated as a sum of sub-domains, W< l, located completely below z1/2and those, δW1/2 l, which are cut by the xy-plane cutting the z-axis at z1/2 W1/2 l=W< l+δW1/2 l(24) where W< l= p∈Pz (xp,1−xp,0)(yp,1−yp,0)(zp,1−zp,0)ρp(25) and δW1/2 l= p∈P1/2 (xp,1−xp,0)(yp,1−yp,0)(z1/2−zp,0)ρp(26) which leads to the following expression for z1/2 z1/2= W1/2 l−W< l+ p∈P1/2 (xp,1−xp,0)(yp,1−yp,0)zp,0ρp p∈P1/2 (xp,1−xp,0)(yp,1−yp,0)ρp (27) Here, the sets Pzand P1/2contains all subdomains pon the highest level Lfor which Pz={p}|ΩL,p ∪Ωl/∈ {∅}∧zp,1>z 1/2∧zp,1≤z1/2(28) P1/2={p}|ΩL,p ∪Ωl/∈ {∅}∧zp,0<z 1/2∧zp,1>z 1/2(29) 7 86
Godehard Sutmann 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1 0 2 4 6 8 10 12 14 16 18 20 P = 64 work distribution error V-c y cle index 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1 100 0 2 4 6 8 10 12 14 16 18 20 P = 512 work distribution error V-c y cle index 0510 15 20 010 20 30 40 50 60 70 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1P = 64 V-cycle index process error on level L 0510 15 20 0100 200 300 400 500 600 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1P = 512 V-cycle index process error on level L Figure 2: Results for Model 1, the trilinear model with an error threshold �1/2= 10−12 for the detection of the intersection plane during the up-traversal step of the tree walk. Compared are results for P= 64 and P= 512 domains, which are partitioned applying a multi-level V-cycle. The longer relaxation time for larger number of domains is in part due to a more inhomogeneous convergence behaviour of some domains. Therefore, in order to split the domain Ωl, requires a map of the underlying ΩLdistribution. Once this map is known on the coarse domain Ωl, the cutting plane for the generation of two sub-domains on level Ωl+1 can be done exactly according to the underlying density distribution. It is noted that between multi-level iteration cycles the exact work distribution does not change, since the sources of work, i.e. particles or mesh points are not moved or re-weighted. However, after each multi-level cycle, the domain geometries on level Lare adjusted and accordingly the work in each domain is changed, i.e., also the work density for each domain is modified in general. As a consequence, the underlying domain map and also the density tesselation is changed, leading to an iteratively converging partitioning of the domains on level L. 2.4 Generation of the underlying density map In each multi-level iteration step, the density map has to be known by all levels l∈{0,L}. The multi-level cycle starts from the finest level L, corresponding to the computational domain of each processor. On that level, the work per domain is explicitly known and transferred as a characteristic quantity to the load balancing method. Going down the tree to the coarsest level l= 0, means to merge two adjacent domains and com- 8 87
Godehard Sutmann 00.2 0.4 0.6 0.8 100.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 P = 64 xy z 00.2 0.4 0.6 0.8 100.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 P = 512 xy z 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1 0 5 10 15 20 25 P = 64 work distribution error V-c y cle index 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1 100 0 5 10 15 20 25 30 P = 512 work distribution error V-c y cle index 0510 15 20 25 30 010 20 30 40 50 60 70 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1P = 64 V-cycle index process error on level L 0510 15 20 25 30 0100 200 300 400 500 600 1x10-12 1x10-10 1x10-8 1x10-6 0.0001 0.01 1P = 512 V-cycle index process error on level L Figure 3: Results for Model 2, the Gaussian superposition model with an error threshold �1/2= 10−12 for the detection of the intersection plane during the up-traversal step of the tree walk. As in Fig. 2, results are compared for P= 64 and P= 512 domains, which are partitioned applying a multi-level V- cycle. For this case, there is also some inhomogeneous convergence behaviour observed for some domains. As an example for the result of the partitioning, the domain structure on the highest level, L, is shown (top). 9 88