Example: marketing

Anatomy of High-Performance Matrix Multiplication

Anatomy of High-Performance MatrixMultiplicationKAZUSHIGE GOTOThe University of Texas at AustinandROBERT A. VAN DE GEIJNThe University of Texas at AustinWe present the basic principles which underlie the High-Performance implementation of the Matrix - Matrix Multiplication that is part of the widely used GotoBLAS library. Design decisions arejustified by successively refining a model of architectures with multilevel memories. A simple buteffective algorithm for executing this operation results. Implementations on a broad selection ofarchitectures are shown to achieve near-peak and Subject Descriptors: [Mathematical Software]: EfficiencyGeneral Terms: Algorithms;PerformanceAdditional Key Words and Phrases: linear algebra, Matrix Multiplication , basic linear algebrasubprogrms1.

Comparison of the matrix-matrix multiplication described in this paper with various other ... according to the above table. The exception to this convention is the gepdot operation, which is a generalization of the dot product. encountered as part of algorithms for other linear algebra operations. For example,

Tags:

  Table, Matrix, Multiplication, Multiplication matrix

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Anatomy of High-Performance Matrix Multiplication

1 Anatomy of High-Performance MatrixMultiplicationKAZUSHIGE GOTOThe University of Texas at AustinandROBERT A. VAN DE GEIJNThe University of Texas at AustinWe present the basic principles which underlie the High-Performance implementation of the Matrix - Matrix Multiplication that is part of the widely used GotoBLAS library. Design decisions arejustified by successively refining a model of architectures with multilevel memories. A simple buteffective algorithm for executing this operation results. Implementations on a broad selection ofarchitectures are shown to achieve near-peak and Subject Descriptors: [Mathematical Software]: EfficiencyGeneral Terms: Algorithms;PerformanceAdditional Key Words and Phrases: linear algebra, Matrix Multiplication , basic linear algebrasubprogrms1.

2 INTRODUCTIONI mplementing Matrix Multiplication so that near-optimal performance is attainedrequires a thorough understanding of how the operation must be layered at themacro level in combination with careful engineering of High-Performance kernelsat the micro level. This paper primarily addresses the macro issues, namely howto exploit a High-Performance inner-kernel , more so than the the micro issuesrelated to the design and engineering of that inner-kernel .In [Gunnels et al. 2001] a layered approach to the implementation of matrixmultiplication was reported. The approach was shown to optimally amortize therequired movement of data between two adjacent memory layers of an architecturewith a complex multi-level memory. Like other work in the area [Agarwal et ; Whaley et al.]

3 2001], that paper ([Gunnels et al. 2001]) casts computation interms of an inner-kernel that computesC:= AB+Cfor somemc kcmatrix Athat is stored contiguously in some packed format and fits in cache , the model for the memory hierarchy that was used is unrealistic inAuthors addresses: Kazushige Goto, Texas Advanced Computing Center, The University of Texasat Austin, Austin, TX Robert A. van de Geijn, Department ofComputer Sciences, The University of Texas at Austin, Austin, TX to make digital/hard copy of all or part of this material without fee for personalor classroom use provided that the copies are not made or distributed for profit or commercialadvantage, the ACM copyright/server notice, the title of the publication, and its date appear, andnotice is given that copying is by permission of the ACM, Inc.

4 To copy otherwise, to republish,to post on servers, or to redistribute to lists requires prior specific permission and/or a 20YY ACM 0098-3500/20YY/1200-0001 $ Transactions on Mathematical Software, Vol. V, No. N, Month 20YY, Pages 1 Kazushige Goto and Robert A. van de Geijnat least two ways: It assumes that this inner-kernel computes with a Matrix Athat resides in thelevel-1 (L1) cache. It ignores issues related to the Translation Look-aside Buffer (TLB).The current paper expands upon a related technical report [Goto and van de Geijn2002] which makes the observations that The ratio between the rate at which floating point operations (flops) can beperformed by the floating point unit(s) and the rate at which floating pointnumbers can be streamed from the level-2 (L2) cache to registers is typicallyrelatively small.

5 This means that Matrix Acan be streamed from the L2 cache. It is often the amount of data that can be addressed by the TLB that is thelimiting factor for the size of A. (Similar TLB issues were discussed in [Strazdins1998].)In addition, we now observe that There are in fact six inner-kernels that should be considered for building blocks forhigh-performance Matrix Multiplication . One of these is argued to be inherentlysuperior over the others. (In [Gunnels et al. 2001; Gunnels et al. 2005] three ofthese six kernels were identified.)Careful consideration of all these observations underlie the implementation of thedgemmBasic Linear Algebra Subprograms (BLAS) routine that is part of thewidely used GotoBLAS library [Goto 2005].In Fig. 1 we preview the effectiveness of the techniques.

6 In those graphs we reportperformance of our implementation as well as vendor implementations (Intel s MKL( ) and IBM s ESSL ( ) libraries) and ATLAS [Whaley and Dongarra 1998]( ) on the Intel Pentium4 Prescott processor, the IBM Power 5 processor, andthe Intel Itanium2 processor1It should be noted that the vendor implementationshave adopted techniques very similar to those described in this paper. It is impor-tant not to judge the performance of Matrix - Matrix Multiplication in isolation. It istypically a building block for other operations like the level-3 BLAS ( Matrix -matrixoperations) [Dongarra et al. 1990; K agstr om et al. 1998] and LAPACK [Andersonet al. 1999]. How the techniques described in this paper impact the implementationof level-3 BLAS is discussed in [Goto and van de Geijn 2006].

7 This paper attempts to describe the issues at a high level so as to make it ac-cessible to a broad audience. Low level issues are introduced only as needed. InSection 2 we introduce notation that is used throughout the remainder of the pa-per. In Section 3 a layered approach to implementing Matrix Multiplication isintroduced. High-Performance implementation of the inner-kernels is discussed inSection 4. Practical algorithms for the most commonly encountered cases of matrixmultiplication are given in Section 5. In Section 6 we give further details that areused in practice to determine parameters that must be tuned in order to optimizeperformance. Performance results attained with highly tuned implementations on1 All libraries that were timed use assembly-coded inner-kernels (including ATLAS).

8 Compileroptions-fomit-frame-pointer -O3 -funroll-all-loopswere Transactions on Mathematical Software, Vol. V, No. N, Month of High-Performance Matrix Multiplication 3020040060080010001200140016001800200001 234567m=nGFLOPS/secPentium4 ( GHz)dgemm (GOTO)dgemm (MKL)dgemm (ATLAS)020040060080010001200140016001800 200001234567m=nGFLOPS/secPower 5 ( GHz)dgemm (GOTO)dgemm (ESSL)dgemm (ATLAS)020040060080010001200140016001800 20000123456m=nGFLOPS/secItanium2 ( GHz)dgemm (GOTO)dgemm (MKL)dgemm (ATLAS)Fig. 1. Comparison of the Matrix - Matrix Multiplication described in this paper with various otherimplementations. See Section 7 for details regarding the different architectures are given in Section 7. Concluding comments can be found inthe final NOTATIONThe partitioning of matrices is fundamental to the description of Matrix multipli-cation algorithms.

9 Given anm nmatrixX, we will only consider partitioningsofXinto blocks of columns and blocks of rows:X=(X0X1 XN 1)= X0 XM 1 ,whereXjhasnbcolumns and Xihasmbrows (except forXN 1and XM 1, whichmay have fewer columns and rows, respectively).The implementations of Matrix Multiplication will be composed from multipli-cations with submatrices. We have given these computations special names, astabulated in Figs. 2 and 3. We note that these special shapes are very frequentlyACM Transactions on Mathematical Software, Vol. V, No. N, Month Kazushige Goto and Robert A. van de GeijnmnkIllustrationLabellargelargelarge :=+gemmlargelargesmall:=+gepplargesmalll arge:=+gempsmalllargelarge:=+gepmsmallla rgesmall:=+gebplargesmallsmall:=+gepbsma llsmalllarge:=+gepdotsmallsmallsmall:=+g ebbFig. 2.

10 Special shapes ofgemmC:=AB+C. HereC,A, andBarem n,m k, andk nmatrices, dimensions are large or of the dimensions is dimensions are 3. The labels in Fig. 2 have the formgexywhere the letters chosen forxandyindicatethe shapes of matricesAandB, respectively, according to the above table . The exception to thisconvention is thegepdotoperation, which is a generalization of the dot as part of algorithms for other linear algebra operations. For example,computation of various operations supported by LAPACK is cast mostly in termsofgepp,gemp, andgepm. Even given a single dense linear algebra operation,multiple algorithms often exist where each of the algorithms casts the computationin terms of these different cases ofgemmmultiplication [Bientinesi et al. ].3. A LAYERED APPROACH TOGEMMIn Fig.


Related search queries