Introduction to PETSc



Similar documents
In-situ Visualization

Introduction. Reading. Today MPI & OpenMP papers Tuesday Commutativity Analysis & HPF. CMSC 818Z - S99 (lect 5)

Computational Physics

Virtual Topologies. Cartesian partitioning Exercise. * includes sample C and Fortran programs

URI and UUID. Identifying things on the Web.

Towards real-time image processing with Hierarchical Hybrid Grids

Hybrid Programming with MPI and OpenMP

Tail call elimination. Michel Schinz

Intro to GPU computing. Spring 2015 Mark Silberstein, , Technion 1

Topological Properties

Drawing Text with SDL

Specific Simple Network Management Tools

Why are we teaching you VisIt?

Moving boundary in openfoam

Locality-Preserving Dynamic Load Balancing for Data-Parallel Applications on Distributed-Memory Multiprocessors

H.Calculating Normal Vectors

SQLITE C/C++ TUTORIAL

An Incomplete C++ Primer. University of Wyoming MA 5310

Visualization of 2D Domains

P1 P2 P3. Home (p) 1. Diff (p) 2. Invalidation (p) 3. Page Request (p) 4. Page Response (p)

7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012

Parallelization: Binary Tree Traversal

Networks and Protocols Course: International University Bremen Date: Dr. Jürgen Schönwälder Deadline:

Overview. Lecture 1: an introduction to CUDA. Hardware view. Hardware view. hardware view software view CUDA programming

Lecture Data Types and Types of a Language

Mesh Partitioning and Load Balancing

CORBA Programming with TAOX11. The C++11 CORBA Implementation

Off-by-One exploitation tutorial

Hands-on Hacking Unlimited

Stacks. Linear data structures

Code Generation Tools for PDEs. Matthew Knepley PETSc Developer Mathematics and Computer Science Division Argonne National Laboratory

Parallel Programming with MPI on the Odyssey Cluster

Operating Systems. Privileged Instructions

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Numerical Libraries with C or Fortran. Shaohao Chen Research Computing, IS&T, Boston University

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

High performance computing systems. Lab 1

An API for Reading the MySQL Binary Log

The Art of Exploiting Logical Flaws in Web Apps. Sumit sid Siddharth Richard deanx Dean

Comp151. Definitions & Declarations

Introduction to Visualization with VTK and ParaView

Lecture 3. Optimising OpenCL performance

Optimizing Load Balance Using Parallel Migratable Objects

S7 OPC Server Tutorial

OpenMP* 4.0 for HPC in a Nutshell


Data Structures and Algorithms C++ Implementation

COMP/CS 605: Introduction to Parallel Computing Lecture 21: Shared Memory Programming with OpenMP

Operating System Structure

Visualization of Adaptive Mesh Refinement Data with VisIt

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

Illustration 1: Diagram of program function and data flow

CUDA Basics. Murphy Stein New York University

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Tutorial: Using a UDF to Control the Dynamic Mesh of a Flexible Oscillating Membrane

How I Learned to Stop Fuzzing and Find More Bugs

Hash-Storage Techniques for Adaptive Multilevel Solvers and Their Domain Decomposition Parallelization

Multi-Block Gridding Technique for FLOW-3D Flow Science, Inc. July 2004

Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG

Tutorial on C Language Programming

Designing and Building Applications for Extreme Scale Systems CS598 William Gropp

Lecture 11 Array of Linked Lists

Software Vulnerabilities

Finite Elements for 2 D Problems

Elementary Name and Address. Conversions

TivaWare Utilities Library

Netscape Internet Service Broker for C++ Programmer's Guide. Contents

Title: Bugger The Debugger - Pre Interaction Debugger Code Execution

OpenCV Tutorial. Part I Using OpenCV with Microsoft Visual Studio.net November Gavin S Page gsp8334@cs.rit.edu

A Client Server Transaction. Introduction to Computer Systems /18 243, fall th Lecture, Nov. 3 rd

Tutorial One: Calculation of leakage inductance of transformer using FEM MVA, 132 kv/33kv, Y/, Ampere-turns: , No.

Data Structures Using C++ 2E. Chapter 5 Linked Lists

Debugging and Bug Tracking. Slides provided by Prof. Andreas Zeller, Universität des Saarlands

Photon Mapping Made Easy

CI6227: Data Mining. Lesson 11b: Ensemble Learning. Data Analytics Department, Institute for Infocomm Research, A*STAR, Singapore.

Help on the Embedded Software Block

Andreas Burghart 6 October 2014 v1.0

CMYK 0/100/100/20 66/54/42/17 34/21/10/0 Why is R slow? How to run R programs faster? Tomas Kalibera

Big Data Analytics for SCADA

The University of Alabama in Huntsville Electrical and Computer Engineering CPE Test #4 November 20, True or False (2 points each)

1 3 4 = 8i + 20j 13k. x + w. y + w

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

Programming languages C

Secure Programming with Static Analysis. Jacob West

Retour vers le futur des bibliothèques de squelettes algorithmiques et DSL

Outline. Motivation. Motivation. MapReduce & GraphLab: Programming Models for Large-Scale Parallel/Distributed Computing 2/28/2013

iphone Objective-C Exercises

PRESENTATION OF THE UNIVERSITY OF FEDERAL ITAJUBÁ

Performance of Dynamic Load Balancing Algorithms for Unstructured Mesh Calculations

Object oriented programming. Course Objectives. On completion of the class, a student should be able: Object Oriented Paradigm

Application Programming Using the GNOME Libraries

CSE 333 SECTION 6. Networking and sockets

Transcription:

Introduction to PETSc Data management Loïc Gouarin Laboratoire de Mathématiques d Orsay May 13-15, 2013 Loïc Gouarin Introduction to PETSc 1

Data management PETSc offers two types of data management DMDA: data management for structured mesh DMPlex (or DMMesh): data management for unstructured mesh These structures define for each process local portion of the mesh, ghost points, communications with the neighbourhood to update ghost points, global and local mapping,... Loïc Gouarin Introduction to PETSc 2

DMDA creation int DMDACreate2d(MPI_Comm comm, DMDABoundaryType xperiod, DMDABoundaryType yperiod, DMDAStencilType st, int M, int N,int m,int n,int dof,int s, int *lx,int *ly,dm *da) xperiod and yperiod: type of ghost nodes. DMDA BOUNDARY NONE, DMDA BOUNDARY GHOSTED, DMDA BOUNDARY PERIODIC st: stencil type. DMDA STENCIL BOX or DMDA STENCIL STAR M and N: global dimension in each direction. m and n: number of processors in each direction. dof: number of degrees of freedom per node. s: stencil width. Loïc Gouarin Introduction to PETSc 3

Local and global vectors Creation int DMCreateGlobalVector(DM da,vec *g) int DMCreateLocalVector(DM da,vec *l) Scatter a global vector into its local parts including the ghost points DMGlobalToLocalBegin(DM da,vec g, InsertMode iora,vec l); DMGlobalToLocalEnd(DM da,vec g, InsertMode iora,vec l); Scatter a local vector into the global vector DMDALocalToGlobalBegin(DM da,vec l, InsertMode iora,vec g); DMDALocalToGlobalEnd(DM da,vec l, InsertMode iora,vec g); InsertMode can be either INSERT_VALUES or ADD_VALUES. Loïc Gouarin Introduction to PETSc 4

First example #include "petsc.h" int main(int argc, char **argv){ int nx=5, ny=5; DM dm; Vec g; } PetscInitialize(&argc, &argv, NULL, NULL); DMDACreate2d(PETSC_COMM_WORLD, DMDA_BOUNDARY_NONE, DMDA_BOUNDARY_NONE, DMDA_STENCIL_STAR, nx, ny, PETSC_DECIDE, PETSC_DECIDE, 1, 1, PETSC_NULL, PETSC_NULL, &dm); DMCreateGlobalVector(dm, &g);... VecDestroy(&g); PetscFinalize(); return 0; Loïc Gouarin Introduction to PETSc 5

Local portion on each process 2 3 0 1 Loïc Gouarin Introduction to PETSc 6

Local portion on each process 20 21 22 23 24 15 16 17 18 19 10 11 12 13 14 5 6 7 8 9 0 1 2 3 4 Loïc Gouarin Introduction to PETSc 7

Ghost points: DMDA STENCIL STAR 0 Loïc Gouarin Introduction to PETSc 8

Ghost points: DMDA STENCIL STAR 3 Loïc Gouarin Introduction to PETSc 9

Ghost points: DMDA STENCIL BOX 0 Loïc Gouarin Introduction to PETSc 10

Ghost points: DMDA STENCIL BOX 3 Loïc Gouarin Introduction to PETSc 11

How to get grid information? DMDAGetCorners(DM da, int *xs,int *ys,int *zs, int *xm,int *ym,int *zm); ym 0 (xs, ys) xm Use PETSC_NULL if you want to omit a parameter. Loïc Gouarin Introduction to PETSc 12

How to get grid information? DMDAGetCorners(DM da, int *xs,int *ys,int *zs, int *xm,int *ym,int *zm); ym 3 (xs, ys) xm Loïc Gouarin Introduction to PETSc 13

How to get grid information? DMDAGetGhostCorners(DM da, int *gxs,int *gys,int *gzs, int *gxm,int *gym,int *gzm); gym 0 (gxs, gys) gxm Loïc Gouarin Introduction to PETSc 14

How to get grid information? DMDAGetGhostCorners(DM da, int *gxs,int *gys,int *gzs, int *gxm,int *gym,int *gzm); gym 3 (gxs, gys) gxm Loïc Gouarin Introduction to PETSc 15

How to get grid information? DMDAGetLocalInfo(DM da,dmdalocalinfo *info) typedef struct { PetscInt dim,dof,sw; /* global number of grid points in each direction */ PetscInt mx,my,mz; /* starting point of this processor, excluding ghosts */ PetscInt xs,ys,zs; /* number of grid points on this processor, excluding ghosts * PetscInt xm,ym,zm; /* starting point of this processor including ghosts */ PetscInt gxs,gys,gzs; /* number of grid points on this processor including ghosts */ PetscInt gxm,gym,gzm; /* type of ghost nodes at boundary */ DMDABoundaryType bx,by,bz; DMDAStencilType st; DM da; } DMDALocalInfo; Loïc Gouarin Introduction to PETSc 16

DMDA offers functions for vector manipulation Local (ghosted) work vectors DMGetLocalVector(DM da,vec *l);... use the local vector l DMRestoreLocalVector(DM da,vec *l); Accessing the vector entries for DMDA vectors PetscScalar **f,**u;... DMDAVecGetArray(DM da,vec local,&u); DMDAVecGetArray(DM da,vec global,&f);... f[i][j] = u[i][j] -...... DMDAVecRestoreArray(DM da,vec local,&u); DMDAVecRestoreArray(DM da,vec global,&f); Loïc Gouarin Introduction to PETSc 17

References 1 PETSc documentation http://www.mcs.anl.gov/petsc/documentation/index.html 2 PETSc tutorial http://www.mcs.anl.gov/petsc/documentation/tutorials/index.html Loïc Gouarin Introduction to PETSc 18