Full text
Exploiting Nested Task-Parallelism in the H-LU Factorization Roc´ıo Carratal´a-S´aeza, Sven Christophersenb, Jos´e I. Aliagaa, Vicen¸c Beltranc, Steffen B¨ormb, Enrique S. Quintana-Ort´ıa, aDepto. Ingenier´ıa y Ciencia de Computadores, Universidad Jaume I, Castell´on, Spain. bMathematisches Seminar, Universit¨at zu Kiel, Germany. cBarcelona Supercomputing Center, Spain. Abstract We address the parallelization of the LU factorization of hierarchical matrices (H-matrices) arising from boundary element methods. Our approach exploits task-parallelism via the OmpSs programming model and runtime, which discovers the data-flow parallelism intrinsic to the operation at execution time, via the analysis of data dependencies based on the memory addresses of the tasks’ operands. This is especially challenging for H-matrices, as the structures containing the data vary in dimension during the execution. We tackle this issue by decoupling the data structure from that used to detect dependencies. Furthermore, we leverage the support for weak operands and early release of dependencies, recently introduced in OmpSs-2, to accelerate the execution of parallel codes with nested task-parallelism and fine-grain tasks. Keywords: Hierarchical linear algebra, LU factorization, nested task-parallelism, task dependencies, multi-threading, multicore processors, boundary element methods (BEM) Email addresses: [email protected] (Roc´ıo Carratal´a-S´aez), [email protected] (Sven Christophersen), [email protected] (Jos´e I. Aliaga), [email protected] (Vicen¸c Beltran), [email protected] (Steffen B¨orm), [email protected] (Enrique S. Quintana-Ort´ı) Preprint submitted to Journal of Computational Science February 5, 2018
1. Introduction Hierarchical matrices (or H-matrices) [1] provide a useful mathematical abstraction to tackle problems arising in boundary element methods, elliptic partial differential operators, and related integral equations, among others [2]. Concretely, for many of these applications, H-matrices and the associated H-arithmetic methods offer efficient numerical tools to store an n×nmatrix using only O(n k log n) elements and compute matrix factorizations with a cost of O(n k2log2n) floating-point operations (flops). In these cost expressions, kdenotes the local rank for subblocks of the matrix, which can be tuned to trade off accuracy of the approximation for storage and computational costs [3]. The development of linear algebra methods for H-matrices has been an active area of research during the past two decades, having produced a wide number of packages such as HLib, H2Lib and HLibPro as well as a collection of individual routines. Part of this software directly relies on the kernels from the Basic Linear Algebra Subprograms (BLAS) [4] to compute fundamental dense linear algebra (LA) operations. As a result, when linked with a multi-threaded instance of the BLAS, these H-LA routines can seamlessly run in parallel on current multicore processors. However, this solution can extract a limited amount parallelism, bounded to that present in the individual BLAS kernels. Furthermore, for H-matrices arising from real applications, low-rank blocks “dominate” the data structure. While this confers H- matrices/methods their appealing low storage and computational costs, unfortunately, it also limits further the parallelism that can be extracted from individual kernels. In particular, H-arithmetic involves memory-bounded kernels which, in general, do not benefit from a multi-threaded execution. The bottom-line is that, for practical H-applications, it becomes necessary to exploit parallelism at a higher level. In the last years, exploiting task-parallelism has been exposed as an appealing coarse-grain approach for the solution of dense and sparse linear systems on multi-threaded architectures [5, 6, 7, 8, 9]. These approaches discover task parallelism dynamically (at execution time) via a runtime but rely on a sequential implementation of the numerical kernels (in the dense case, BLAS) to execute the individual operations. Although similar, the factorization of H-matrices for linear systems presents some specific challenges when the aim is to extract task-parallelism. First, the “recursive nature” of H-matrices makes the detection and efficient exploitation of nested task- 2
parallelism a complex endeavor. Second, handling low-rank matrices requires specialized data structures that can vary (grow/shrink in size), at execution time, with low overhead. This is particularly important given the low cost of H-arithmetic algorithms. In [10], we presented two prototype task-parallel versions of the H-LU factorization using the OpenMP and OmpSs programming models [11, 12]. Our initial implementations presented several drawbacks, that we overcome in this work, making the following specific contributions: •The prototype implementations in [10] assumed that the blocks of the H-matrix were either dense or null. No specialized data structures and H-arithmetic for low-rank blocks were therefore involved in the factorization. In comparison, in the present work we parallelize the H-LU factorization as implemented in the sequential version of H2Lib, with problems involving low-rank blocks and, therefore, low-rank storage and real H-arithmetic. •An additional consequence of targeting the H-LU factorization in H2Lib is the need to accommodate low-rank data structures that can change their dimensions at execution time. This is particularly challenging for a runtime-based parallelization because task dependencies are detected via an analysis of the memory addresses of the tasks’ operands. To address this problem, we propose the use of an auxiliary “skeleton” array, which reflects the block hierarchy of the H-matrix, and can be leveraged to identify task dependencies. This additional data structure is built before the execution commences, at low cost, and remains unchanged during the complete execution, independently of the modifications on the structures containing the actual data due to the use of H-arithmetic. •The task-parallel implementation developed in our past work [10], based on OmpSs, forced us to operate on fine-granularity tasks with operands that were stored in contiguous regions of memory. The practical consequence of this constraint is that it was not possible to exploit the nested task-parallelism intrinsic to the H-LU factorization. In the present work, we address these problems using the new OmpSs-2 model, with explicit support for weak dependencies and early release to take advantage of fine-grained nested parallelism [13]. 3
The rest of the paper is structured as follows. In Sections 2 and 3, we briefly review the structure of H-matrices in H2Lib and introduce a high-level algorithm for the LU factorization of an H-matrix, respectively. (A complete review of H-matrices and H-arithmetic can be found, for example, in [1, 3].) In Section 4 we re-visit the parallelization of the H-LU factorization in [10], exposing the limitations of those prototype codes. In Section 5 we describe the new task-level parallelization of the hierarchical factorization, offering details on the use of the skeleton structure to detect task dependencies and the exploitation of fine-grained nested parallelism via weak dependencies. Finally, in Section 6 we provide a complete experimental evaluation of the task-parallel codes, and in Section 7 we close the paper with a few concluding remarks. 2. Representation of H-Matrices in H2Lib In this section we briefly introduce the structure of H-matrices and how they are implemented in H2Lib.1This sequential library, written in C, offers a state-of-the-art implementation of H-matrix techniques, including sophisticated data structures, support for H-arithmetic operations such as multiplication, inversion and factorization, compression schemes for non-local operators, and fast re-compression algorithms. The main idea behind H-matrices relies on finding a partition over a matrix into blocks which are either small in dimension or admissible in the sense that they can be stored efficiently using low-rank data structures instead of dense ones. Utilizing low-rank matrices is a prerequisite for reducing the storage and computational costs down to log-linear functions on the number of elements and flops, respectively. Before we can find a partition of the matrix into a set of subblocks, we need to “organize” the degrees of freedom (DoFs) into sets, which can be handled efficiently via a tree-like structure called clustertree. Therefore, we assume that we know the geometric extent of every degree of freedom that appears in our application. This frequently reduces to the support of finite element basis functions. Armed with that information, we can setup an axis-parallel bounding box Bt, which contains the union of all extents corresponding to the cluster t. This box will now be splitted into two parts along 1http://www.h2lib.org/ 4
some geometrical dimension, which yields two independent boxes Bt1,Bt2. From there, we can sort each and every DoF into one of these boxes according to their position in space. Next we process both boxes recursively until the number of DoFs located in a box falls below a prescribed constant, which we denote by leafsize (Clf ). In order to handle all these boxes efficiently, we organize these clusters into a tree structure expressed by sons(t) = {t1, t2}. This procedure is summarized in Algorithm 1. Algorithm 1 Clustertree construction Require: Geometric information about the degrees of freedom is stored within an array dofs of length size. Ensure: A hierarchical partition of the DoFs is returned via the clustertree t. procedure setup clustertree(dofs, size) if size > Clf then d←find splitting dimension(dofs, size) sons ←2 t←new cluster(dofs, size, sons) {dofs1, dofs2, size1, size2} ← sort dofs(dofs, size, d) t1←setup clustertree(dofs1, size1) t2←setup clustertree(dofs2, size2) sons(t)← {t1, t2} else t←new leaf cluster(dofs, size) end if return t end procedure This hierarchical structure is realized with the following C data structure cluster within H2Lib: 1struct cluster { 2uint size; 3uint *dofs 4uint * bbox_min ; 5uint * bbox_max ; 6cluster *son; 7uint sons; 8} 5
Here size is the number of elements associated with this cluster and dofs is an array referring to the degrees of freedom. The bounding box Btfor a cluster tis stored within the arrays bbox min and bbox max, respectively. In addition, son and sons represent the tree structure of the clusters. In order to identify subblocks of the matrix, which can be approximated by a low rank representation, we need some admissibility condition, which ensures that we can find an approximation to some prescribed accuracy. For many cases, particularly for tensor-interpolation, the condition min{diam(t),diam(s)} ≤ dist(t, s) guarantees this. Here diam and dist denote the Euclidean diameter of some cluster and the Euclidean distance between two clusters, respectively. During the setup of the H-matrix, the partitioning is performed recursively as stated in Algorithm 2, returning a tree-like block structure. For a detailed construction of such block partition, see [1, 3]. Algorithm 2 Blocktree construction Require: row cluster t, column cluster s. Ensure: A blocktree bis returned for the pair (t,s). procedure setup blocktree(t, s) if admissible(t, s) then b←new admissible block(t, s) else if sons(t) 6=∅ ∧ sons(s) 6=∅then b←new partitioned block (t, s) for all t’ ∈sons(t), s’ ∈sons(s) do b[t’][s’] ←setup blocktree(t’, s’) end for return b else b←new inadmissible block(t, s) end if end if return b end procedure In agreement with the three cases occurring in Algorithm 2, the application of Algorithm 2, at a given level of the recursion, can produce either 6
a low-rank block (i.e., a new admissible block), a new recursive partitioning (via the same algorithm), or a conventional dense (inadmissible) block. To handle these cases, the C data type representing a H-matrix in the H2Lib follows this structure: 1struct hmatrix { 2cluster rc , cc; 3rkmatrix r; 4amatrix f; 5hmatrix * son; 6uint rsons , csons ; 7} In this data type, rc and cc respectively correspond to the row cluster and column cluster of he current matrix block. Low-rank matrices are stored in the structure rkmatrix, whereas dense matrices are stored in amatrix. Partitioned matrices are accommodated using an array pointing to the sons. The structure also provides the amount of sons per row and column, stored in rsons and csons, respectively. 3. LU Factorization of H-Matrices 3.1. Algorithm for the H-LU factorization We open this section with a brief review of the algorithm for the H-LU factorization. For this purpose, consider a sample H-matrix A∈Rn×n, partitioned as shown in Figure 1. The factorization procedure can be formulated as a generalization of the blocked right-looking (RL) algorithm for the LU factorization [14] that exploits the hierarchical structure of the matrix. 4,3 A 1:2,3:4 A 1,2 A 2,1 A 3:4,1:2 A 3,3 A3,4 A 1,1 A A4,4 A2,2 Figure 1: 2 ×2 partitioning of a simple H-matrix. 7
In particular, the following sequence of operations computes the H-LU factorization of A: Sequence of operations for the H-LU factorization of A: O1.1 :A1,1=L1,1U1,1 O1.2 :U1,2:= L−1 1,1A1,2 O1.3 :L2,1:= A2,1U−1 1,1 O1.4 :A2,2:= A2,2−L2,1·U1,2 O1.5 :A2,2=L2,2U2,2 O2 :U1:2,3:4 := L−1 1:2,1:2A1:2,3:4 O3 :L3:4,1:2 := A3:4,1:2U−1 1:2,1:2 O4 :A3:4,3:4 := A3:4,3:4 −L3:4,1:2 ·U1:2,3:4 O5.1 :A3,3=L3,3U3,3 O5.2 :U3,4:= L−1 3,3A3,4 O5.3 :L4,3:= A4,3U−1 3,3 O5.4 :A4,4:= A4,4−L4,3·U3,4 O5.5 :A4,4=L4,4U4,4 Dense blocks. Assuming all blocks are dense, these operations correspond to three basic linear algebra building blocks (or computational kernels): •LU factorization (e.g., O1.1,O1.5 and O5.1); •triangular system solve (e.g., with unit lower triangular factor in O1.2 and O2; or upper triangular factor in O1.3 and O3); and •matrix-matrix multiplication (O1.4,O4, etc.). In the dense case, the triangular factors Land Uoverwrite the corresponding entries of Aso that, for example, in O2, the output U1:2,3:4 overwrites the input A1:2,3:4. Furthermore, the diagonal of the unit triangular matrix L only contains ones and it is not explicitly stored. Low-rank blocks. In the H-LU factorization, if any of the matrix blocks is represented in low-rank factorized form, the storage will have to be specialized (see section 2) and the operations involving this block will need to be performed in H-arithmetic. In typical H-matrix implementations, low-rank matrices are represented in the factorized form X=AB∗, where Aand Bhave only kcolumns, so 8
the rank of Xis bounded by k. In practice, kis significantly smaller than the dimensions of the original matrix X. The H2Lib packages use the following data type to store low-rank matrices: 1typedef struct rkmatrix { 2uint k; /* Maximal rank */ 3amatrix A; /* Left factor A */ 4amatrix B; /* Right factor B */ 5} Basic operations for low-rank matrices X∈Rn×minclude: •matrix-vector multiplication y:= Xz, performed using y:= Xz = A(B∗z); •multiplication of Xby an arbitrary matrix Z∈R`×n, using Y:= ZX = (ZA)B∗, •triangular system solve LY =Xor Y L =X; by applying forward or backward substitution to the kcolumns of Aor the krows of B, respectively. Adding two low-rank matrices poses a challenge, since the sum of two matrices X1=A1B∗ 1and X2=A2B∗ 2, of ranks k1and k2, may have a rank of k1+k2. Fortunately, in typical applications a low-rank approximation can be constructed by computing, e.g., a singular value decomposition of X1+X2=A1B∗ 1+A2B∗ 2=A1A2B1B2∗ and discarding small singular values. The same approach can be employed to convert an arbitrary matrix into a factorized low-rank matrix. From the point of view of peak floating-point performance, working with factorized low-rank matrices poses a challenge. Concretely, while the multiplication of two n×n-matrices requires 2n3operations, i.e., noperations for each coefficient transferred from main memory, only 2kn2operations are required if one of the factors is a factorized low-rank matrix, i.e., only k operations for each coefficient. Therefore we have to deal with the fact that the speed of operations involving low-rank matrices and, in consequence, H- matrices, is generally limited by the memory bandwidth, instead of by the floating-point throughput. 9
on the top-right block A1:2,3:4.) Correspondingly, the initial update (see the sequence of operations for the H-LU factorization in Section 3) O2 :U1:2,3:4 := L−1 1:2,1:2A1:2,3:4 can be further decomposed into the six suboperations: O2.1 :U1,3:= L−1 1,1A1,3, O2.2 :U1,4:= L−1 1,1A1,4, O2.3 :A2,3:= A2,3−L21 ·U1,3, O2.4 :A2,4:= A2,4−L21 ·U1,4 O2.5 :U2,3:= L−1 2,2A2,3,and O2.6 :U2,4:= L−1 2,2A2,4. In the application of nested parallelism to this scenario, we again assume that O1,O2,O3,O4,O5 are each annotated as a (coarse-grain) task, and the decompositions of O1,O2,O5 respectively produce the operations in O1.1– O1.5,O2.1–O2.6,O5.1–O5.5, each annotated as a (fine-grain) task. A rapid analysis of the new scenario reveals that, for example, the coarsegrain dependency O1→O2 boils down (among others) to the finer-grain cases O1.1→{O2.1,O2.2}, as the former operation (LU factorization) O1.1 :A1,1:= L1,1U1,1 yields the unit lower triangular factor L1,1required by the latter two operations (triangular solves) O2.1,O2.2. The problem with OmpSs and OpenMP 4.5 is that ensuring a correct result requires the introduction of a taskwait at the end of the code of O1 in order to guarantee a correct result. In contrast, the support for weak dependencies and early release in OmpSs-2 implies that (provided the operand L1:2,1:2 for O2 is annotated as weak,) the boundaries between the coarse-grain tasks O1 and O2 can be crossed and the execution of O2.1 and O2.2 can commence as soon as O1.1 is computed. In order to attain this effect, in OmpSs-2 we should annotate O2 as a task with weak operands (via the corresponding representants): 1#pragma oss task weakin ( RepL [0;S] ), weakinout ( RepB [0;S] ) 2void task_ltrsm ( int M, int P, double *L, int LDL , 3double *B, int LDB ) 16
while O2.1,O2.2 are both specified as tasks with strong operands: 1#pragma oss task in( L [0;M*M] ), inout ( B[0;M*P] ) 2void task_ltrsm ( int M, int P, double *L, int LDL , 3double *B, int LDB ) This simple example illustrates that the use of weak dependencies and early release can unleash a higher degree of task-parallelism during the execution of the H-LU factorization as, for example, the execution of O2.1,O2.2 can proceed in parallel with that of O1.2–O1.5; and O2.3,O2.4 in parallel with O1.2,O1.4,O1.5; see Figure 4. O1.2 O1.4 O1.5 O1.3 O1.1 O1 O2.2 O2.1 O2.3 O2.5 O2.6O2.4 O2 Figure 4: Data dependencies between tasks O1 and O2 of the blocked RL algorithm for the H-LU factorization. The black solid lines specify “internal” strong dependencies; the pink solid lines, strong dependencies crossing task boundaries; and the blue dashed line, the weak dependency. 6. Numerical Experiments In this section we first describe the problem setup and target architecture employed in our experiment. Next we analyze the concurrency of the parallel implementations of the code for the H-LU factorization in H2Lib. 6.1. Mathematical problems The usage of H-matrices often appears in the context of Boundary Element Methods (BEM) [15]. The reason for this is that the discretization of 17
boundary integral equations often yields matrices that are densely populated and have to be stored efficiently, where H-matrices come in handy. There is also a need of constructing efficient preconditioners for this type of equations, which can be carried out in H-arithmetic. In particular, in the experiments in this section we consider integral equations of the form ZΓ g(x, y)u(y)dy =f(x),for almost all x∈Ω, where Ω can be some d-dimensional bounded domain for d∈ {1,2,3}. By choosing suitable test-and-trial spaces Uhand Vh, equipped with some bases (ϕi), i ∈ I, and (ψj), j ∈ J , we can apply a Galerkin discretization and obtain a variational formulation of the kind ZΩ vh(x)ZΓ g(x, y)uh(y)dy dx =ZΩ vh(x)f(x)dx , for all vh∈ Vh. Employing finite element basis functions for these spaces we directly obtain a system of linear equations Gu =f, where all the entries of the matrix gij =ZΩ ϕi(x)ZΓ g(x, y)ψj(y)dy dx , for all i∈ I, j ∈ J , are non-zero. In particular, we consider the Laplace equation in d∈ {1,2,3}dimensions. In these cases the underlying kernel functions are g:Rd×Rd→R, g(x, y) = −log |x−y|:d= 1, −1 2πlog kx−yk2:d= 2, 1 4πkx−yk−1 2:d= 3. For the construction of low-rank blocks within our experiments, we choose the analytical method of tensor-interpolation [16], which is applicable in all dimensions. For the sake of lighter storage requirements and faster setup times of the H-LU, we further re-compress all low-rank blocks by a fast singular value decomposition (SVD) [14]. 18
6.2. Setup All the experiments in this section were performed using ieee 754 doubleprecision arithmetic, on a single node of the MareNostrum 4 system at Barcelona Supercomputing Center. The node contains two Intel Xeon Platinum 8160 sockets, with 24 cores per socket, and 96 Gbytes per of DDR4 RAM. In Turbo frequency mode (3.7 GHz), the theoretical peak performance for a single core is 59.2 GFLOPS (billions of floating-point operations per second) when using AVX2 instructions. This rate is reduced to 33.6 GFLOPS when using a single core running in the base frequency (2.1 GHz). At this point we note that the aggregated (theoretical) peak performance of this machine is a linear function of the operation frequency which, in turn, depends on the specific type of vector instructions that are executed (AVX, AVX2, AVX-512) and the number of active cores [17]. In the experiments we employed gcc 4.8.5, Intel MKL 2017.4 (with AVX2 instructions enabled), and OmpSs-2 (mcxx 2.1.0). 6.3. Matrix-matrix multiplication Our first experiment is designed to assess the performance of the implementation of the matrix-matrix multiplication routine (dgemm) in Intel MKL. This is relevant because it offers an upper bound of the actual performance that can be obtained from the H-LU factorization of a hierarchical matrix. This bound will be tight in case most of the blocks involved in the decomposition are dense and the fragmentation of the blocks implicit to the matrix hierarchy is not too fine-grained. Figure 5 reports the GFLOPS per core attained by Intel’s dgemm routine using 1, 4, 8,. . . , 24 cores (of a single socket) and square operands all of the same dimension b. (Note that the limit of the y-axis in this plot and all subsequent ones is fixed to 60, which basically corresponds to the theoretical peak performance with 1 core.) This experiment reveals two important aspects. First, the execution of the sequential instance of dgemm delivers 57.0 GFLOPS for a problem of order b= 150, and 58.9 GFLOPS for the largest problem dimension, b= 1000. These values represent 96.2% an 99.4% of the peak rate, respectively (when using AVX2 instructions). Thus, even for problems that are rather small, it is already possible to attain a large fraction of the peak performance when using a single thread. Second, as the number of threads/cores grows, the multi-threaded instance of dgemm requires considerably larger problems to attain a relevant fraction of the theoretical peak. (As argued earlier, the peak rate of this processor is “variable” because it 19
depends on the operation frequency and this parameter is constrained by the number of active cores [17].) Problem Size 0 200 400 600 800 1000 GFLOPS/core 0 10 20 30 40 50 60 Performance of dgemm 1 core 4 cores 8 cores 12 cores 16 cores 20 cores 24 cores Figure 5: Performance of the matrix-matrix multiplication routine in Intel MKL. 6.4. Basic parallel solutions The following experiment exposes the drawback of a parallelization that simply relies on a multi-threaded instance of the BLAS, providing initial evidence that a runtime-based approach can offer higher performance. In order to do so, we compare three different parallelization strategies applied to the H-LU factorization: •MKL extracts fine-grain loop-parallelism from within the BLAS kernels only. As argued in the introduction of this paper, this approach is rather appealing in that it requires a low programming effort. In particular, provided the sequential routine for the H-LU factorization already casts most of its operations in terms of BLAS, the code can be executed in parallel by simply linking in a multi-threaded instance of this library such as that in Intel MKL. The downside of this approach is that it constrains the parallelism that can be leveraged to that inside individual kernels, which may be insufficient if the number of cores is large. 20
•OpenMP aims to exploit loop-parallelism (like MKL) but targets a coarser-grain layer, by applying the parallelization to the loops present in the H-LU routine. To clarify this, consider for example a singlelevel hierarchical matrix that is decomposed into 8 ×8 blocks. After the factorization of the leading block of the matrix, this approach will compute in parallel the remaining 7+7 triangular system solves in the same column+row of the matrix; and next update the 7×7 blocks of the trailing submatrix in parallel. In summary, instead of extracting the parallelism from within the individual BLAS kernels, this approach targets the parallelism existing between independent BLAS kernels (tasks) comprised by a loop. •OmpSs discovers tasks dynamically and takes into account the dependencies among them to schedule their execution when appropriate; see Section 4. (This version does not include the advanced features supported by OmpSs-2.) To simplify the following analysis, we will employ a hierarchical matrix with a 2 ×2 recursive structure defined on the diagonal blocks. Concretely, starting with a hierarchical matrix of order n, we define a 2 ×2 partitioning, which is recursively applied to the inadmissible blocks until a minimum leafsize is reached; see Figure 6. This type of data structure appears, for example, in BEM with d= 1 as those described in subsection 6.1. For simplicity, we will also consider dense blocks only. With these consideration, the cost of the LU factorization of a hierarchical matrix of order nis (approximately) the standard 2n3/3 flops. Figure 7 reports the GFLOPS per core for the three different parallelization strategies described above. The results there correspond to a square H-matrix of dimension n= 10K, with r= 4, 5, 6 and 7 recursive partitionings applied to the inadmissible blocks until a minimum leafsize is reached. This implies that the smallest blocks on the diagonal are of order bmin = 10K/2r≈625, 312, 156 and 78, respectively. This experiment offers some interesting insights: •The performance of MKL greatly benefits from problems with large block sizes, which is consistent with the trends in the GFLOPS rates observed for the multi-threaded instance of Intel’s dgemm in the previous experiment. This option is competitive with the task-parallel 21
Figure 6: Hierarchical structures of the H-matrices employed in the evaluation of the parallelization strategies (with 5 recursive partitionings of the diagonal blocks; note that the colors remark the amount of levels defined in each structure: 7, 6, 5 and 4 respectively). OmpSs-based routine when the number of cores is reduced or partitioning features large diagonal blocks (r= 4, bmin = 625). •The parallel performance of OpenMP is practically negligible as the GFLOPS per core decrease linearly with the number of cores. This is not totally a surprise as, due to the 2×2 organization of the H-matrix, the operations that can be performed independently are reduced to the two triangular system solves at each partitioning. •When the number of cores is small, the OmpSs-based parallelization attains mild GFLOPS rates. Here, the coarse-grain partitioning of the 22
blocks and the existence of synchronization points constrain the degree of parallelism that can be exploited and limit the performance of this approach when the number of cores is large. Number of cores 1 2 4 8 12 GFLOPS/core 0 10 20 30 40 50 60 bmin=78 MKL OpenMP OmpSs Number of cores 1 2 4 8 12 GFLOPS/core 0 10 20 30 40 50 60 bmin=156 MKL OpenMP OmpSs Number of cores 1 2 4 8 12 GFLOPS/core 0 10 20 30 40 50 60 bmin=312 MKL OpenMP OmpSs Number of cores 1 2 4 8 12 GFLOPS/core 0 10 20 30 40 50 60 bmin=625 MKL OpenMP OmpSs Figure 7: Performance of basic parallelization strategies applied to an H-matrix of order n= 10K, with dense blocks, and a recursive 2 ×2 hierarchical partitioning of the inadmissible blocks; see Figure 6. To complete the analysis of this experiment, we remark that a comparative analysis of the GFLOPS observed in these executions with those of dgemm is delicate. In particular, the execution using a single core can be expected to set the processor to operate on a higher frequency than a parallel multi-threaded execution using several cores. Unfortunately, the exact frequency is difficult to know as it depends on the number of cores as well as the arithmetic intensity of the operations (and it can even vary at execution time). 23
6.5. Scalability of task-parallel routines Our next experiments aim to demonstrate the benefits that the WD+ER (weak dependency and early release) mechanism exerts on the scalability of the task-parallel codes based on OmpSs-2. For this purpose, we next conduct an analysis of the strong and weak scalabilies, using a complete socket (24 cores) and the same hierarchical matrix, with a 2 ×2 recursive structure defined on the diagonal blocks and dense blocks only, employed in the previous study. In the following analysis of strong scalability, we set the problem dimension to three different values, n=10K, 15K and 30K, and progressively increase the amount of cores up to 24 while measuring the GFLOPS per core. In this type of experiment, we can expect that the GFLOPS/core rates eventually drop as the problem becomes too small for the volume of resources that are employed to tackle it. Figure 8 confirms that this is the case for both implementations, which exploit/do not exploit the new features in OmpSs-2 (lines labeled as with WD+ER and w/out WD+ER, respectively). In addition, the results also show that the exploitation of WD+ER, made possible by OmpSs-2, offers a GFLOPS/core rate that clearly outperforms that of the implementation that is oblivious of these options. For the analysis of weak scalability, we utilize a problem of dimension n×n that grows proportionally to the number of cores c, so that the ratio n2/c = 15K×15K holds while cgrows to 24. As the problem size per core is constant, we can expect that the GFLOPS/core remains stable, showing the possibility of addressing larger problems by increasing proportionally the amount of resources up to a certain point. (This is not totally exact, as the cost of the factorization for dense matrices grows cubically with the problem dimension while, in the conditions set for this experiment, the amount of resources only does so quadratically.) Unfortunately, the results of this experiment reveal that the weak scalability of both algorithms suffers an important drop as the number of cores is increased, though in the variant equipped with WD+ER this occurs in the transition from 8 to 12 cores while the implementation that does not exploit this mechanism the gap is visible already in the increase from 4 to 8 cores. There are two aspects to take into account when considering the GFLOP- S/core rates observed in the strong scaling analysis and, especially, the weak scaling counterpart. The first one refers to the CPU frequency, which decreases with the number of cores which are active (see [17] and Figure 5) and affect the performance of the task-parallel routines, reducing it with the 24
Number of cores 1 4 8 12 16 20 24 GFLOPS/core 0 10 20 30 40 50 60 Strong Scalability 10K w/out WD+ER 10K with WD+ER 15K w/out WD+ER 15K with WD+ER 30K w/out WD+ER 30K with WD+ER Figure 8: Strong scalability of the advanced parallelization strategies applied to H-matrices of order n= 10K, 15K and 30K (bmin =156, 234 and 234, respectively), with dense blocks, and a recursive 2 ×2 hierarchical partitioning of the inadmissible blocks; see Figure 6. number of cores. The second one is a consideration of the structure of the hierarchical matrix employed in these experiments (see Figure 6). In particular, when all the blocks are dense, and the matrix is decomposed into a task per block in this partitioning, the result is a problem where a reduced collection of coarse-grain tasks concentrate a large fraction of the flops. This effect is exacerbated with the problem order (n) and its negative effect is more visible when the number of cores is increased because the task-parallel algorithms confront then a suboptimal scenario consisting of a very reduced number of tasks (little task-parallelism) of (very) coarse-grain operations. 6.6. Parallelism of task-parallel routines with low-rank cases Our final round of experiments assesses the performance of the WD+ER (weak dependency and early release) mechanism using several BEM cases, of dimensions d=1, 2 and 3, involving low-rank blocks. The “sparsity” pattern of these blocks is controlled via a parameter ηthat we set to four different values, 0.25, 0.5, 1.0 and 2.0. The structure of these cases is illustrated in Figure 10. Table 1 reports the acceleration factors (or speed-ups) attained by the task-parallel codes with respect to the corresponding sequential code/case, 25