Download presentation
Presentation is loading. Please wait.
Published byAlejandro Peairs Modified over 9 years ago
1
Grid Computing, B. Wilkinson, 200410.1 C Program Command Line Arguments A normal C program specifies command line arguments to be passed to main with: int main(int argc, char *argv[]) where argc is the argument count and argv[] is an array of character pointers. –First entry is a pointer to program name –Subsequent entries point to subsequent strings on the command line.
2
Grid Computing, B. Wilkinson, 200410.2 MPI C program command line arguments Implementations of MPI remove from the argv array any command line arguments used by the implementation. Note MPI_Init requires argc and argv (specified as addresses)
3
Grid Computing, B. Wilkinson, 200410.3 Example Getting Command Line Argument #include “mpi.h” #include int main (int argc, char *argv[]) { int n; /* get and convert character string argument to integer value /* n = atoi(argv[1]); return 0; }
4
Grid Computing, B. Wilkinson, 200410.4 Executing MPI program with command line arguments mpirun -np 2 myProg 56 123 argv[1] argv[2] Remember these array elements hold pointers to the arguments. argv[0] Removed by MPI implementation MPI_Init() ?
5
Grid Computing, B. Wilkinson, 200410.5 More Information on MPI Books: “Using MPI Portable Parallel Programming with the Message-Passing Interface 2nd ed.,” W. Gropp, E. Lusk, and A. Skjellum, The MIT Press,1999. MPICH: http://www.mcs.anl.gov/mpi LAM MPI: http://www.lam-mpi.org
6
Grid Computing, B. Wilkinson, 200410.6 Grid-enabled MPI
7
Grid Computing, B. Wilkinson, 200410.7 Several versions of MPI developed for a grid: MPICH-G, MPI-G2 PACXMPI We will use MPICH-G2, which is based on MPICH for a grid, and uses Globus.
8
Grid Computing, B. Wilkinson, 200410.8 MPI code for the grid No difference in code from regular MPI code. Key aspect is MPI implementation: Communication methods Resource management
9
Grid Computing, B. Wilkinson, 200410.9 Communication Methods Implementation should take into account whether messages are between processor on the same computer or processors on different computers on the network. Pack messages into less larger message, even if this requires more computations
10
Grid Computing, B. Wilkinson, 200410.10 MPICH-G2 Complete implementation of MPI Can use existing MPI programs on a grid without change Uses Globus to start tasks, etc. Version 2 a complete redesign from MPICH-G for Globus 2.2 or later.
11
Grid Computing, B. Wilkinson, 200410.11 Compiling Application Program As with regular MPI programs, compile on each machine you intend to use (unless binary compatible and have common file system). For C programs: /bin/mpicc
12
Grid Computing, B. Wilkinson, 200410.12 Running an MPICH-G2 Program mpirun mpirun submits a Globus RSL script (Resource Specification Language Script) to launch application RSL script can be created by mpirun or you can write your own. RSL script gives powerful mechanism to specify different executables etc., but low level.
13
Grid Computing, B. Wilkinson, 200410.13 mpirun (with it constructing RSL script) Use if want to launch a single executable on binary compatible machines with a shared file system. Requires a “machines” file - a list of computers to be used (and job managers)
14
Grid Computing, B. Wilkinson, 200410.14 “Machines” file Computers listed by their Globus job manager service followed by optional maximum number of node (tasks) on that machine. If job manager omitted (i.e., just name of computer), will default to Globus job manager.
15
Grid Computing, B. Wilkinson, 200410.15 Location of “machines” file mpirun command expects the “ machines ” file either in –the directory specified by -machinefile flag –the current directory used to execute the mpirun command, or –in /bin/machines
16
Grid Computing, B. Wilkinson, 200410.16 Running MPI program Uses the same command line as a regular MPI program: mpirun -np 25 my_prog creates 25 tasks allocated on machines in “machines’ file in around robin fashion
17
Grid Computing, B. Wilkinson, 200410.17 Example With the machines file containing: ”jupitor.cs.wcu.edu" 4 "venus.cs.wcu.edu" 5 and the command: mpirun -np 10 myProg the first 4 processes (jobs) would run on jupitor, the next 5 on venus, and the remaining one on jupitor.
18
Grid Computing, B. Wilkinson, 200410.18 mpirun with your own RSL script Necessary if machines not executing same executable. Easiest way to create script is to modify existing one. Use mpirun -dumprsl which causes script printed out. Application program not launched.
19
Grid Computing, B. Wilkinson, 200410.19 Example mpirun -dumprsl -np 2 myprog will generate appropriate printout of an rsl document according to the details of the job from the command line and machine file.
20
Grid Computing, B. Wilkinson, 200410.20 Given rsl file, myRSL.rsl, use: mpirun -globusrsl myRSL.rsl to submit modified script.. More details and practice in assignment 5 (once I have finished it!)
21
Grid Computing, B. Wilkinson, 200410.21 MPICH-G internals Processes allocated a “machine-local” number and a “grid global” number - translated into where process actually resides. Non-local operations uses grid services Local operations do not. globusrun command submits simultaneous job requests
22
Grid Computing, B. Wilkinson, 200410.22 Limitations “machines” file limits computers to those known - no discovery of resources If machines heterogeneous, need appropriate executables available, and RSL script Speed an issue - original version MPI-G slow.
23
Grid Computing, B. Wilkinson, 200410.23 More information on MPI-G2 http://www.niu.edu/mpi http://www.globus.org/mpi http://www.hpclab.niu.edu/mpi/g2_body.htm
24
Grid Computing, B. Wilkinson, 200410.24 Parallel Programming Techniques Suitable for a Grid
25
Grid Computing, B. Wilkinson, 200410.25 Message-Passing on a Grid VERY expensive, sending data across network costs millions of cycles Bandwidth shared with other users Links unreliable
26
Grid Computing, B. Wilkinson, 200410.26 Computational Strategies As a computing platform, a grid favors situations with absolute minimum communication between computers.
27
Grid Computing, B. Wilkinson, 200410.27 Strategies With no/minimum communication: “Embarrassingly Parallel” Computations –those computations which obviously can be divided into parallel independent parts. Parts executed on separate computers. Separate instance of the same problem executing on each system, each using different data
28
Grid Computing, B. Wilkinson, 200410.28 Embarrassingly Parallel Computations A computation that can obviously be divided into a number of completely independent parts, each of which can be executed by a separate process(or). No communication or very little communication between processes. Each process can do its tasks without any interaction with other processes
29
Grid Computing, B. Wilkinson, 200410.29 Monte Carlo Methods An embarrassingly parallel computation. Monte Carlo methods use of random selections.
30
Grid Computing, B. Wilkinson, 200410.30 Simple Example: To calculate Circle formed within a square, with radius of 1. Square has sides 2 2.
31
Grid Computing, B. Wilkinson, 200410.31 Ratio of area of circle to square given by Area of circle = (1) 2 = Area of square 2 x 2 4 Points within square chosen randomly. Score kept of how many points happen to lie within circle. Fraction of points within circle will be /4, given a sufficient number of randomly selected samples.
32
Grid Computing, B. Wilkinson, 200410.32 Method actually computes an integral. One quadrant of the construction can be described by integral
33
Grid Computing, B. Wilkinson, 200410.33 So can use method to compute any integral! Monte Carlo method very useful if the function cannot be integrated numerically (maybe having a large number of variables).
34
Grid Computing, B. Wilkinson, 200410.34 Alternative (better) “Monte Carlo” Method Use random values of x to compute f (x) and sum values of f (x) where x r are randomly generated values of x between x 1 and x 2. Areaf(x)x d x 1 x 2 1 N ---- N limf( x r ) r i1= N == (x 2 – x 1 ) X1X1 X2X2
35
Grid Computing, B. Wilkinson, 200410.35 Example Computing the integral Sequential Code sum = 0; for (i = 0; i < N; i++) { /* N random samples */ xr = rand_v(x1, x2);/* next random value */ sum = sum + xr * xr - 3 * xr/* compute f(xr)*/ } area = (sum / N) * (x2 - x1); randv(x1, x2) returns pseudorandom number between x1 and x2. x 1 x 2 (x 2 – 3x) dx
36
Grid Computing, B. Wilkinson, 200410.36 For parallelizing Monte Carlo code, must address best way to generate random numbers in parallel. Can use SPRNG (Scalable Pseudo- random Number Generator) -- supposed to be a good parallel random number generator.
37
Grid Computing, B. Wilkinson, 200410.37 Executing separate problem instances In some application areas, same program executed repeatedly - ideal if with different parameters (“parameter sweep”) Nimrod/G -- a grid broker project that targets parameter sweep problems.
38
Grid Computing, B. Wilkinson, 200410.38 Techniques to reduce effects of network communication Latency hiding with communication/computation overlap Better to have fewer larger messages than many smaller ones
39
Grid Computing, B. Wilkinson, 200410.39 Synchronous Algorithms Many tradition parallel algorithms require the parallel processes to synchronize at regular and frequent intervals to exchange data and continue from known points This is bad for grid computations!! All traditional parallel algorithms books have to be thrown away for grid computing.
40
Grid Computing, B. Wilkinson, 200410.40 Techniques to reduce actual synchronization communications Asynchronous algorithms –Algorithms that do not use synchronization at all Partially synchronous algorithms –those that limit the synchronization, for example only synchronize on every n iterations –Actually such algorithms known for many years but not popularized.
41
Grid Computing, B. Wilkinson, 200410.41 Big Problems “Grand challenge” problems Most of the high profile projects on the grid involve problems that are so big usually in number of data items that they cannot be solved otherwise
42
Grid Computing, B. Wilkinson, 200410.42 Examples High-energy physics Bioinformatics Medical databases Combinatorial chemistry Astrophysics
43
Grid Computing, B. Wilkinson, 200410.43 Workflow Technique Use functional decomposition - dividing problem into separate functions which take results from other functions units and pass on results to functional units - interconnection patterns depends upon the problem. Workflow - describes the flow of information between the units.
44
Grid Computing, B. Wilkinson, 200410.44 Example Climate Modeling
45
Grid Computing, B. Wilkinson, 200410.45 Next topic UNC-Wilmington’s GUI workflow editor. Next week Professor Clayton Ferner
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.