15
Midpoint-Based Parallel Sparse Matrix–Matrix Multiplication Algorithm V. Weber 1 , A. Pozdneev 2 , T. Laino 1 1 IBM Zurich Research Laboratory, R¨ uschlikon, Switzerland 2 IBM Science and Technology Center, Moscow, Russia March 3, 2016 — GraphHPC-2016, Moscow 1 c 2016 IBM Corporation

Midpoint-Based Parallel Sparse Matrix-Matrix Multiplication Algorithm

Embed Size (px)

Citation preview

Midpoint-Based Parallel Sparse Matrix–MatrixMultiplication Algorithm

V. Weber1, A. Pozdneev2, T. Laino1

1IBM Zurich Research Laboratory, Ruschlikon, Switzerland

2IBM Science and Technology Center, Moscow, RussiaMarch 3, 2016 — GraphHPC-2016, Moscow

1 c○ 2016 IBM Corporation

Matrix graph dualityGraph algorithms in the language of linear algebra

∙ Adjacency matrix A is dual with the corresponding graph∙ Vector matrix multiply is dual with breadth-first search

Image credit: [Kepner2011]

2 c○ 2016 IBM Corporation

Sparse matrix-matrix multiplication motivationElectronic structure theory

∙ Density matrix 𝐷 at zeroelectronic temperature:

𝐷 = 𝜃[𝜇𝐼 − 𝐹 ]

I 𝜃(𝑥) — Heaviside stepfunction

I 𝜇 — chemical potentialI 𝐼 — identity matrixI 𝐹 — Fockian

∙ Second-order spectral projection (SP2)method

𝐷 = lim𝑖→∞

𝑓𝑖[𝑓𝑖−1[. . . 𝑓0[𝑋0]]]

∙ Recursive polynomial

𝑓𝑖[𝑋𝑖] =

{𝑋2

𝑖 Tr[𝑋𝑖] > 𝑁𝑠

2𝑋𝑖 −𝑋2𝑖 otherwise

I 𝑁𝑠 — number of occupied states

3 c○ 2016 IBM Corporation

Scalability issues of the Cannon’s and SUMMA algorithms

∙ Weak scaling experiment∙ ≈ 200 atoms per MPI task∙ From 32 928 atoms on 144 cores∙ To 1 022 208 atoms on 5184 cores∙ Image legend:

I Total CPU time per atomI Block matrix multiplicationsI Book-keeping overheadI Communication between processesI Dashed line: fit to the data using

𝑓(𝑁) = 𝑎+ 𝑏√𝑁

Image credit: [VandeVondele2012]

4 c○ 2016 IBM Corporation

Midpoint method

∙ Particle interactions in moleculardynamics [Bowers2006]

∙ The computational domain isdivided between processors

∙ Interaction between a pair — aprocessor that holds a midpoint

Image credit: [Bowers2006]

5 c○ 2016 IBM Corporation

Midpoint distribution of a matrix

6 c○ 2016 IBM Corporation

Midpoint distribution of a matrix (contd.)

7 c○ 2016 IBM Corporation

Sparse matrix-matrix multiplication

∙ Exploit the locality∙ 3D Cartesian topology∙ Each matrix element lies at theprocess that owns a midpoint:

I midpoint(𝑖, 𝑘)⇒ element 𝐴𝑖𝑘

I midpoint(𝑘, 𝑗)⇒ element 𝐵𝑘𝑗

I midpoint(𝑖, 𝑗)⇒ element 𝐶𝑖𝑗

∙ Send 𝐴𝑖𝑘 and 𝐵𝑘𝑗

∙ 𝐶𝑖𝑗 ← 𝐴𝑖𝑘 ·𝐵𝑘𝑗 + 𝐶𝑖𝑗

i

j

k

Bkj(-1,0) (0,0)

(0,-1)

Cij

Aik

Image credit: [Weber2015]

8 c○ 2016 IBM Corporation

Why does it work?

As a reminder. . .Midpoint distribution of a matrix

𝐴 = 𝐴(1,1) + · · ·+𝐴(𝑝𝑥,𝑝𝑦)

𝐴𝐵 = (𝐴(1,1) + · · ·+𝐴(𝑝𝑥,𝑝𝑦))×× (𝐵(1,1) + · · ·+𝐵(𝑝𝑥,𝑝𝑦))

𝐴(𝑟,𝑠)𝐵(𝑡,𝑢) = 𝑂

if |𝑟 − 𝑡| ≤ 2, |𝑠− 𝑢| ≤ 2

9 c○ 2016 IBM Corporation

Weak scaling experiments

∙ Two occupations of thedensity matrix (O1, O2)

∙ ≈ 19 water moleculesper MPI task

∙ 216÷ 59 319 MPI tasks∙ MPSM3 vs. SUMMAcrossover point:

I O1: ≈ 19 683 MPItasks (373 248 watermolecules)

I O2: ≈ 9 261 MPItasks (175 616 watermolecules)

Image credit: [Weber2015]

10 c○ 2016 IBM Corporation

Strong scaling experiments

∙ Water molecules:I S1: 110 592I S2: 373 248I S3: 1 124 864

∙ MPI tasks:I S1: 216÷ 59 319I S2: 1 728÷ 110 592I S3: 9 261÷ 185 193

∙ MPSM3 vs. SUMMAcrossover point — slightlysmaller than S2 Image credit: [Weber2015]

11 c○ 2016 IBM Corporation

Summary

∙ Linear algebra is the language of graph algorithms∙ Sparse matrix-matrix multiplication is a critical building block∙ General-purpose SMMM algorithms do not scale well∙ We distribute sparse matrix according to the midpoint principle∙ Linear scalability with number of “edges” given proportional resources∙ Advantages over SUMMA:

I reduced communication volumeI more effective load balancingI communication latency (nearby processes only)

∙ The scalability comes from the reduced volume of interprocesscommunications

12 c○ 2016 IBM Corporation

References

V. Weber, T. Laino, A. Pozdneev, I. Fedulova, A. CurioniSemiempirical Molecular Dynamics (SEMD) I: Midpoint-Based ParallelSparse Matrix–Matrix Multiplication Algorithm for Matrices with DecayJ. Chem. Theory Comput., 2015, 11 (7), pp 3145–3152

K.J. Bowers, R.O. Dror, D.E. ShawThe midpoint method for parallelization of particle simulationsJ. Chem. Phys., 124, 184109 (2006)

J. VandeVondele, U. Borstnik, J. HutterLinear Scaling Self-Consistent Field Calculations with Millions of Atomsin the Condensed PhaseJ. Chem. Theory Comput., 2012, 8 (10), pp 3565–3573

J. Kepner, J. Gilbert (eds.)Graph Algorithms in the Language of Linear AlgebraSIAM, Philadelphia, 2011

13 c○ 2016 IBM Corporation

Disclaimer

All the information, representations, statements, opinions and proposals in thisdocument are correct and accurate to the best of our present knowledge but arenot intended (and should not be taken) to be contractually binding unless anduntil they become the subject of separate, specific agreement between us.Any IBM Machines provided are subject to the Statements of Limited Warrantyaccompanying the applicable Machine.Any IBM Program Products provided are subject to their applicable license terms.Nothing herein, in whole or in part, shall be deemed to constitute a warranty.IBM products are subject to withdrawal from marketing and or service uponnotice, and changes to product configurations, or follow-on products, may resultin price changes.Any references in this document to “partner” or “partnership” do not constitute orimply a partnership in the sense of the Partnership Act 1890.IBM is not responsible for printing errors in this proposal that result in pricing orinformation inaccuracies.

14 c○ 2016 IBM Corporation

Правовая информация

IBM, логотип IBM, BladeCenter, System Storage и System x являются товарными знаками International BusinessMachines Corporation в США и/или других странах. Полный список товарных знаков компании IBM смотритена узле Web: www.ibm.com/legal/copytrade.shtml.

Названия других компаний, продуктов и услуг могут являться товарными знаками или знаками обслуживаниядругих компаний.

(c) 2016 International Business Machines Corporation. Все права защищены.

Упоминание в этой публикации продуктов или услуг корпорации IBM не означает, что IBM предполагаетпредоставлять их во всех странах, в которых осуществляет свою деятельность, информация опредоставлении продуктов или услуг может быть изменена без уведомления. За самой свежей информациейо продуктах и услугах компании IBM, предоставляемых в Вашем регионе, следует обращаться в ближайшееторговое представительство IBM или к авторизованным бизнес-партнерам.

Все заявления относительно намерений и перспективных планов IBM могут быть изменены без уведомления.

Информация о продуктах третьих фирм получена от производителей этих продуктов или из опубликованныханонсов указанных продуктов. IBM не тестировала эти продукты и не может подтвердитьпроизводительность, совместимость, или любые другие заявления относительно продуктов третьих фирм.Вопросы о возможностях продуктов третьих фирм следует адресовать поставщику этих продуктов.

Информация может содержать технические неточности или типографические ошибки. В представленную впубликации информацию могут вноситься изменения, эти изменения будут включаться в новые редакцииданной публикации. IBM может вносить изменения в рассматриваемые в данной публикации продукты илиуслуги в любое время без уведомления.

Любые ссылки на узлы Web третьих фирм приведены только для удобства и никоим образом не служатподдержкой этим узлам Web. Материалы на указанных узлах Web не являются частью материалов дляданного продукта IBM.

15 c○ 2016 IBM Corporation