Los Alamos National Laboratory 1 POOMA 2.1 Timothy J. Williams Advanced Computing Laboratory ACL Seminar LANL September 28, 1999.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

MPI Message Passing Interface
SEG4110 – Advanced Software Design and Reengineering TOPIC J C++ Standard Template Library.
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Vectors, lists and queues
Chapter 6 Advanced Function Features Pass by Value Pass by Reference Const parameters Overloaded functions.
Programming in Occam-pi: A Tutorial By: Zain-ul-Abdin
Systems and Technology Group © 2006 IBM Corporation Cell Programming Tutorial - JHD24 May 2006 Cell Programming Tutorial Jeff Derby, Senior Technical Staff.
Slide-1 University of Maryland Five Common Defect Types in Parallel Computing Prepared for Applied Parallel Computing Prof. Alan Edelman Taiga Nakamura.
Class 15 - Overhead 11Object Oriented Programming Using C #define t_circle 1 #define t_rectangle 2 struct circle_shape {short type; double x,y; double.
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
Derived data types Dealing with data –Where the information is stored –What value is kept there –What kind of information is stored Address operator Pointers.
Winter, 2004CSS490 MPI1 CSS490 Group Communication and MPI Textbook Ch3 Instructor: Munehiro Fukuda These slides were compiled from the course textbook,
SPRING 2015 QtSpim Demo & Tutorial. 2 By DGP Outline How to write your own MIPS assembly language program How to use QtSpim simulator.
C++ Templates. What is a template? Templates are type-generic versions of functions and/or classes Template functions and template classes can be used.
 2003 Prentice Hall, Inc. All rights reserved Fundamentals of Characters and Strings Character constant –Integer value represented as character.
© 2003 Mark D. HillCS & ECE, University of Wisconsin-Madison Harnessing Moore’s Law (with Selected Implications) Mark D. Hill Computer Sciences Department.
1 Chapter 10 Strings and Pointers. 2 Introduction  String Constant  Example: printf(“Hello”); “Hello” : a string constant oA string constant is a series.
CSE 332: C++ Algorithms I The C++ Algorithm Libraries A standard collection of generic algorithms –Applicable to various types and containers E.g., sorting.
Trellis: A Framework for Adaptive Numerical Analysis Based on Multiparadigm Programming in C++ Jean-Francois Remacle, Ottmar Klaas and Mark Shephard Scientific.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 10 - C Structures, Unions, Bit Manipulations,
CIS 101: Computer Programming and Problem Solving Lecture10 Usman Roshan Department of Computer Science NJIT.
Command-line arguments CS 201 Fundamental Structures of Computer Science.
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009.
ITUppsala universitet Data representation and fundamental algorithms Filip Malmberg
Finite Difference Methods Or Computational Calculus.
Assigned work: pg. 433 #1-12 Equation of a line – slope and point or two points BUT NOW we will learn to describe an Equation of a Line by using vectors…………………..
University of Calgary – CPSC 441. C PROGRAM  Collection of functions  One function “main()” is called by the operating system as the starting function.
Copyright © 2012 Pearson Education, Inc. Chapter 8 Two Dimensional Arrays.
POOMA 2.4 Progress and Plans Scott Haney, Mark Mitchell, James Crotinger, Jeffrey Oldham, and Stephen Smith October 22, 2001 Los Alamos National Laboratory.
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
DCT1063 Programming 2 CHAPTER 5 ADVANCED DATA TYPE (part 1) Mohd Nazri Bin Ibrahim Faculty of Computer Media and Technology TATi University College
Variables, Functions & Parameter Passing CSci 588 Fall 2013 All material not from online sources copyright © Travis Desell, 2011.
CSE 332: C++ Type Programming: Associated Types, Typedefs and Traits A General Look at Type Programming in C++ Associated types (the idea) –Let you associate.
VORPAL Optimizations for Petascale Systems Paul Mullowney, Peter Messmer, Ben Cowan, Keegan Amyx, Stefan Muszala Tech-X Corporation Boyana Norris Argonne.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
File IO and command line input CSE 2451 Rong Shi.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 3 Formatting Output.
Equations of Lines and Planes
Stable, Circulation- Preserving, Simplicial Fluids Sharif Elcott, Yiying Tong, Eva Kanso, Peter Schröder, and Mathieu Desbrun.
VTK-m Project Goals A single place for the visualization community to collaborate, contribute, and leverage massively threaded algorithms. Reduce the challenges.
Los Alamos National Laboratory 1 Using POOMA Particles Classes Timothy J. Williams CIC-19, Los Alamos National Laboratory P ARALLEL O BJECT -O RIENTED.
Slides created by: Professor Ian G. Harris Hello World #include main() { printf(“Hello, world.\n”); }  #include is a compiler directive to include (concatenate)
The Generalized Interpolation Material Point Method.
Hank Childs, University of Oregon Unstructured Grids.
Ghost Elements. Ghost Elements: Overview Most FEM programs communicates via shared nodes, using FEM_Update_field Most FEM programs communicates via shared.
BioPSE NCRR SCIRun2 -THE PROJECT -OBJECTIVES -DEVELOPMENTS -TODAY -THE FUTURE.
Ch 4 Fluids in Motion.
CSE 332: C++ Statements C++ Statements In C++ statements are basic units of execution –Each ends with ; (can use expressions to compute values) –Statements.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
C++ Programming Lecture 13 Functions – Part V The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
1 Craig Rasmussen Advanced Computing Laboratory Los Alamos National Laboratory Introduction to Object- and Component-Oriented Programming.
Introduction to Computers and Programming Class 24 Structures (structs) Professor Avi Rosenfeld.
Add Cool Visualizations Here Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary.
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
C++ REVIEW – TEMPLATES. GENERIC PROGRAMMING Programming/developing algorithms with the abstraction of types Algorithms/data is expressed “without type”
Unit 10 Code Reuse. Key Concepts Abstraction Header files Implementation files Storage classes Exit function Conditional compilation Command-line arguments.
Energy-momentum tensor Section 32. The principle of least action gives the field equations Parts.
GPU Acceleration of Particle-In-Cell Methods B. M. Cowan, J. R. Cary, S. W. Sides Tech-X Corporation.
Motion of a Fluid Particle (Kinematics)
Writing a File Format Reader for VisIt
Auburn University COMP7330/7336 Advanced Parallel and Distributed Computing Message Passing Interface (cont.) Topologies.
Command Line Arguments
C++ Functions, Classes, and Templates
Vector Field Visualization
GENERAL VIEW OF KRATOS MULTIPHYSICS
Code::Block vs Visual C++
Outline Introduction Motivation for performance mapping SEAA model
Pointers and dynamic objects
Presentation transcript:

Los Alamos National Laboratory 1 POOMA 2.1 Timothy J. Williams Advanced Computing Laboratory ACL Seminar LANL September 28, 1999

Los Alamos National Laboratory 2 Outline l Background l POOMA 2.1 l Field  Example: scalar advection l Particles  Example: particle-in-cell l 2.1 vs. R1 l Details of POOMA 2.1 features

Los Alamos National Laboratory 3 POOMA l Parallel Object-Oriented Methods and Applications  C++ class library for computational science applications l POOMA R1  Fields, particles, Cartesian meshes, operators, parallel I/O, PAWS (Encapsulated) message-passing  Example uses Beneath Tecolote framework in Blanca Project Accelerator physics Grand Challenge l POOMA 2  Redesign, reimplement from scratch SMARTS thread-based parallelism  Tutorials, Presentations (these slides)

Los Alamos National Laboratory 4 Project 2.1 l Recover most POOMA R1 capabilities Build on POOMA 2.0.x Array  Map {indices}  value (i 1, i 2,..., i N )  value Dim template class Array;

Los Alamos National Laboratory 5 POOMA 2.1 x y y x f (x,y) f 0f 0 ArrayParticlesField

Los Alamos National Laboratory 6 Field Class x f (x,y) y template class Field; double int Tensor Vector... Brick MultiPatch FieldStencilEngine<>...

Los Alamos National Laboratory 7 x f (x,y) y Field Class (cont’d) template class Field; DiscreteGeometry > DiscreteGeometry, RectilinearMesh >... template class DiscreteGeometry; template class RectilinearMesh;

Los Alamos National Laboratory 8 Example: Scalar Advection u = uPrev - 2*dt*div (v*u); T=

Los Alamos National Laboratory 9 ScalarAdvection.cpp (1/6) #include "Pooma/Fields.h" int main(int argc, char *argv[]) { Pooma::initialize(argc,argv); // Set up the library // Create the physical Domains: const int Dim = 1; // Dimensionality const int nVerts = 129; const int nCells = nVerts - 1; Interval vertexDomain; for (int d = 0; d < Dim; d++) { vertexDomain[d] = Interval (nVerts); }

Los Alamos National Laboratory 10 ScalarAdvection.cpp (2/6) // Create the (uniform, logically rectilinear) mesh. Vector origin(0.0), spacings(0.2); typedef UniformRectilinearMesh Mesh_t; Mesh_t mesh(vertexDomain, origin, spacings); // Create two geometry objects, one with 1 guard layer for // stencil width; one with none for temporaries: typedef DiscreteGeometry Geometry_t; Geometry_t geom(mesh, GuardLayers (1)); Geometry_t geomNG(mesh);

Los Alamos National Laboratory 11 ScalarAdvection.cpp (3/6) // Create the Fields: // The flow Field u(x,t): Field u(geom); // The same, stored at the previous timestep for staggered // leapfrog plus a useful temporary: Field uPrev(geomNG), uTemp(geomNG); // Initialize Field to zero everywhere, even global guard layers: u.all() = 0.0; // Set up periodic boundary conditions on all mesh faces: u.addBoundaryConditions(AllPeriodicFaceBC());

Los Alamos National Laboratory 12 ScalarAdvection.cpp (4/6) // Initial condition u(x,0), symmetric pulse about nCells/4: const double pulseWidth = spacings(0)*nCells/8; Loc pulseCenter; for (int d = 0; d < Dim; d++) { pulseCenter[d] = Loc (nCells/4); } Vector u0 = u.x(pulseCenter); u = exp(-dot(u.x() - u0, u.x() - u0) / (2.0 * pulseWidth)); // Output the initial field on its physical domain: std::cout << "Time = 0:\n" << u() << std::endl; const Vector v(0.2); // Propagation velocity const double dt = 0.1; // Timestep

Los Alamos National Laboratory 13 ScalarAdvection.cpp (5/6) // Prime the leapfrog from initial conditions: uPrev = u; // Preliminary forward Euler timestep, using canned POOMA // stencil-based operator div() for the spatial difference: u -= dt * div (v * u); // Staggered leapfrog timestepping. Spatial derivative is // again canned POOMA operator div(): for (int timestep = 2; timestep <= 1000; timestep++) { uTemp = u; u = uPrev * dt * div (v * u); uPrev = uTemp; }

Los Alamos National Laboratory 14 ScalarAdvection.cpp (6/6) Pooma::finalize(); return 0; }

Los Alamos National Laboratory 15 Particles Class template class Particles; x y l Container of particle attributes:  Special 1D array type allows insertion/deletion of elements template DynamicArray;  PTraits defines EngineTag for attributes Particle layout type for multi-patch DynamicArray s Patch 0,1,2,3 UniformLayoutSpatialLayout

Los Alamos National Laboratory 16 Example: Particle-In-Cell E discretized on mesh as Field ( Cell centering)  Interpolate to particle positions Nearest-grid-point formula

Los Alamos National Laboratory 17 PIC.cpp (1/9) // Traits class for Particles object template class CPTraits { public: // The type of engine to use in the attributes typedef MultiPatch AttributeEngineTag_t; // The type of particle layout to use typedef SpatialLayout, FL> ParticleLayout_t; };

Los Alamos National Laboratory 18 PIC.cpp (2/9) // Particles subclass with position, velocity, E-field template class ChargedParticles : public Particles { public: // Typedefs typedef Particles Base_t; typedef typename Base_t::AttributeEngineTag_t EngineTag_t; typedef typename Base_t::ParticleLayout_t ParticleLayout_t; typedef typename ParticleLayout_t::AxisType_t AxisType_t; typedef typename ParticleLayout_t::PointType_t PointType_t;

Los Alamos National Laboratory 19 PIC.cpp (3/9) // Constructor: set up layouts, register attributes ChargedParticles(const ParticleLayout_t &pl, double qmi = 1.0) : Particles (pl), qm(qmi) { addAttribute(R); // Position addAttribute(V); // Velocity addAttribute(E); // Local electric Field value } // Position, velocity, local E attributes (as public members) DynamicArray R; DynamicArray V; DynamicArray E; double qm; // Charge-to-mass ratio; same for all particles };

Los Alamos National Laboratory 20 PIC.cpp (4/9) // Main simulation routine int main(int argc, char *argv[]) { Pooma::initialize(argc, argv); // Set up the library Inform out(NULL,0); // Thread-0 output stream // Create the physical Domains: const int Dim = 2; // Dimensionality const int nVerts = 201; const int nCells = nVerts - 1; Interval vertexDomain; for (int d = 0; d < Dim; d++) { vertexDomain[d] = Interval (nVerts); }

Los Alamos National Laboratory 21 PIC.cpp (5/9) // Mesh and geometry objects for cell-centered Field: typedef UniformRectilinearMesh Mesh_t; Mesh_t mesh(vertexDomain); typedef DiscreteGeometry Geometry_t; Geometry_t geometry(mesh); // Create the electric Field; 4 x 4 x... decomposition: typedef MultiPatch EngineTag_t; typedef UniformGridLayout FLayout_t; Loc patches(4); FLayout_t flayout(geometry.physicalDomain(), patches); Field, EngineTag_t> E(geometry, flayout); // Initialize (constant) electric field as sin(x): double E0 = 0.01 * nCells; double pi = acos(-1.0); E = E0 * sin(2.0*pi * E.x().comp(0) / nCells);

Los Alamos National Laboratory 22 PIC.cpp (6/9) // Create a particle layout object for our use typedef CPTraits PTraits_t; PTraits_t::ParticleLayout_t layout(geometry, flayout); // Create Particles object, set periodic boundary conditions typedef ChargedParticles Particles_t; Particles_t P(layout, 1.0); // Charge-to-mass ratio = 1.0 Particles_t::PointType_t lower(0.0), upper(nCells); PeriodicBC bc(lower, upper); P.addBoundaryCondition(P.R, bc); // Create an equal number of particles on each patch: const int NumPart = 400; // Global number of particles P.globalCreate(NumPart);

Los Alamos National Laboratory 23 PIC.cpp (7/9) // Random initial particle positions, zero velocities. P.V = Particles_t::PointType_t(0.0); srand(12345U); for (int i = 0; i < NumPart; ++i) { for (int d = 0; d < Dim; d++) { P.R.comp(d)(i) = nCells * rand() / static_cast (RAND_MAX); } // Redistribute particle data based on spatial layout P.swap(P.R); const double dt = 1.0; // Timestep

Los Alamos National Laboratory 24 PIC.cpp (8/9) // Begin main timestep loop for (int timestep = 1; timestep <= 20; timestep++) { // Advance particle positions P.R = P.R + dt * P.V; // Apply boundary conditions, update particle distribution P.sync(P.R); // Gather E field to particle positions gather( P.E, E, P.R, NGP() ); // Advance particle velocities P.V = P.V + dt * P.qm * P.E; }

Los Alamos National Laboratory 25 PIC.cpp (9/9) // Display the final particle positions & velocities out << "PIC timestep loop complete." << std::endl; out << " " << std::endl; out << "Final particle data:" << std::endl; out << "Particle positions: " << P.R << std::endl; out << "Particle velocities: " << P.V << std::endl; Pooma::finalize(); return 0; }

Los Alamos National Laboratory 26 POOMA R1 Capabilities Missing in 2.1 l Parallel file I/O  Plan: POOMA 2.2 (Nov.), HDF5-based l FFT  Plan: POOMA 2.3 l Cross-box parallelism  Plan: POOMA 2.3 l Field/Array iterators  Plan: external iterators, flattening Engines (flatten ND to 1D view) l Parallel random number generators  Plan: POOMA 2.3

Los Alamos National Laboratory 27 POOMA 2.1 Capabilities Not in R1 Array syntax on local patch views of Array, Field, DynamicArray l Easy user-defined boundary conditions Automated way to plug “scalar code” into expressions: Stencil, FieldStencil, UserFunction Dynamic adding of attributes to Particles object

Los Alamos National Laboratory 28 POOMA 2.1 Domain Classes l Integer-based (discrete array indexing)  Interval I(0, 13, 2, 20) [0:13:1, 2:20:1]  Range R(0, 10, 2) [0:10:2]  Loc L(i1, i2, i3) (i1, i2, i3) scalar index l Floating-point-based (continuous regions)  Region box(0.0, 1.0, 2.0, 4.0) ([0.0,1.0], [2.0,4.0])

Los Alamos National Laboratory 29 POOMA 2.1 Domain Classes (cont’d) l Array syntax Interval I(0, 13), J(2, 20); Interval I2(I, J); Array A(...), B(...), C(...), D(...); A(I,J) += B(I,J); C(I2) = B(I2) + pow(D(I2), 3); // Stencil: A(I,J) = (A(I+1, J+1) - A(I-1, J-1))/2; // Equivalent Stencil: Loc offsets(1,1); A(I2) = (A(I2 + offsets) - A(I2 - offsets))/2;

Los Alamos National Laboratory 30 POOMA 2.1 Mesh Classes l Logically rectilinear template class UniformRectilinearMesh; template class RectilinearMesh; l Example services (member fcns) Array &vertexPositions() Compute-based Engine (no storage) Indexable (it’s an Array ) Loc &cellContaining(PointType_t &pt) Finds array index of cell containing pt 0 0

Los Alamos National Laboratory 31 POOMA 2.1 Coordinate Systems l Rectilinear template class Cartesian; l Curvilinear (cylindrical) class Cylindrical; class Polar class RhoZ; class Rho; l Example services: template Cylindrical::Volume(Region &region); template T Cartesian ::distance(const Vector &pt1, const Vector &pt2);

Los Alamos National Laboratory 32 POOMA 2.1 Geometry Classes l Only one  Discrete  Centering points relative to a Mesh template class DiscreteGeometry; Partial specializations for [Uniform]RectilinearMesh l Example services PositionArray_t &x() Compute-based Engine (no storage) for [Uniform]RectilinearMesh Indexable (it’s an Array ) Domain_t &physicalDomain() Array domain for a Field on this geometry

Los Alamos National Laboratory 33 POOMA 2.1 Centering Classes l Centerings with respect to logically rectilinear meshes RectilinearCentering >

Los Alamos National Laboratory 34 Field Class Services Field member functions  operator() - Indexing with int s, Interval<>, etc.  x() - Array of position vectors Forwards to Field::geometry().x()  all() - Array view of total index domain  template addBoundaryConditions(Category &bc); - Add to Field ’s list of automatic boundary conditions

Los Alamos National Laboratory 35 POOMA 2.1 Field Boundary Conditions l Canned types PeriodicFaceBC LinearExtrapolateFaceBC ConstantFaceBC, ZeroFaceBC NegReflectFaceBC, PosReflectFaceBC l User-defined: partial specialization of template class BCond;  class MyBC : public BCondCategory ;  Choose class for Subject parameter, such as Field<>  class BCond, MyBC> { Field ::Domain_t destDomain[,srcDomain]; void applyBoundaryCondition() {...}...}; l Componentwise BC (for multicomponent element types)  template class ComponentBC;

Los Alamos National Laboratory 36 POOMA 2.1 Tiny Types l Multicomponent template class Vector; template class Tensor; template class TinyMatrix; Storage type. POOMA 2.1: only Full Compile-time sizes Post POOMA 2.1: Full, Symmetric, Antisymmetric, Diagonal

Los Alamos National Laboratory 37 FieldStencil template class FieldStencil; Functor::operator(i0,i1,...) methods  scalar code to implement stencil Returns Field Inlines into expressions. Canned Div<>(), grad<>(), average<>() functions use Div<>, Grad<>, Average<> FieldStencils internally. l FieldStencil ::operator()(Field &) May be an expression.

Los Alamos National Laboratory 38 Particles Class Services Particles member functions  create(... ),destroy(... ) Allocate/delete elements in DynamicArray s for all attributes  template void addBoundaryConditions(Subject &s, Object &o, Bctype &b); Add to list of automatic boundary conditions  template void swap(T &attrib) Reassign patch ownership based on attrib values

Los Alamos National Laboratory 39 POOMA 2.1 Particles Boundary Conditions l Really filters: Out-of-range values of one attribute reset values of another.  Subject = Object = position attribute  conventional boundary condition. Canned BC AbsorbBC, KillBC PeriodicBC ReflectBC, ReverseBC l User-defined: partial specialization of template class ParticleBC;  class MyBC : public ParticleBCType ;  Choose class for Subject, Object parameters, such as DynamicArray<>  class ParticleBC, DynamicArray<>, MyBC> { Subject_t subject_m; Object_t object_m; void applyBoundaryCondition(...);

Los Alamos National Laboratory 40 Particle-Field Interpolators l Canned interpolation schemes NGPCICSUDS l Gather/scatter functions gather( attribute, Field, position attribute, scheme ); scatter( attribute, Field, position attribute, scheme ); gatherValue( value, Field, position attribute, scheme ); gatherCache( attribute, Field, position attribute, cache, scheme ); gatherCache( attribute, Field, cache, scheme );