Accelerating BST Methods for Model Reduction with Graphics Processors
Abstract
Model order reduction of dynamical linear time-invariant system appears in many scientific and engineering applications. Numerically reliable SVD-based methods for this task require O(n3) floating-point arithmetic operations, with n being in the range 103 − 105 for many practical applications. In this paper we investigate the use of graphics processors (GPUs) to accelerate model reduction of large-scale linear systems via Balanced Stochastic Truncation, by off-loading the computationally intensive tasks to this device. Experiments on a hybrid platform consisting of state-of-the-art general-purpose multi-core processors and a GPU illustrate the potential of this approach.
Full text
Accelerating BST Methods for Model Reduction with Graphics Processors Peter Benner1, Pablo Ezzatti2, Enrique S. Quintana-Ort´ı3, and Alfredo Rem´on3 1Max Planck Institute for Dynamics of Complex Technical Systems (Magdeburg, Germany) [email protected] 2Centro de C´alculo-Instituto de Computaci´on, Universidad de la Rep´ublica (Montevideo, Uruguay) [email protected] 3Depto. de Ingenier´ıa y Ciencia de Computadores, Universidad Jaume I (Castell´on, Spain) {quintana,remon}@icc.uji.es Abstract Model order reduction of dynamical linear time-invariant system appears in many scientific and engineering applications. Numerically reliable SVD-based methods for this task require 𝒪(𝑛3) floating-point arithmetic operations, with 𝑛being in the range 103−105for many practical applications. In this paper we investigate the use of graphics processors (GPUs) to accelerate model reduction of large-scale linear systems via Balanced Stochastic Truncation, by off-loading the computationally intensive tasks to this device. Experiments on a hybrid platform consisting of state-of-the-art general-purpose multi-core processors and a GPU illustrate the potential of this approach. Key words: Model reduction, linear dynamical systems, Lyapunov equations, SVD-based methods, GPUs. 1 Introduction Model order reduction is an important numerical tool to reduce the time and cost required for the design of optimal controllers in many industrial processes where dynamics can be modeled by a linear time-invariant (LTI) system of the form: ˙𝑥(𝑡) = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡), 𝑡 > 0, 𝑥(0) = 𝑥0, 𝑦(𝑡) = 𝐶𝑥(𝑡) + 𝐷𝑢(𝑡), 𝑡 ≥0.(1) Here, 𝑥(𝑡) contains the states of the system, with 𝑥0∈ℝ𝑛the initial state, 𝑢(𝑡)∈ ℝ𝑚and 𝑦(𝑡)∈ℝ𝑝contain the inputs and outputs, respectively, and 𝐴∈ℝ𝑛×𝑛, 𝐵∈ℝ𝑛×𝑚,𝐶∈ℝ𝑝×𝑛,𝐷∈ℝ𝑝×𝑚. The system in (1) can also be described by the associated transfer function matrix (TFM) 𝐺(𝑠) = 𝐶(𝑠𝐼𝑛−𝐴)−1𝐵+𝐷. A particularly important property is that the number of states (also known as the
state-space dimension or the order) of the system, 𝑛, is in general much larger than 𝑚and 𝑝. The goal of model reduction is to find a reduced-order LTI system, ˙ ˆ𝑥(𝑡) = ˆ 𝐴ˆ𝑥(𝑡) + ˆ 𝐵𝑢(𝑡), 𝑡 > 0,ˆ𝑥(0) = ˆ𝑥0, ˆ𝑦(𝑡) = ˆ 𝐶ˆ𝑥(𝑡) + ˆ 𝐷𝑢(𝑡), 𝑡 ≥0,(2) of order 𝑟, with 𝑟≪𝑛, and associated TFM ˆ 𝐺(𝑠) = ˆ 𝐶(𝑠𝐼𝑛−ˆ 𝐴)−1ˆ 𝐵+ˆ 𝐷which approximates the dynamics of the original system defined by 𝐺(𝑠). The reducedorder realization (2) can then replace the original model of order 𝑛in subsequent simulations or processes, thus simplifying these tasks considerably. Model order reduction of large-scale systems appears, e.g., in thermal, thermo-mechanical, electro-mechanical and acoustic finite element models [1]. We consider a system to be large-scale if 𝑛∼ 𝒪(1,000) − 𝒪(100,000), while, often, 𝑚, 𝑝 ∼ 𝒪(10) − 𝒪(100). The numerical method for model order reduction considered in this paper is based on the so-called state-space truncation approach and requires, at an initial stage, the solution of a Lyapunov and a Riccati equation. The reduced-order system is then obtained using a variant of the balanced stochastic truncation (BST) method [2], which only requires dense linear algebra computations. Although there exist several other approaches for model order reduction (see, e.g., [1,3] and the references therein), those are specific for a certain subset of problems and often do not possess relevant properties such as error bounds, preservation of stability and passivity, or phase information. A comparison of the numerical properties of SVD-based methods (as Balanced Stochastic Truncation, BST) and Krylov subspace methods can be found in [1]. The Lyapunov and Riccati equations are solved in our algorithms via the matrix sign function, which yields a computational cost for the global model order reduction procedure of 𝒪(𝑛3) flops (floating-point arithmetic operations). This calls for the application of high performance computing in the reduction of models with 𝑛in the order of thousands or larger. Recent work on the implementation of the BLAS specification and some relevant linear algebra operations included in LAPACK [4,5,6,7] has demonstrated the potential of graphics processors (GPUs) to yield high performance for the execution of dense linear algebra operations, specially if they can be cast in terms of matrix-matrix products. In [8] we built upon these works to deal with the solution of the standard Lyapunov equation on a GPU. Here, we extend this work by tackling the different stages in BST methods for model reduction of linear systems, namely, the solution of the Lyapunov and Riccati equations, the computation of the SVD, and other auxiliary computations. The target architecture is a hybrid platform consisting of a general-purpose multicore processor and a GPU. We exploit these two resources by designing a hybrid numerical algorithm for model order reduction that performs fine-grain computations on the CPU while off-loading computationally intensive operations to the GPU. The rest of the paper is structured as follows. In Section 2 we briefly review the BST method for model order reduction, including the Lyapunov solver, the
sign function-based Riccati solver and the remaining stages of the method. In Section 3 high performance implementations for a hybrid CPU-GPU platform are described. In Section 4 we present experimental results that expose the parallelism attained by the numerical algorithms on a platform consisting of two Intel QuadCore processors connected to an NVIDIA Tesla C1060 GPU. Finally, in Section 5 we provide a few concluding remarks and future lines of work. 2 Model Reduction methods based on SVD Relative error methods attempt to minimize the relative error ∥𝛥𝑟∥∞, defined implicitly by 𝐺−ˆ 𝐺=𝐺𝛥𝑟. Among these, BST and its variants are particularly popular [9,10,11]. Due to their high computational cost, BST methods have been used only for problems of moderate dimension, i.e., models of state-space dimension in the order of hundreds. The implementation included in the Subroutine Library in Control Theory – SLICOT1[12], available for MATLAB R and Fortran 77, made feasible to target systems with a few thousands of state-space variables on nowadays standard desktop computers, but larger problems remain un-affordable, unless a cluster of computers and a message-passing library as PLiCMR [13] is employed. BST is a technique where the reduced order model is obtained truncating a balanced stochastic realization. Such a realization is obtained as follows. Define 𝛷(𝑠) = 𝐺(𝑠)𝐺𝑇(−𝑠), and let 𝑊be a square minimum phase right spectral factor of 𝛷, i.e., 𝛷(𝑠) = 𝑊𝑇(−𝑠)𝑊(𝑠). As 𝐷has full row rank, 𝐸=𝐷𝐷𝑇is positive definite and a minimal state-space realization (𝐴𝑊, 𝐵𝑊, 𝐶𝑊, 𝐷𝑊) of 𝑊is given by (see [14,15]) 𝐴𝑊=𝐴, 𝐵𝑊=𝐵𝐷𝑇+𝑊𝑐𝐶𝑇, 𝐶𝑊=𝐸−1 2(𝐶−𝐵𝑇 𝑊𝑋𝑊), 𝐷𝑊=𝐸1 2.(3) Here, 𝑊𝑐is the controllability Gramian of 𝐺(𝑠) given by the solution of the Lyapunov equation 𝐴𝑊𝑐+𝑊𝑐𝐴𝑇+𝐵𝐵𝑇= 0 (4) while 𝑊𝑜is the observability Gramian of 𝑊(𝑠) obtained as the stabilizing solution of the algebraic Riccati equation (ARE) 0 = (𝐴−𝐵𝑊𝐸−1𝐶)𝑇𝑊𝑜+𝑊𝑜(𝐴−𝐵𝑊𝐸−1𝐶) + 𝑊𝑜𝐵𝑊𝐸−1𝐵𝑇 𝑊𝑊𝑜+ 𝐶𝑇𝐸−1𝐶. (5) In the following subsections we revisit the sign function methods for the solution of Lyapunov and Riccati equations introduced in [16] and [17] respectively. For the solution of the Lyapunov equation, the algorithm introduced in [8] has demonstrated to be highly efficient on hybrid architectures equipped with a GPU. This Lyapunov solver provides a low-rank approximation to the full-rank factor of the solution matrix. 1Available from http://www.slicot.org.
2.1 Solution of the Lyapunov equation The matrix sign function was introduced in [17] as an efficient tool to solve stable (standard) Lyapunov equations. The variant of the Newton iteration method for the matrix sign function in Algorithm CECLNC [16] can be employed for the solution of a Lyapunov equation (like that in (4)). Algorithm CECLNC: 𝐴0←𝐴,˜ 𝑆0←𝐵𝑇 𝑘←0 repeat Compute the rank-revealing QR (RRQR) decomposition 1 √2𝑐𝑘[˜ 𝑆𝑘, 𝑐𝑘˜ 𝑆𝑘𝐴−𝑇 𝑘]=𝑄𝑠[𝑈𝑠 0]𝛱𝑠 ˜ 𝑆𝑘+1 ←𝑈𝑠𝛱𝑠 𝐴𝑘+1 ←1 √2(𝐴𝑘/𝑐𝑘+𝑐𝑘𝐴−1 𝑘) 𝑘←𝑘+ 1 until ∥𝐴𝑘−𝐼∥1< 𝜏𝑙∥𝐴𝑘∥1 The number of columns of factor ˜ 𝑆is doubled at each iteration and, in consequence, the computational and storage costs associated with its update grow at each iteration. To moderate this increase, and the number of columns in the factors, an RRQR factorization is computed at each step. This approach yields important gains when the number of iterations that are required for convergence is large. Note that 𝑄𝑠is not accumulated as it is not needed in further computations. This reduces the cost of the RRQR significantly. For simplicity, we do not detail this compression procedure; see [18]. On convergence, after 𝑗iterations, ˜ 𝑆=1 √2˜ 𝑆𝑗, of dimension ˜ 𝑘𝑐×𝑛, is the full (row-)rank approximation of 𝑆, so that 𝑊𝑐=𝑆𝑇𝑆≈˜ 𝑆𝑇˜ 𝑆. The Newton iteration for the sign function method usually presents a fast convergence rate, which is ultimately quadratic. Initial convergence can be accelerated using several techniques. In our case, we employ a scaling factor defined by the parameter 𝑐𝑘=√∥𝐴𝑘∥/∥𝐴−1 𝑘∥. In the convergence test, 𝜏𝑙is a tolerance threshold for the iteration that is usually set as a function of the problem dimension and the machine precision 𝜀. In particular, to avoid stagnation in the iteration, we set 𝜏𝑙=𝑛⋅√𝜀and perform one or two additional iteration steps after the stopping criterion is satisfied. Due to the quadratic convergence of the Newton iteration, this is usually enough to reach the attainable accuracy. The RRQR decomposition can be obtained by means of the traditional QR factorization with column pivoting [18] plus a reliable rank estimator.
2.2 Solution of the Riccati equation The solution of an Algebraic Riccati Equation (ARE) of the form 𝐹𝑇𝑋+𝑋𝐹 −𝑋𝐺𝑋 +𝑄= 0,(6) can be obtained from the stable invariant subspace of the Hamiltonian matrix defined in [19] 𝐻=[𝐹 𝐺 −𝑄−𝐹𝑇].(7) This solution can be obtained computing the matrix sign function of 𝐻[17]: sign(𝐻) = 𝑌=[𝑌11 𝑌12 𝑌21 𝑌22 ],(8) and then, solving the overdetermined system [𝑌11 𝑌12 +𝐼𝑛]𝑋=[𝐼𝑛−𝑌21 −𝑌11 ](9) (e.g., applying the least squares method). Algorithm GECRSG summarizes the steps to solve an ARE with this method. Algorithm GECRSG: 𝐻0←[𝐹 𝐺 −𝑄−𝐹𝑇] 𝑘←0 repeat 𝐻𝑘+1 ←1 2(𝐻𝑘/𝑑𝑘+𝑑𝑘𝐻−1 𝑘) until ∥𝐻𝑘+1 −𝐻𝑘∥1< 𝜏𝑟∥𝐻𝑘∥1 Solve [𝑌11 𝑌12 +𝐼𝑛]𝑋=[𝐼𝑛−𝑌21 −𝑌11 ] The scaling factor 𝑑𝑘and the tolerance threshold 𝜏𝑟can be defined here following the ideas presented for 𝑐𝑘and 𝜏𝑙, respectively, in the previous subsection. 3 High performance implementation on a hybrid architecture In this section, we describe an efficient implementation of the BST model order reduction method, specially designed for hybrid platforms composed of a
multicore CPU connected to a single GPU. The objective of the hybrid implementation is to reduce the computational time of the BST method, executing each operation on the most convenient architecture and reducing the amount of data transfers between the two components. Specifically, the most expensive computations are executed on the GPU while the fine-grain operations are executed on the CPU. 3.1 Hybrid implementation of the Lyapunov solver The most time consuming operation of Algorithm CECLNC is the update of 𝐴𝑘+1. This is due to the large dimension of 𝐴and the significant computational cost of the matrix inversion. The hybrid algorithm to accelerate the solution of this equation proceeds as follows. At the beginning of each iteration, the CPU transfers matrix 𝐴𝑘to the GPU. Then, the CPU and the GPU cooperate in the inversion of matrix 𝐴𝑘, which is returned to the CPU upon completion. The rest of the operations are performed on the CPU since they require a minor computational effort and can be efficiently executed on a multicore processor, e.g. invoking parallel implementations of BLAS and LAPACK to compute the linear algebra operations or using a simple OpenMP-based parallelization in other cases. The inversion algorithm is based on the Gauss-Jordan elimination method [20], since this is a highly parallel algorithm. The implementation includes some performance-enhancing techniques, as the processing by blocks to exploit the hierarchical organization of the memory, hybrid and concurrent computing (CPU + GPU) to increment the resource utilization, look-ahead techniques [21] to avoid bottlenecks, padding to accelerate the memory accesses on the GPU, and multilevel blocks strategies to improve throughput of both devices. 3.2 Hybrid implementation of the Riccati solver This stage can be divided into three steps: –First, it is necessary to build matrix 𝐻performing some matrix-matrix multiplications (see equations (3)-(5)). As the dimensions of the matrices involved in these operations are moderate, the related computational cost is moderate as well. For this reason, and with the aim to reduce data transfers overheads, those operations are performed on the CPU. –Second, the sign function for the extended matrix (7) is computed. The proposal is based on the efficient matrix inversion kernel described in subsection 3.1 and the utilization of OpenMP to accelerate the matrix addition and matrix norm evaluation performed on the CPU; see Algorithm GECRSG. Note that the solution of the Riccati equation via this solver involves matrices which are twice as big as those that appear in the sign function solver for the Lyapunov equation. –Finally, the overdetermined system is solved. To do so, a multi-thread version of routine GEQP3 (included in LAPACK) is employed. Other minor operations are also executed on the CPU and parallelized using OpenMP.
3.3 Remaining stages of the BST method Once the low rank factor from the controllability gramian (𝑆) and the observability gramian (𝑊𝑜) have been computed from the solution of the Lyapunov and the Riccati equations respectively, only some minor operations with moderate computational effort are required to obtain the reduced order model. The main computations in this step include some matrix-matrix products involving matrices of relatively small dimension. All these operations require a moderate number of arithmetic operations and, therefore, can be efficiently computed on the CPU using BLAS. Computing them on the CPU avoids data transfers and the associated overhead. 4 Numerical Experiments In this section we evaluate the parallel performance of the BST model order reduction method. The target platform consists of two Intel Xeon QuadCore E5410 processors (2.33GHz) with 8GB of RAM connected to an Nvidia Tesla C1060 via a PCI-e bus. Multi-threaded implementation of BLAS, from the Intel MKL library (version 10.2) for the general-purpose processor and from Nvidia CUBLAS (version 3.2) for the GPU are used. We compare three different implementations: a sequential one (bst scpu) that is executed on a single CPU core (used as the reference implementation), a parallel multi-thread routine (bst mtcpu) that exploits all the cores from the CPU, and a hybrid CPU-GPU implementation (bst hyb) that executes operations concurrently on the GPU and the CPU cores. We employ double precision arithmetic for the solution of two instances of the STEEL Imodel reduction problem [22], extracted from the Oberwolfach benchmark collection (University of Freiburg)2. This model arises in the manufacturing process of steel profiles. The goal is to design a control that yields moderate temperature gradients when the rail is cooled down. The mathematical model corresponds to the boundary control for a 2-D heat equation. A finite element discretization, followed by adaptive refinement of the mesh, results in the example in this benchmark. The problem dimensions depend of the discretization mesh; the two versions employed are STEEL I1357 with 𝑛= 1,357, 𝑚= 7, 𝑝= 6; and STEEL I5177 with 𝑛= 5,177, 𝑚= 7, 𝑝= 6. Table 1 summarizes the results (in seconds) obtained with all the implementations evaluated. The execution time dedicated to solve the Lyapunov equation is shown in column 2; columns 3, 4 and 5 report the time required to initialize matrix 𝐻, compute sign(𝐻) and solve the overdetermined system, respectively; column 6 displays the accumulated time. All the times given in Table 1 include the costs to perform all the necessary CPU-GPU data transfers. Note that most of the time is dedicated to compute the solution of the Riccati equation, in particular the computation of sign(𝐻) (column 4). The rest of the time is basically spent in the Lyapunov equation solver. A careful study of these 2http://www.imtek.de/simulation/benchmark/.
Implementation Lyapunov 𝐻init. sign(𝐻) System solver Total solver time(s) STEEL I1357 bst scpu 7.74 0.10 118.15 3.23 129.22 bst mtcpu 1.68 0.05 22.34 0.57 24.64 bst hyb 9.46 0.05 10.93 0.57 21.01 STEEL I5177 bst scpu 334.16 1.52 6404.65 325.34 7065.67 bst mtcpu 63.75 0.86 1127.87 25.05 1217.53 bst hyb 26.82 0.78 292.93 24.92 345.48 Table 1. Execution time (in secs.) of the different steps of the BST method for the STEEL Iproblem. two operations demonstrates that the computational effort is concentrated in the calculation of matrix inverses. This operation is accelerated in the bst mtcpu implementation using multi-thread codes. The bst hyb variant improves the parallelization of the matrix inversion procedure using the Gauss-Jordan elimination method, which is more suitable for its execution on parallel architectures, and off-loading part of the computations to the GPU. The times reported for the STEEL I1357 instance show a notable benefit from the usage of the multicore (bst mtcpu) and the hybrid (bst hyb) implementation, which are respectively 5 and 6 times faster than the sequential implementation. From the results obtained for STEEL I5177 we can conclude that these differences are even higher for larger problems. In this case, bst mtcpu is nearly 6 times faster than bst scpu, while bst hyb is more than 20 times faster. The reason is that larger problems present a higher inherent parallelism which can be leveraged by the massively parallel architecture of the GPU. 5 Concluding Remarks We have presented two high performance parallel implementations for the BST method for model reduction. Variant bst mtcpu is optimized for its execution on a multicore CPU, while bst hyb targets hybrid platforms composed of a CPU and a GPU. bst hyb exploits the capabilities of both architectures, the multicore CPU and the many-core GPU, yielding a high performance implementation of the BST model reduction technique. Two levels of parallelism are exploited in this implementation: at the inner level, multithread lineal algebra kernels included in the BLAS library (MKL and CUBLAS) are employed to compute the most time-consuming linear algebra operations; at the outer level, operations proceed concurrently in both architectures, overlapping computations on the CPU and the GPU.
Experimental results on a platform consisting of a state-of-the-art generalpurpose multi-core processor and a pre-Fermi GPU show that model order reduction of large-scale linear systems can be significantly accelerated using this kind of platforms. The promising results obtained encourage us to further improve the developed implementations. On-going and future work include: –Exploit the use of multiple GPUs to further reduce the computational time and increase the dimension of the affordable problems. –Evaluate the use of mixed precision techniques that allow to perform most of the computations in single precision arithmetic. References 1. A. Antoulas, Approximation of Large-Scale Dynamical Systems. Philadelphia, PA: SIAM Publications, 2005. 2. P. Benner, E. S. Quintana-Ort´ı, and G. Quintana-Ort´ı, “Efficient numerical algorithms for balanced stochastic truncation,” Internat. J. in Applied Mathematics and Computer Science, vol. 1, no. 1, pp. 15–21, 2005. 3. R. Freund, “Reduced-order modeling techniques based on Krylov subspaces and their use in circuit simulation,” in Applied and Computational Control, Signals, and Circuits, B. Datta, Ed. Boston, MA: Birkh¨auser, 1999, vol. 1, ch. 9, pp. 435–498. 4. V. Volkov and J. Demmel, “LU, QR and Cholesky factorizations using vector capabilities of GPUs,” EECS Department, University of California, Berkeley, Tech. Rep. UCB/EECS-2008-49, May 2008. [Online]. Available: http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-49.html 5. P. Bientinesi, F. D. Igual, D. Kressner, and E. S. Quintana-Ort´ı, “Reduction to condensed forms for symmetric eigenvalue problems on multi-core architectures,” in Proceedings of the 8th International Conference on Parallel Processing and Applied Mathematics – PPAM’09, ser. Lecture Notes in Computer Science, vol. 6067. Springer, 2010, pp. 387–395. 6. S. Barrachina, M. Castillo, F. D. Igual, R. Mayo, E. S. Quintana-Ort´ı, and G. Quintana-Ort´ı, “Exploiting the capabilities of modern GPUs for dense matrix computations,” Concurrency and Computation: Practice and Experience, vol. 21, pp. 2457–2477, 2009. 7. H. Ltaif, S. Tomov, R. Nath, P. Du, and J. Dongarra, “A scalable high performance cholesky factorization for multicore with gpu accelerators,” University of Tennessee, LAPACK Working Note 223, 2009. 8. P. Benner, P. Ezzatti, E. S. Quintana-Ort´ı, and A. Rem´on, “Using hybrid CPUGPU platforms to accelerate the computation of the matrix sign function,” in Euro-Par 2009, Parallel Processing - Workshops, ser. Lecture Notes in Computer Science, H.-X. Lin, M. Alexander, M. Forsell, A. Kn¨upfer, R. Prodan, L. Sousa, and A. Streit, Eds. Springer-Verlag, 2009, no. 6043, pp. 132–139. 9. U. Desai and D. Pal, “A transformation approach to stochastic model reduction,” IEEE Trans. Automat. Control, vol. AC–29, pp. 1097–1100, 1984. 10. M. Green, “Balanced stochastic realization,” Linear Algebra Appl., vol. 98, pp. 211–247, 1988.