40
edric Lachat &Franc¸ois Pellegrini June 14, 2012 PaMPA : Parallel Mesh Partitioning and Adaptation

PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Cedric Lachat & Francois Pellegrini June 14, 2012

PaMPA :Parallel MeshPartitioning and Adaptation

Page 2: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Introduction

Contents

Introduction

Common needs of solvers regarding meshes

Data structures

Version 0.1

Example: Laplacian equation using finite element method

Some results

Upcoming features

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 2

Page 3: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Introduction

Middleware

I PaMPA: Parallel Mesh Partitioning and AdaptationI Middleware library managing the parallel repartitioning and

remeshing of unstructured meshes modeled as interconnectedvaluated entities

I The user can focus on his/her “core business”:I SolverI Sequential remesher

I Coupling with MMG3D provided for tetrahedra

Physics, solver

Remeshing and redistribution

PT-Scotch

Seq. Qual.Measurement

Sequentialremesher

MMG3D

PaMPA

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 3

Page 4: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Common needs of solvers regarding meshes

Contents

Introduction

Common needs of solvers regarding meshes

Data structures

Version 0.1

Example: Laplacian equation using finite element method

Some results

Upcoming features

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 4

Page 5: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Common needs of solvers regarding meshes

Common needs of solvers regarding meshes:

I Handling of mesh structuresI Distribution of meshes across the processors of a parallel

architectureI Handling of load balance

I Data exchange across neighboring entitiesI Iteration on mesh entities

I Entities of any kind: e.g. elements, faces, edges, nodes, . . .I Entity sub-classes: e.g. regular or boundary faces, . . .I Inner or frontier entities with respect to neighboring processorsI Maximization of cache effects thanks to proper data reordering

I Dynamic modification of mesh structureI Dynamic redistribution

I Adaptive remeshing

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 5

Page 6: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Contents

Introduction

Common needs of solvers regarding meshes

Data structures

Version 0.1

Example: Laplacian equation using finite element method

Some results

Upcoming features

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 6

Page 7: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Constraints

I Distributed dataI Mesh data should not be replicated for the sake of scalabilityI Minimization of data exchangesI Abstraction from actual data structure implementations

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 7

Page 8: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

Top-level mesh entityMay bear some data (volume,

pressure, etc.)

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 9: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

May bear some data (geometry, etc.)

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 10: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

May bear some data (flux, etc.)

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 11: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

Regular mesh edge

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 12: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

Boundary mesh edge

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 13: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

What all entities are in fact. . .

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 14: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

Subset of edges between verticesbelonging to prescribed entity types

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 15: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

Subset of vertices bearing the samedata

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 16: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

Subset of entity vertices that maybear specific data

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 17: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Definitions

I ElementI NodeI Edge

I InternalI Boundary

I VertexI RelationI EntityI Sub-entityI Enriched graph

Whole set of vertices and relationsEvery vertex belongs to one and only

one entity (and sub-entity)

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 8

Page 18: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Global vue

baseval

enttglbnbr

proccnttab

procvrttab

1

3

3 4 3

1 4 8 11

5

1

2 9

7

4

3 6 8

10

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 9

Page 19: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Local vision of process 0

vertgstnbr

vertlocnbr

edgelocnbr

ventloctab

edgeloctab

vertloctab

vendloctab

6

3

7

3 1

1

1 1

2 3 8

1 2 3 4 2

3

4

1

2

3

1 2

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 10

Page 20: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Local vision of process 1

vertgstnbr

vertlocnbr

edgelocnbr

ventloctab

edgeloctab

vertloctab

vendloctab

7

4

3 13 2

13

1

2

3 6

1 2 1 3 2 1 2 1 3 1

1412

3 3

23

1

1

2 1 3

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 11

Page 21: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Per-entity data (1/2)

E.g. entity 1 on processor 0:

vertgstnbr

vertlocnbr

2

1

4

1

2

3

1 2

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 12

Page 22: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Per-entity data (2/2)

E.g. node neighbors of element 1 on process 0:

vertloctab

edgeloctab

vendloctab

4

1 1

8

43212

4

1

2

3

1 2

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 13

Page 23: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Data structures

Data linking

5

1

2 9

7

4

3 6 8

10

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 14

Page 24: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Version 0.1

Contents

Introduction

Common needs of solvers regarding meshes

Data structures

Version 0.1

Example: Laplacian equation using finite element method

Some results

Upcoming features

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 15

Page 25: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Version 0.1

Entities

I Based (for C and Fortran interfaces)I SimpleI Stable with respect to sub-entities

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 16

Page 26: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Version 0.1

Partitioning

I Performed with respect to top-level entity

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 17

Page 27: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Version 0.1

Overlap

I Of size 1 at the time beingI Extensible to any distance nI Requires top-level relations

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 18

Page 28: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Version 0.1

Local vue of process 0

I Halo of size 1 I Overlap of size 1

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 19

Page 29: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Version 0.1

Local vue of process 1

I Halo of size 1I Overlap of size 1

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 20

Page 30: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Version 0.1

Iterators

I Entities - sub-entitiesI Decrease of cache missesI Debugging tools

PAMPA dmeshIt In i tStart ( mesh , vent locnum , PAMPA VERT ANY, & i t v e r t ) ;PAMPA dmeshItInit ( mesh , vent locnum , nentlocnum , &i t n g h b ) ;

w h i l e ( PAMPA itHasMore(& i t v e r t ) ) {v e r t l o c n u m = PAMPA itCurEnttvert locnum(& i t v e r t ) ;p r i n t f ( ” v e r t l o c n u m : %d\n” , v e r t l o c n u m ) ;PAMPA itStart(& i t n g h b , v e r t l o c n u m ) ;

w h i l e ( PAMPA itHasMore(& i t n g h b ) ) {PAMPA Num sngblocnum , engblocnum , mngblocnum , nsublocnum ;engblocnum = PAMPA itCurEnttvert locnum(& i t n g h b ) ;mngblocnum = PAMPA itCurMeshvertlocnum(& i t n g h b ) ;sngblocnum = PAMPA itCurSubEnttvert locnum(& i t n g h b ) ;nsublocnum = PAMPA itCurnsublocnum(& i t n g h b ) ;p r i n t f ( ”[%d ] ngb o f %d w i t h e n t i t y %d : %d ( sub : %d ) %d ( e n t : %d ) %d ( g l b )\n” ,

rank , ver t locnum , vent locnum , sngblocnum , nsublocnum ,engblocnum , nentlocnum , mngblocnum ) ;

PAMPA itNext(& i t n g h b ) ;}

}

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 21

Page 31: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Example: Laplacian equation using finite element method

Contents

Introduction

Common needs of solvers regarding meshes

Data structures

Version 0.1

Example: Laplacian equation using finite element method

Some results

Upcoming features

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 22

Page 32: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Example: Laplacian equation using finite element method

All steps

! P a r a l l e l Mesh Computat ions!−−−−−−−−−−−−−−−−−−−−−−−−−−−

! P r o c e s s o r 0 o n l y :CALL ReadMesh ( ) ! Read mesh on f i l eCALL GraphPampa ( ) ! B u i l d graph o f v e r t e x n e i g h b o r s f o r PAMPACALL PampaCentra l izedMesh ( ) ! B u i l d PaMPA g l o b a l non d i s t r i b u t e d mesh

! On a l l p r o c e s s o r s :CALL PampaDistr ibutedMesh ( ) ! B u i l d PAMPA d i s t r i b u t e d mesh :! 1− S c a t t e r c e n t r a l i z e d mesh on a l l p r o c e s s o r s! 2− C a l l PAMPA mesh p a r t i o n n e r! 3− R e d i s t r i b u t e d i s t r i b u t e meshCALL ElementVolume ( )CALL I n i t i a l i z e M a t r i x C S R ( )

! S o l u t i o n computat ion!−−−−−−−−−−−−−−−−−−−−−

CALL I n i t S o l ( )CALL F i l l M a t r i x ( )CALL So lveSystem ( )

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 23

Page 33: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Example: Laplacian equation using finite element method

Solve system: Jacobi (1/2)

UaPrec = 0 . ! Suppose A = L + D + U, system to s o l v e : A x = bDO i r e l a x = 1 , N r e l a x

r e s = 0 .DO i s = 1 , MatCSR%Nin

r e s 0 = RHS( i s ) ! r e s 0 = bi 1 = MatCSR%I a ( i s )I 1 F i n = MatCSR%I a ( i s + 1) −1

DO i v = I1 , I 1 F i nj s = MatCSR%Ja ( i v )r e s 0 = r e s 0 − MatCSR%V a l s ( i v ) ∗ UaPrec ( j s ) ! r e s 0 = b − ( L + U) xˆn

END DOUa( i s ) = r e s 0 / MatCSR%Diag ( i s ) ! xˆn+1 = ( b − ( L + U) xˆn )/Dr e s 0 = r e s 0 − MatCSR%Diag ( i s ) ∗ UaPrec ( i s ) ! r e s 0 = ( b − ( L + D + U) xˆn )r e s 0 = r e s 0 ∗ r e s 0 ! r e s 0 = ( b − ( L + D + U) xˆn )∗∗2r e s = r e s + r e s 0

END DO

CALL PAMPAF dmeshHaloValue (dm, && enttnum = PAMPA ENTITY NODE , && tagnum = INT (PAMPA TAG SOL , PAMPAF NUM) , && r e t v a l = s t a t u t )

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 24

Page 34: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Example: Laplacian equation using finite element method

Solve system: Jacobi (2/2)

d e l t a U = 0 .d e l t a U = DOT PRODUCT( UaPrec ( : MatCSR%Nin ) − Ua ( : MatCSR%Nin ) ,

UaPrec ( : MatCSR%Nin ) − Ua ( : MatCSR%Nin ) )r e s 0 = 0 .r e s 0 = DOT PRODUCT( RHS ( : MatCSR%Nin ) ,

RHS ( : MatCSR%Nin ) )UaPrec = Ua

d e l t a U g l b = 0 .CALL MPI ALLREDUCE( de l taU , d e l t a U g l b , 1 , t y p e r e a l , MPI SUM ,MPI COMM WORLD, code )d e l t a U g l b = s q r t ( d e l t a U g l b )

r e s g l b = 0 .CALL MPI ALLREDUCE( r e s , r e s g l b , 1 , t y p e r e a l , MPI SUM , MPI COMM WORLD, code )r e s g l b = s q r t ( r e s g l b )

r e s 0 g l b = 0 .CALL MPI ALLREDUCE( r e s 0 , r e s 0 g l b , 1 , t y p e r e a l , MPI SUM , MPI COMM WORLD, code )r e s 0 g l b = s q r t ( r e s 0 g l b )

r e s g l b = r e s g l b / r e s 0 g l b

END DO ! end loop on i r e l a x

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 25

Page 35: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Some results

Contents

Introduction

Common needs of solvers regarding meshes

Data structures

Version 0.1

Example: Laplacian equation using finite element method

Some results

Upcoming features

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 26

Page 36: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Some results

First results (1/2)

0

50

100

150

200

250

300

350

400

450

500

550

0 1 2 3 4 5 6 7 8 9 10

Tim

e (

in s

eco

nd

s)

Number of processors (x1000)

Time for distributing centralized mesh and partitionning distributed mesh

ScatterPart

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 27

Page 37: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Some results

First results (2/2)

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

0 1 2 3 4 5 6 7 8 9 10

Tim

e (

in s

eco

nd

s)

Number of processors (x1000)

Time for distributing centralized mesh and partitionning distributed mesh

Redistribution

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 28

Page 38: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Upcoming features

Contents

Introduction

Common needs of solvers regarding meshes

Data structures

Version 0.1

Example: Laplacian equation using finite element method

Some results

Upcoming features

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 29

Page 39: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Upcoming features

New features

I Main idea:I Parallel mesh adaptation

I Others:I Parallel I/O with HDF5I Overlap greater than 1I Unbreakable relations

Cedric Lachat & Francois Pellegrini - PaMPA June 14, 2012- 30

Page 40: PaMPA : Parallel Mesh Partitioning and Adaptation · Parallel Mesh Partitioning and Adaptation. Introduction Contents Introduction Common needs of solvers regarding meshes Data structures

Upcoming features

Merci

Franois Pellegrini June 14, 2012