Charm++ Arrays, Parameter Marshalling, Load Balancing and what they have in common-- PUP 9/1/2001 Orion Sky Lawlor PPL Developer Bachelor's in Math and.

Slides:



Advertisements
Similar presentations
CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
Advertisements

SEE C GO Provisional Title. Syntax Types int, float, double, char, void Identifiers foo Operators + - * / ^ Delimiters ; {} () “” ‘’ Keywords return,
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Arrays, A1 COMP 401, Fall 2014 Lecture 4 8/28/2014.
CS-1030 Dr. Mark L. Hornick 1 Constructors Copy Constructors.
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
CS Winter 2011 Further Introduction to the C programming language.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Pointers and dynamic objects COMP171 Fall Pointers and dynamic objects/ Slide 2 Topics * Pointers n Memory addresses n Declaration n Dereferencing.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
CS Winter 2011 Introduction to the C programming language.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS 61C L4 Structs (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #4: Strings & Structs
OOP Spring 2007 – Recitation 21 Object Oriented Programming Spring 2007 Recitation 2.
1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation –The new operator –The delete operator –Dynamic.
Templates. Objectives At the conclusion of this lesson, students should be able to Explain how function templates are used Correctly create a function.
1 Procedural Concept The main program coordinates calls to procedures and hands over appropriate data as parameters.
CSC 142 J 1 CSC 142 Arrays [Reading: chapter 10].
Charm++ Load Balancing Framework Gengbin Zheng Parallel Programming Laboratory Department of Computer Science University of Illinois at.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 19 Clicker Questions November 3, 2009.
Pointer Data Type and Pointer Variables
Inheritance. Recall the plant that we defined earlier… class Plant { public: Plant( double theHeight ) : hasLeaves( true ), height (theHeight) { } Plant(
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
1 C - Memory Simple Types Arrays Pointers Pointer to Pointer Multi-dimensional Arrays Dynamic Memory Allocation.
Copyright © 2002, Systems and Computer Engineering, Carleton University a-JavaReview.ppt * Object-Oriented Software Development Unit.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
Week 14 - Monday.  What did we talk about last time?  Introduction to C++  Input and output  Functions  Overloadable  Default parameters  Pass.
Pointers, Variables, and Memory. Variables and Pointers When you declare a variable, memory is allocated to store a value. A pointer can be used to hold.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
1 CS 132 Spring 2008 Chapter 3 Pointers and Array-Based Lists read p
Trees and beyond Tutorial #3 CPSC 261. Trees are just an example The next two weeks in labs we are playing with trees – Trees are interesting – Trees.
1 Pointers to structs. 2 A pointer to a struct is used in the same way as a pointer to a simple type, such as an int. Pointers to structs were introduced.
Copyright 2005, The Ohio State University 1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
CPSC 252 The Big Three Page 1 The “Big Three” Every class that has data members pointing to dynamically allocated memory must implement these three methods:
CS 261 – Data Structures Introduction to C Programming.
CS 261 – Data Structures C Pointers Review. C is Pass By Value Pass-by-value: a copy of the argument is passed in to a parameter void foo (int a) { a.
Charm++ Data-driven Objects L. V. Kale. Parallel Programming Decomposition – what to do in parallel Mapping: –Which processor does each task Scheduling.
OOP in C++ CS 124. Program Structure C++ Program: collection of files Source (.cpp) files be compiled separately to be linked into an executable Files.
Charm++ Data-driven Objects L. V. Kale. Parallel Programming Decomposition – what to do in parallel Mapping: –Which processor does each task Scheduling.
Topics memory alignment and structures typedef for struct names bitwise & for viewing bits malloc and free (dynamic storage in C) new and delete (dynamic.
Data Structures Using C++1 Chapter 3 Pointers and Array-Based Lists.
Implementation: Charm++ Orion Sky Lawlor
Charm++ overview L. V. Kale. Parallel Programming Decomposition – what to do in parallel –Tasks (loop iterations, functions,.. ) that can be done in parallel.
CMSC 202 Computer Science II for Majors. CMSC 202UMBC Topics Memory management operators Dynamic memory Project 2 questions.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Pointers and Dynamic Arrays.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
1 Memory as byte array Pointers Arrays relationship to pointers Operator ‘new’ Operator ‘delete’ Copy ctor Assignment operator ‘this’ const pointer Allocating.
1 Recall that... char str [ 8 ]; str is the base address of the array. We say str is a pointer because its value is an address. It is a pointer constant.
1 Chapter 15-1 Pointers, Dynamic Data, and Reference Types Dale/Weems.
Programming in C Arrays, Structs and Strings. 7/28/092 Arrays An array is a collection of individual data elements that is:An array is a collection of.
CS162 - Topic #6 Lecture: Pointers and Dynamic Memory –Review –Dynamically allocating structures –Combining the notion of classes and pointers –Destructors.
Object-Oriented programming in C++ Classes as units of encapsulation Information Hiding Inheritance polymorphism and dynamic dispatching Storage management.
1 Creating Simulations with POSE Terry L. Wilmarth, Nilesh Choudhury, David Kunzman, Eric Bohm Parallel Programming Laboratory University of Illinois at.
Pointer Variables A pointer is a variable that contains a memory address The address is commonly the location of another variable in memory This pointer.
1 Charm++ Tutorial Parallel Programming Laboratory, UIUC.
Using Charm++ with Arrays Laxmikant (Sanjay) Kale Parallel Programming Lab Department of Computer Science, UIUC charm.cs.uiuc.edu.
1 Network Access to Charm Programs: CCS Orion Sky Lawlor 2003/10/20.
1 Structures & Unions. 2 User-Defined Types C provides facilities to define one’s own types. These may be a composite of basic types ( int, double, etc)
Accelerating Large Charm++ Messages using RDMA
This pointer, Dynamic memory allocation, Constructors and Destructor
Chapter 15 Pointers, Dynamic Data, and Reference Types
Chapter 15 Pointers, Dynamic Data, and Reference Types
Java Programming Language
Screen shots – Load imbalance
Presentation transcript:

Charm++ Arrays, Parameter Marshalling, Load Balancing and what they have in common-- PUP 9/1/2001 Orion Sky Lawlor PPL Developer Bachelor's in Math and CS from Univ. of Alaska at Fairbanks MS in CS from UIUC

Arrays: the Basic Idea " So there's some parallel object " How do you talk to it? " MPI approach: send a message to the processor number " Make migration (almost) impossible " Makes load balancing (almost) impossible " Array approach: send message to array index (1D, 2D, etc.)

Array Syntax (.ci) module demo { array [1D] A { entry A(void); entry void foo(void); }

Array Syntax (.h) class A:public ArrayElement1D { public: A(void); void foo(void); //For migration: A(CkMigrateMessage *) { } void pup(PUP::er &p); };

Array Creation... in main chare... int n=17; CProxy_A ap=CProxy_A:: ckNew(n);//Create array //Elements numbered {0..n-1} //Always dense //Always 1D

Sparse Array Creation... in main chare... int n=17; CProxy_A ap=CProxy_A:: ckNew();//Create array for (int i=0;i<n;i++) ap[7+2*i].insert(); ap.doneInserting(); //Don't forget the doneInserting!

Array Messaging //Just index the array proxy ap[7].foo(); //Or can make element proxy: CProxyElement_A aep=ap[9]; aep.foo(); //For higher dimensions: ap2(x,y).foo(); ap3(x,y,z).foo();

Array Broadcast //Leave off the index: ap.foo(); " Invokes foo on every existing array element " Works even with migrations " Bad syntax: easy to broadcast by mistake, causing disaster!

Array Reduction int myData[2]={...}; contribute(2*sizeof(int), (void *)&myData, CkReduction::sum_int); " Called from every array element " Collects result to PE 0 & calls fn: void myCli(void *userData, int redLen,void *redData); ap.setReductionClient(myCli,userData);

Arrays PUP

PUP-- Wazzup? " Before PUP, had to write 3 functions: " size-- compute message size, in bytes " pack-- write object into message " unpack-- read object out of message " PUP combines all three into one " Basic contract: here are my fields (types, sizes, and a pointer) " C++ version uses operator overloading for very spartan syntax-- just parens() and bar|

PUP Single Fields class simple { int x; float y; public: simple() { }... other methods... void pup(PUP::er &p) { p|x; p|y; } }; PUPmarshall(simple);

PUP Arrays class withArray { public: int n; double *d;//Holds n doubles simple() {n=0;d=NULL;} ~simple() { delete[] d;}... other methods... void pup(PUP::er &p) { p|n; if (p.isUnpacking()) d=new double[n]; p(d,n); } }; PUPmarshall(withArray);

PUP Subobject class sub { public: simple *s;//Holds a subobject sub() {s=NULL;} ~sub() { delete s;}... other methods... void pup(PUP::er &p) { if (p.isUnpacking()) s=new simple; s->pup(p); } }; PUPmarshall(sub);

PUP::able & auto-allocate class A:public PUP::able { public:... other methods... A(CkMigrateMessage *) { } virtual void pup(PUP::er &p); PUPable_decl(A); }; PUPable_def(A); (...in an initcall routine...) PUPable_reg(A); (...in some object's pup...) p|a;

PUP::able & trees class A:public PUP::able { A *left,*right;... as before... }; void A::pup(PUP::er &p) { p|left; p|right; } " Packs, allocates, and unpacks left and right children automatically " Works properly with NULL pointers " Doesn't work for object graphs with cycles! (Never terminates)

PUP::able & inheritance class B:public A {... the usual... PUPable_decl(B); }; PUPable_def(B); (...in an initcall routine...) PUPable_reg(B); " Now an A pointer that actually points to a B object will be restored properly-- B::pup will be called. " Combines well with virtual functions.

PUP Param. Marshall

Parameter Marshalling entry void foo(void); entry void bar(int a,int b); entry void baz(float f[7]); entry void far(int n,double d[n]); entry void boo(int n,int m, unsigned char area[n*m]); entry void oof(char s[strlen(s)+1]); entry void fub(something_t s); " Arrays passed as pointers in C++ " Array length evaluated on call side " Can declare everything “const", “&"

Param. Marshalling & PUP entry void foo(T a, V b); " Gets translated into: //Send side: CProxy_A::foo(T &a, V &b) {...make PUP::er &p... p|a; p|b;...use resulting p... } //Recv. side:...in call-foo function... T a; V b; p|a; p|b; obj->foo(a,b); " Because there’s a default bar operator, T and V can be C structs; which are copied as bytes. " Because you can overload the bar operator using PUP_Marshall, if T and V have pup routines they’ll be called properly! " Makes marshalling flexible.

Param. Marshall Load Balancing

" All you need is a working pup " Load balancer will migrate constantly " Create the load balancer with: //In the.ci file: extern module RefineLB; //In the.C file: #include "RefineLB.h" //In the main chare: CreateRefineLB(); //Also: CommLB, GreedyRefLB, HeapCentLB, MetisLB, NeighborLB

AtSync Load Balancing " When you need more control over when balancing happens. " Create balancer as usual, then: //In the element constructor: usesAtSync=CmiTrue; //When ready to balance call: AtSync(); //When computation resumes, void ResumeFromSync(void); //gets called on each element.

Conclusion " Arrays support messaging, broadcasts, reductions, and migration " Migration is for load balance " Migration uses PUP " Parameter marshalling uses PUP " Can get lots of functionality (almost) for free with PUP