SlideShare a Scribd company logo
1 of 59
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.1
Message-Passing Computing
Chapter 2
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.2
Message-Passing Programming using
User-level Message-Passing Libraries
Two primary mechanisms needed:
1. A method of creating separate processes for
execution on different computers
2. A method of sending and receiving messages
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.3
Multiple program, multiple data (MPMD)
model
Source
file
Executable
Processor 0 Processor p - 1
Compile to suit
processor
Source
file
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.4
Single Program Multiple Data (SPMD) model
.
Source
file
Executables
Processor 0 Processor p - 1
Compile to suit
processor
Basic MPI way
Different processes merged into one program. Control
statements select different parts for each processor to
execute. All executables started together - static process
creation
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.5
Multiple Program Multiple Data (MPMD) Model
Process 1
Process 2
spawn();
Time
Start execution
of process 2
Separate programs for each processor. One processor
executes master process. Other processes started from within
master process - dynamic process creation.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.6
Basic “point-to-point”
Send and Receive Routines
Process 1 Process 2
send(&x, 2);
recv(&y, 1);
x y
Movement
of data
Generic syntax (actual formats later)
Passing a message between processes using
send() and recv() library calls:
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.7
Synchronous Message Passing
Routines that actually return when message transfer
completed.
Synchronous send routine
• Waits until complete message can be accepted by the
receiving process before sending the message.
Synchronous receive routine
• Waits until the message it is expecting arrives.
Synchronous routines intrinsically perform two actions:
They transfer data and they synchronize processes.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.8
Synchronous send() and recv() using 3-way
protocol
Process 1 Process 2
send();
recv();
Suspend
Time
process
Acknowledgment
Message
Both processes
continue
(a) When send() occurs before recv()
Process 1 Process 2
recv();
send();
Suspend
Time
process
Acknowledgment
Message
Both processes
continue
(b) When recv() occurs before send()
Request to send
Request to send
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.9
Asynchronous Message Passing
• Routines that do not wait for actions to complete before
returning. Usually require local storage for messages.
• More than one version depending upon the actual
semantics for returning.
• In general, they do not synchronize processes but allow
processes to move forward sooner. Must be used with
care.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.10
MPI Definitions of Blocking and Non-
Blocking
• Blocking - return after their local actions complete,
though the message transfer may not have been
completed.
• Non-blocking - return immediately.
Assumes that data storage used for transfer not modified
by subsequent statements prior to being used for
transfer, and it is left to the programmer to ensure this.
These terms may have different interpretations in other
systems.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.11
How message-passing routines return
before message transfer completed
Process 1 Process 2
send();
recv();
Message buffer
Read
message buffer
Continue
process
Time
Message buffer needed between source and
destination to hold message:
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.12
Asynchronous (blocking) routines
changing to synchronous routines
• Once local actions completed and message is safely
on its way, sending process can continue with
subsequent work.
• Buffers only of finite length and a point could be
reached when send routine held up because all
available buffer space exhausted.
• Then, send routine will wait until storage becomes re-
available - i.e then routine behaves as a synchronous
routine.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.13
Message Tag
• Used to differentiate between different types
of messages being sent.
• Message tag is carried within message.
• If special type matching is not required, a wild
card message tag is used, so that the recv()
will match with any send().
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.14
Message Tag Example
Process 1 Process 2
send(&x,2, 5);
recv(&y,1, 5);
x y
Movement
of data
Waits for a message from process 1 with a tag of 5
To send a message, x, with message tag 5 from
a source process, 1, to a destination process, 2,
and assign to y:
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.15
“Group” message passing routines
Have routines that send message(s) to a group
of processes or receive message(s) from a
group of processes
Higher efficiency than separate point-to-point
routines although not absolutely necessary.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.16
Broadcast
Sending same message to all processes concerned with
problem.
Multicast - sending same message to defined group of
processes.
bcast();
buf
bcast();
data
bcast();
data
data
Process 0 Process p - 1
Process 1
Action
Code
MPI form
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.17
Scatter
scatter();
buf
scatter();
data
scatter();
data
data
Process 0 Process p - 1
Process 1
Action
Code
MPI form
Sending each element of an array in root process
to a separate process. Contents of ith location of
array sent to ith process.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.18
Gather
gather();
buf
gather();
data
gather();
data
data
Process 0 Process p - 1
Process 1
Action
Code
MPI form
Having one process collect individual values
from set of processes.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.19
Reduce
reduce();
buf
reduce();
data
reduce();
data
data
Process 0 Process p - 1
Process 1
+
Action
Code
MPI form
Gather operation combined with specified
arithmetic/logical operation.
Example: Values could be gathered and then
added together by root:
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.20
PVM
(Parallel Virtual Machine)
Perhaps first widely adopted attempt at using a workstation
cluster as a multicomputer platform, developed by Oak
Ridge National Laboratories. Available at no charge.
Programmer decomposes problem into separate programs
(usually master and group of identical slave programs).
Programs compiled to execute on specific types of
computers.
Set of computers used on a problem first must be defined
prior to executing the programs (in a hostfile).
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.21
Message routing between computers done by PVM daemon processes
installed by PVM on computers that form the virtual machine.
PVM
Application
daemon
program
Workstation
PVM
daemon
Application
program
Application
program
PVM
daemon
Workstation
Workstation
Messages
sent through
network
(executable)
(executable)
(executable)
MPI implementation we use is similar.
Can have more than one process
running on each computer.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.22
MPI
(Message Passing Interface)
• Message passing library standard developed
by group of academics and industrial partners
to foster more widespread use and portability.
• Defines routines, not implementation.
• Several free implementations exist.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.23
MPI
Process Creation and Execution
• Purposely not defined - Will depend upon
implementation.
• Only static process creation supported in MPI version 1.
All processes must be defined prior to execution and
started together.
• Originally SPMD model of computation.
• MPMD also possible with static creation - each program
to be started together specified.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.24
Communicators
• Defines scope of a communication operation.
• Processes have ranks associated with communicator.
• Initially, all processes enrolled in a “universe” called
MPI_COMM_WORLD, and each process is given a
unique rank, a number from 0 to p - 1, with p
processes.
• Other communicators can be established for groups of
processes.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.25
Using SPMD Computational Model
main (int argc, char *argv[])
{
MPI_Init(&argc, &argv);
.
.
MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /*find process rank */
if (myrank == 0)
master();
else
slave();
.
.
MPI_Finalize();
}
where master() and slave() are to be executed by master
process and slave process, respectively.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.26
Unsafe message passing - Example
lib()
lib()
send(…,1,…);
recv(…,0,…);
Process 0 Process 1
send(…,1,…);
recv(…,0,…);
(a) Intended behavior
(b) Possible behavior
lib()
lib()
send(…,1,…);
recv(…,0,…);
Process 0 Process 1
send(…,1,…);
recv(…,0,…);
Destination
Source
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.27
MPI Solution
“Communicators”
• Defines a communication domain - a set of
processes that are allowed to communicate
between themselves.
• Communication domains of libraries can be
separated from that of a user program.
• Used in all point-to-point and collective MPI
message-passing communications.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.28
Default Communicator
MPI_COMM_WORLD
• Exists as first communicator for all processes
existing in the application.
• A set of MPI routines exists for forming
communicators.
• Processes have a “rank” in a communicator.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.29
MPI Point-to-Point Communication
• Uses send and receive routines with
message tags (and communicator).
• Wild card message tags available
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.30
MPI Blocking Routines
• Return when “locally complete” - when location
used to hold message can be used again or
altered without affecting message being sent.
• Blocking send will send message and return -
does not mean that message has been
received, just that process free to move on
without adversely affecting message.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.31
Parameters of blocking send
MPI_Send(buf, count, datatype, dest, tag, comm)
Address of
Number of items
Datatype of
Rank of destination
Message tag
Communicator
send buffer
to send
each item
process
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.32
Parameters of blocking receive
MPI_Recv(buf, count, datatype, src, tag, comm, status)
Address of
Maximum number
Datatype of
Rank of source
Message tag
Communicator
receive buffer
of items to receive
each item
process
Status
after operation
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.33
Example
To send an integer x from process 0 to process 1,
MPI_Comm_rank(MPI_COMM_WORLD,&myrank); /* find rank */
if (myrank == 0) {
int x;
MPI_Send(&x, 1, MPI_INT, 1, msgtag, MPI_COMM_WORLD);
} else if (myrank == 1) {
int x;
MPI_Recv(&x, 1, MPI_INT,
0,msgtag,MPI_COMM_WORLD,status);
}
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.34
MPI Nonblocking Routines
• Nonblocking send - MPI_Isend() - will return
“immediately” even before source location is
safe to be altered.
• Nonblocking receive - MPI_Irecv() - will return
even if no message to accept.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.35
Nonblocking Routine Formats
MPI_Isend(buf,count,datatype,dest,tag,comm,request)
MPI_Irecv(buf,count,datatype,source,tag,comm, request)
Completion detected by MPI_Wait() and MPI_Test().
MPI_Wait() waits until operation completed and returns then.
MPI_Test() returns with flag set indicating whether operation completed
at that time.
Need to know whether particular operation completed.
Determined by accessing request parameter.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.36
Example
To send an integer x from process 0 to process 1
and allow process 0 to continue,
MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* find rank */
if (myrank == 0) {
int x;
MPI_Isend(&x,1,MPI_INT, 1, msgtag, MPI_COMM_WORLD, req1);
compute();
MPI_Wait(req1, status);
} else if (myrank == 1) {
int x;
MPI_Recv(&x,1,MPI_INT,0,msgtag, MPI_COMM_WORLD, status);
}
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.37
Send Communication Modes
• Standard Mode Send - Not assumed that corresponding
receive routine has started. Amount of buffering not defined
by MPI. If buffering provided, send could complete before
receive reached.
• Buffered Mode - Send may start and return before a
matching receive. Necessary to specify buffer space via
routine MPI_Buffer_attach().
• Synchronous Mode - Send and receive can start before
each other but can only complete together.
• Ready Mode - Send can only start if matching receive
already reached, otherwise error. Use with care.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.38
• Each of the four modes can be applied to
both blocking and nonblocking send routines.
• Only the standard mode is available for the
blocking and nonblocking receive routines.
• Any type of send routine can be used with
any type of receive routine.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.39
Collective Communication
Involves set of processes, defined by an intra-communicator.
Message tags not present. Principal collective operations:
• MPI_Bcast() - Broadcast from root to all other processes
• MPI_Gather() - Gather values for group of processes
• MPI_Scatter() - Scatters buffer in parts to group of processes
• MPI_Alltoall() - Sends data from all processes to all processes
• MPI_Reduce() - Combine values on all processes to single value
• MPI_Reduce_scatter() - Combine values and scatter results
• MPI_Scan() - Compute prefix reductions of data on processes
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.40
Example
To gather items from group of processes into process
0, using dynamically allocated memory in root
process:
int data[10]; /*data to be gathered from processes*/
MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* find rank */
if (myrank == 0) {
MPI_Comm_size(MPI_COMM_WORLD, &grp_size); /*find group size*/
buf = (int *)malloc(grp_size*10*sizeof (int)); /*allocate
memory*/
}
MPI_Gather(data,10,MPI_INT,buf,grp_size*10,MPI_INT,0,MPI_COMM_WORLD) ;
MPI_Gather() gathers from all processes, including root.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.41
Barrier routine
• A means of synchronizing processes by
stopping each one until they all have reached
a specific “barrier” call.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.42
Sample MPI program
#include “mpi.h”
#include <stdio.h>
#include <math.h>
#define MAXSIZE 1000
void main(int argc, char *argv)
{
int myid, numprocs;
int data[MAXSIZE], i, x, low, high, myresult, result;
char fn[255];
char *fp;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
if (myid == 0) { /* Open input file and initialize data */
strcpy(fn,getenv(“HOME”));
strcat(fn,”/MPI/rand_data.txt”);
if ((fp = fopen(fn,”r”)) == NULL) {
printf(“Can’t open the input file: %snn”, fn);
exit(1);
}
for(i = 0; i < MAXSIZE; i++) fscanf(fp,”%d”, &data[i]);
}
MPI_Bcast(data, MAXSIZE, MPI_INT, 0, MPI_COMM_WORLD); /* broadcast data */
x = n/nproc; /* Add my portion Of data */
low = myid * x;
high = low + x;
for(i = low; i < high; i++)
myresult += data[i];
printf(“I got %d from %dn”, myresult, myid); /* Compute global sum */
MPI_Reduce(&myresult, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (myid == 0) printf(“The sum is %d.n”, result);
MPI_Finalize();
}
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.43
Evaluating Parallel Programs
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.44
Sequential execution time, ts: Estimate by
counting computational steps of best sequential
algorithm.
Parallel execution time, tp: In addition to number
of computational steps, tcomp, need to estimate
communication overhead, tcomm:
tp = tcomp + tcomm
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.45
Computational Time
Count number of computational steps.
When more than one process executed simultaneously,
count computational steps of most complex process.
Generally, function of n and p, i.e.
tcomp = f (n, p)
Often break down computation time into parts. Then
tcomp = tcomp1 + tcomp2 + tcomp3 + …
Analysis usually done assuming that all processors are
same and operating at same speed.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.46
Communication Time
Many factors, including network structure and
network contention. As a first approximation,
use
tcomm = tstartup + ntdata
tstartup is startup time, essentially time to send a
message with no data. Assumed to be constant.
tdata is transmission time to send one data word,
also assumed constant, and there are n data
words.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.47
Idealized Communication Time
Number of data items (
n)
Startup time
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.48
Final communication time, tcomm
Summation of communication times of all
sequential messages from a process, i.e.
tcomm = tcomm1 + tcomm2 + tcomm3 + …
Communication patterns of all processes assumed
same and take place together so that only one
process need be considered.
Both tstartup and tdata, measured in units of one
computational step, so that can add tcomp and tcomm
together to obtain parallel execution time, tp.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.49
Benchmark Factors
With ts, tcomp, and tcomm, can establish speedup
factor and computation/communication ratio for
a particular algorithm/implementation:
Both functions of number of processors, p, and
number of data elements, n.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.50
Factors give indication of scalability of parallel
solution with increasing number of processors and
problem size.
Computation/communication ratio will highlight
effect of communication with increasing problem
size and system size.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.51
Debugging/Evaluating Parallel
Programs Empirically
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.52
Visualization Tools
Programs can be watched as they are executed in
a space-time diagram (or process-time diagram):
Process 1
Process 2
Process 3
Time
Computing
Waiting
Message-passing system routine
Message
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.53
Implementations of visualization tools are
available for MPI.
An example is the Upshot program visualization
system.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.54
Evaluating Programs Empirically
Measuring Execution Time
To measure the execution time between point L1 and point L2
in the code, we might have a construction such as
.
L1: time(&t1); /* start timer */
.
.
L2: time(&t2); /* stop timer */
.
elapsed_time = difftime(t2, t1); /* elapsed_time = t2 - t1 */
printf(“Elapsed time = %5.2f seconds”, elapsed_time);
MPI provides the routine MPI_Wtime() for returning time (in
seconds).
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.55
Parallel Programming Home Page
http://www.cs.uncc.edu/par_prog
Gives step-by-step instructions for compiling
and executing programs, and other information.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.56
Compiling/Executing MPI Programs
Preliminaries
• Set up paths
• Create required directory structure
• Create a file (hostfile) listing machines to be
used (required)
Details described on home page.
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.57
Hostfile
Before starting MPI for the first time, need to
create a hostfile
Sample hostfile
ws404
#is-sm1 //Currently not executing, commented
pvm1 //Active processors, UNCC sun cluster called pvm1 - pvm8
pvm2
pvm3
pvm4
pvm5
pvm6
pvm7
pvm8
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.58
Compiling/executing (SPMD) MPI program
For LAM MPI version 6.5.2. At a command line:
To start MPI:
First time: lamboot -v hostfile
Subsequently: lamboot
To compile MPI programs:
mpicc -o file file.c
or mpiCC -o file file.cpp
To execute MPI program:
mpirun -v -np no_processors file
To remove processes for reboot
lamclean -v
Terminate LAM
lamhalt
If fails
wipe -v lamhost
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved.
2.59
Compiling/Executing Multiple MPI Programs
Create a file specifying programs:
Example
1 master and 2 slaves, “appfile” contains
n0 master
n0-1 slave
To execute:
mpirun -v appfile
Sample output
3292 master running on n0 (o)
3296 slave running on n0 (o)
412 slave running on n1

More Related Content

Similar to slides2.ppt

Software Architecture taxonomies - Integration patterns
Software Architecture taxonomies - Integration patternsSoftware Architecture taxonomies - Integration patterns
Software Architecture taxonomies - Integration patternsJose Emilio Labra Gayo
 
Message passing Programing and MPI.
Message passing Programing and MPI.Message passing Programing and MPI.
Message passing Programing and MPI.Munawar Hussain
 
applicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.pptapplicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.pptDEEPAK948083
 
Ch21 OS
Ch21 OSCh21 OS
Ch21 OSC.U
 
Satyam_Singh_cv
Satyam_Singh_cvSatyam_Singh_cv
Satyam_Singh_cvSatyam Singh
 
slides4.ppt
slides4.pptslides4.ppt
slides4.pptnazimsattar
 
A NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdf
A NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdfA NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdf
A NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdfSaiReddy794166
 
Application cloudification with liberty and urban code deploy - UCD
Application cloudification with liberty and urban code deploy - UCDApplication cloudification with liberty and urban code deploy - UCD
Application cloudification with liberty and urban code deploy - UCDDavide Veronese
 
IRJET - Code Compiler Shell
IRJET -  	  Code Compiler ShellIRJET -  	  Code Compiler Shell
IRJET - Code Compiler ShellIRJET Journal
 
NSA Capstone Project III final pp
NSA Capstone Project III final ppNSA Capstone Project III final pp
NSA Capstone Project III final ppAlfonso Zamorano
 
Performance Analysis of VoIP by Communicating Two Systems
Performance Analysis of VoIP by Communicating Two Systems Performance Analysis of VoIP by Communicating Two Systems
Performance Analysis of VoIP by Communicating Two Systems IOSR Journals
 
Chapter2 application
Chapter2 applicationChapter2 application
Chapter2 applicationVan Quang Tran
 
Week3 applications
Week3 applicationsWeek3 applications
Week3 applicationsDigvijay Singh
 
Robin_Informatica
Robin_InformaticaRobin_Informatica
Robin_InformaticaRobin Goyal
 

Similar to slides2.ppt (20)

Why meteor
Why meteorWhy meteor
Why meteor
 
Software Architecture taxonomies - Integration patterns
Software Architecture taxonomies - Integration patternsSoftware Architecture taxonomies - Integration patterns
Software Architecture taxonomies - Integration patterns
 
Message passing Programing and MPI.
Message passing Programing and MPI.Message passing Programing and MPI.
Message passing Programing and MPI.
 
applicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.pptapplicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.ppt
 
Ch21 OS
Ch21 OSCh21 OS
Ch21 OS
 
OSCh21
OSCh21OSCh21
OSCh21
 
OS_Ch21
OS_Ch21OS_Ch21
OS_Ch21
 
Satyam_Singh_cv
Satyam_Singh_cvSatyam_Singh_cv
Satyam_Singh_cv
 
3rd edition chapter2
3rd edition chapter23rd edition chapter2
3rd edition chapter2
 
slides4.ppt
slides4.pptslides4.ppt
slides4.ppt
 
A NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdf
A NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdfA NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdf
A NETWORK-BASED DAC OPTIMIZATION PROTOTYPE SOFTWARE 2 (1).pdf
 
005281271.pdf
005281271.pdf005281271.pdf
005281271.pdf
 
Application cloudification with liberty and urban code deploy - UCD
Application cloudification with liberty and urban code deploy - UCDApplication cloudification with liberty and urban code deploy - UCD
Application cloudification with liberty and urban code deploy - UCD
 
IRJET - Code Compiler Shell
IRJET -  	  Code Compiler ShellIRJET -  	  Code Compiler Shell
IRJET - Code Compiler Shell
 
NSA Capstone Project III final pp
NSA Capstone Project III final ppNSA Capstone Project III final pp
NSA Capstone Project III final pp
 
FINODEX introduces FIWARE
FINODEX introduces FIWAREFINODEX introduces FIWARE
FINODEX introduces FIWARE
 
Performance Analysis of VoIP by Communicating Two Systems
Performance Analysis of VoIP by Communicating Two Systems Performance Analysis of VoIP by Communicating Two Systems
Performance Analysis of VoIP by Communicating Two Systems
 
Chapter2 application
Chapter2 applicationChapter2 application
Chapter2 application
 
Week3 applications
Week3 applicationsWeek3 applications
Week3 applications
 
Robin_Informatica
Robin_InformaticaRobin_Informatica
Robin_Informatica
 

More from nazimsattar

Pr.SE2.361101659.pptx
Pr.SE2.361101659.pptxPr.SE2.361101659.pptx
Pr.SE2.361101659.pptxnazimsattar
 
vehiculr networks.ppt
vehiculr networks.pptvehiculr networks.ppt
vehiculr networks.pptnazimsattar
 
ad-hoc 16 4 2018.ppt
ad-hoc 16 4 2018.pptad-hoc 16 4 2018.ppt
ad-hoc 16 4 2018.pptnazimsattar
 
Cellular Wireless Networks p1 chap 2.pptx
Cellular Wireless Networks p1 chap 2.pptxCellular Wireless Networks p1 chap 2.pptx
Cellular Wireless Networks p1 chap 2.pptxnazimsattar
 
Cellular Wireless Networks part2.pptx
Cellular Wireless Networks part2.pptxCellular Wireless Networks part2.pptx
Cellular Wireless Networks part2.pptxnazimsattar
 
slides11.ppt
slides11.pptslides11.ppt
slides11.pptnazimsattar
 
types of DS.ppt
types of DS.ppttypes of DS.ppt
types of DS.pptnazimsattar
 
parallel programming.ppt
parallel programming.pptparallel programming.ppt
parallel programming.pptnazimsattar
 
slides10.ppt
slides10.pptslides10.ppt
slides10.pptnazimsattar
 
slides9.ppt
slides9.pptslides9.ppt
slides9.pptnazimsattar
 
351101835.pptx
351101835.pptx351101835.pptx
351101835.pptxnazimsattar
 
351101042.ppt
351101042.ppt351101042.ppt
351101042.pptnazimsattar
 
331103344.ppt
331103344.ppt331103344.ppt
331103344.pptnazimsattar
 
381101843.pptx
381101843.pptx381101843.pptx
381101843.pptxnazimsattar
 
372103483.pptx
372103483.pptx372103483.pptx
372103483.pptxnazimsattar
 
pl10ch2.ppt
pl10ch2.pptpl10ch2.ppt
pl10ch2.pptnazimsattar
 
e3-chap-08.ppt
e3-chap-08.ppte3-chap-08.ppt
e3-chap-08.pptnazimsattar
 
DTUI5_chap06.ppt
DTUI5_chap06.pptDTUI5_chap06.ppt
DTUI5_chap06.pptnazimsattar
 

More from nazimsattar (20)

Pr.SE2.361101659.pptx
Pr.SE2.361101659.pptxPr.SE2.361101659.pptx
Pr.SE2.361101659.pptx
 
ch10.ppt
ch10.pptch10.ppt
ch10.ppt
 
vehiculr networks.ppt
vehiculr networks.pptvehiculr networks.ppt
vehiculr networks.ppt
 
ad-hoc 16 4 2018.ppt
ad-hoc 16 4 2018.pptad-hoc 16 4 2018.ppt
ad-hoc 16 4 2018.ppt
 
Cellular Wireless Networks p1 chap 2.pptx
Cellular Wireless Networks p1 chap 2.pptxCellular Wireless Networks p1 chap 2.pptx
Cellular Wireless Networks p1 chap 2.pptx
 
Cellular Wireless Networks part2.pptx
Cellular Wireless Networks part2.pptxCellular Wireless Networks part2.pptx
Cellular Wireless Networks part2.pptx
 
slides11.ppt
slides11.pptslides11.ppt
slides11.ppt
 
types of DS.ppt
types of DS.ppttypes of DS.ppt
types of DS.ppt
 
parallel programming.ppt
parallel programming.pptparallel programming.ppt
parallel programming.ppt
 
slides10.ppt
slides10.pptslides10.ppt
slides10.ppt
 
slides9.ppt
slides9.pptslides9.ppt
slides9.ppt
 
chap2.ppt
chap2.pptchap2.ppt
chap2.ppt
 
351101835.pptx
351101835.pptx351101835.pptx
351101835.pptx
 
351101042.ppt
351101042.ppt351101042.ppt
351101042.ppt
 
331103344.ppt
331103344.ppt331103344.ppt
331103344.ppt
 
381101843.pptx
381101843.pptx381101843.pptx
381101843.pptx
 
372103483.pptx
372103483.pptx372103483.pptx
372103483.pptx
 
pl10ch2.ppt
pl10ch2.pptpl10ch2.ppt
pl10ch2.ppt
 
e3-chap-08.ppt
e3-chap-08.ppte3-chap-08.ppt
e3-chap-08.ppt
 
DTUI5_chap06.ppt
DTUI5_chap06.pptDTUI5_chap06.ppt
DTUI5_chap06.ppt
 

Recently uploaded

NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Ramkumar k
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesChandrakantDivate1
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...vershagrag
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X79953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxNANDHAKUMARA10
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...gragchanchal546
 

Recently uploaded (20)

NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...
Ghuma $ Russian Call Girls Ahmedabad â‚ą7.5k Pick Up & Drop With Cash Payment 8...
 

slides2.ppt

  • 1. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.1 Message-Passing Computing Chapter 2
  • 2. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.2 Message-Passing Programming using User-level Message-Passing Libraries Two primary mechanisms needed: 1. A method of creating separate processes for execution on different computers 2. A method of sending and receiving messages
  • 3. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.3 Multiple program, multiple data (MPMD) model Source file Executable Processor 0 Processor p - 1 Compile to suit processor Source file
  • 4. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.4 Single Program Multiple Data (SPMD) model . Source file Executables Processor 0 Processor p - 1 Compile to suit processor Basic MPI way Different processes merged into one program. Control statements select different parts for each processor to execute. All executables started together - static process creation
  • 5. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.5 Multiple Program Multiple Data (MPMD) Model Process 1 Process 2 spawn(); Time Start execution of process 2 Separate programs for each processor. One processor executes master process. Other processes started from within master process - dynamic process creation.
  • 6. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.6 Basic “point-to-point” Send and Receive Routines Process 1 Process 2 send(&x, 2); recv(&y, 1); x y Movement of data Generic syntax (actual formats later) Passing a message between processes using send() and recv() library calls:
  • 7. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.7 Synchronous Message Passing Routines that actually return when message transfer completed. Synchronous send routine • Waits until complete message can be accepted by the receiving process before sending the message. Synchronous receive routine • Waits until the message it is expecting arrives. Synchronous routines intrinsically perform two actions: They transfer data and they synchronize processes.
  • 8. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.8 Synchronous send() and recv() using 3-way protocol Process 1 Process 2 send(); recv(); Suspend Time process Acknowledgment Message Both processes continue (a) When send() occurs before recv() Process 1 Process 2 recv(); send(); Suspend Time process Acknowledgment Message Both processes continue (b) When recv() occurs before send() Request to send Request to send
  • 9. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.9 Asynchronous Message Passing • Routines that do not wait for actions to complete before returning. Usually require local storage for messages. • More than one version depending upon the actual semantics for returning. • In general, they do not synchronize processes but allow processes to move forward sooner. Must be used with care.
  • 10. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.10 MPI Definitions of Blocking and Non- Blocking • Blocking - return after their local actions complete, though the message transfer may not have been completed. • Non-blocking - return immediately. Assumes that data storage used for transfer not modified by subsequent statements prior to being used for transfer, and it is left to the programmer to ensure this. These terms may have different interpretations in other systems.
  • 11. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.11 How message-passing routines return before message transfer completed Process 1 Process 2 send(); recv(); Message buffer Read message buffer Continue process Time Message buffer needed between source and destination to hold message:
  • 12. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.12 Asynchronous (blocking) routines changing to synchronous routines • Once local actions completed and message is safely on its way, sending process can continue with subsequent work. • Buffers only of finite length and a point could be reached when send routine held up because all available buffer space exhausted. • Then, send routine will wait until storage becomes re- available - i.e then routine behaves as a synchronous routine.
  • 13. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.13 Message Tag • Used to differentiate between different types of messages being sent. • Message tag is carried within message. • If special type matching is not required, a wild card message tag is used, so that the recv() will match with any send().
  • 14. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.14 Message Tag Example Process 1 Process 2 send(&x,2, 5); recv(&y,1, 5); x y Movement of data Waits for a message from process 1 with a tag of 5 To send a message, x, with message tag 5 from a source process, 1, to a destination process, 2, and assign to y:
  • 15. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.15 “Group” message passing routines Have routines that send message(s) to a group of processes or receive message(s) from a group of processes Higher efficiency than separate point-to-point routines although not absolutely necessary.
  • 16. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.16 Broadcast Sending same message to all processes concerned with problem. Multicast - sending same message to defined group of processes. bcast(); buf bcast(); data bcast(); data data Process 0 Process p - 1 Process 1 Action Code MPI form
  • 17. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.17 Scatter scatter(); buf scatter(); data scatter(); data data Process 0 Process p - 1 Process 1 Action Code MPI form Sending each element of an array in root process to a separate process. Contents of ith location of array sent to ith process.
  • 18. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.18 Gather gather(); buf gather(); data gather(); data data Process 0 Process p - 1 Process 1 Action Code MPI form Having one process collect individual values from set of processes.
  • 19. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.19 Reduce reduce(); buf reduce(); data reduce(); data data Process 0 Process p - 1 Process 1 + Action Code MPI form Gather operation combined with specified arithmetic/logical operation. Example: Values could be gathered and then added together by root:
  • 20. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.20 PVM (Parallel Virtual Machine) Perhaps first widely adopted attempt at using a workstation cluster as a multicomputer platform, developed by Oak Ridge National Laboratories. Available at no charge. Programmer decomposes problem into separate programs (usually master and group of identical slave programs). Programs compiled to execute on specific types of computers. Set of computers used on a problem first must be defined prior to executing the programs (in a hostfile).
  • 21. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.21 Message routing between computers done by PVM daemon processes installed by PVM on computers that form the virtual machine. PVM Application daemon program Workstation PVM daemon Application program Application program PVM daemon Workstation Workstation Messages sent through network (executable) (executable) (executable) MPI implementation we use is similar. Can have more than one process running on each computer.
  • 22. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.22 MPI (Message Passing Interface) • Message passing library standard developed by group of academics and industrial partners to foster more widespread use and portability. • Defines routines, not implementation. • Several free implementations exist.
  • 23. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.23 MPI Process Creation and Execution • Purposely not defined - Will depend upon implementation. • Only static process creation supported in MPI version 1. All processes must be defined prior to execution and started together. • Originally SPMD model of computation. • MPMD also possible with static creation - each program to be started together specified.
  • 24. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.24 Communicators • Defines scope of a communication operation. • Processes have ranks associated with communicator. • Initially, all processes enrolled in a “universe” called MPI_COMM_WORLD, and each process is given a unique rank, a number from 0 to p - 1, with p processes. • Other communicators can be established for groups of processes.
  • 25. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.25 Using SPMD Computational Model main (int argc, char *argv[]) { MPI_Init(&argc, &argv); . . MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /*find process rank */ if (myrank == 0) master(); else slave(); . . MPI_Finalize(); } where master() and slave() are to be executed by master process and slave process, respectively.
  • 26. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.26 Unsafe message passing - Example lib() lib() send(…,1,…); recv(…,0,…); Process 0 Process 1 send(…,1,…); recv(…,0,…); (a) Intended behavior (b) Possible behavior lib() lib() send(…,1,…); recv(…,0,…); Process 0 Process 1 send(…,1,…); recv(…,0,…); Destination Source
  • 27. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.27 MPI Solution “Communicators” • Defines a communication domain - a set of processes that are allowed to communicate between themselves. • Communication domains of libraries can be separated from that of a user program. • Used in all point-to-point and collective MPI message-passing communications.
  • 28. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.28 Default Communicator MPI_COMM_WORLD • Exists as first communicator for all processes existing in the application. • A set of MPI routines exists for forming communicators. • Processes have a “rank” in a communicator.
  • 29. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.29 MPI Point-to-Point Communication • Uses send and receive routines with message tags (and communicator). • Wild card message tags available
  • 30. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.30 MPI Blocking Routines • Return when “locally complete” - when location used to hold message can be used again or altered without affecting message being sent. • Blocking send will send message and return - does not mean that message has been received, just that process free to move on without adversely affecting message.
  • 31. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.31 Parameters of blocking send MPI_Send(buf, count, datatype, dest, tag, comm) Address of Number of items Datatype of Rank of destination Message tag Communicator send buffer to send each item process
  • 32. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.32 Parameters of blocking receive MPI_Recv(buf, count, datatype, src, tag, comm, status) Address of Maximum number Datatype of Rank of source Message tag Communicator receive buffer of items to receive each item process Status after operation
  • 33. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.33 Example To send an integer x from process 0 to process 1, MPI_Comm_rank(MPI_COMM_WORLD,&myrank); /* find rank */ if (myrank == 0) { int x; MPI_Send(&x, 1, MPI_INT, 1, msgtag, MPI_COMM_WORLD); } else if (myrank == 1) { int x; MPI_Recv(&x, 1, MPI_INT, 0,msgtag,MPI_COMM_WORLD,status); }
  • 34. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.34 MPI Nonblocking Routines • Nonblocking send - MPI_Isend() - will return “immediately” even before source location is safe to be altered. • Nonblocking receive - MPI_Irecv() - will return even if no message to accept.
  • 35. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.35 Nonblocking Routine Formats MPI_Isend(buf,count,datatype,dest,tag,comm,request) MPI_Irecv(buf,count,datatype,source,tag,comm, request) Completion detected by MPI_Wait() and MPI_Test(). MPI_Wait() waits until operation completed and returns then. MPI_Test() returns with flag set indicating whether operation completed at that time. Need to know whether particular operation completed. Determined by accessing request parameter.
  • 36. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.36 Example To send an integer x from process 0 to process 1 and allow process 0 to continue, MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* find rank */ if (myrank == 0) { int x; MPI_Isend(&x,1,MPI_INT, 1, msgtag, MPI_COMM_WORLD, req1); compute(); MPI_Wait(req1, status); } else if (myrank == 1) { int x; MPI_Recv(&x,1,MPI_INT,0,msgtag, MPI_COMM_WORLD, status); }
  • 37. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.37 Send Communication Modes • Standard Mode Send - Not assumed that corresponding receive routine has started. Amount of buffering not defined by MPI. If buffering provided, send could complete before receive reached. • Buffered Mode - Send may start and return before a matching receive. Necessary to specify buffer space via routine MPI_Buffer_attach(). • Synchronous Mode - Send and receive can start before each other but can only complete together. • Ready Mode - Send can only start if matching receive already reached, otherwise error. Use with care.
  • 38. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.38 • Each of the four modes can be applied to both blocking and nonblocking send routines. • Only the standard mode is available for the blocking and nonblocking receive routines. • Any type of send routine can be used with any type of receive routine.
  • 39. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.39 Collective Communication Involves set of processes, defined by an intra-communicator. Message tags not present. Principal collective operations: • MPI_Bcast() - Broadcast from root to all other processes • MPI_Gather() - Gather values for group of processes • MPI_Scatter() - Scatters buffer in parts to group of processes • MPI_Alltoall() - Sends data from all processes to all processes • MPI_Reduce() - Combine values on all processes to single value • MPI_Reduce_scatter() - Combine values and scatter results • MPI_Scan() - Compute prefix reductions of data on processes
  • 40. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.40 Example To gather items from group of processes into process 0, using dynamically allocated memory in root process: int data[10]; /*data to be gathered from processes*/ MPI_Comm_rank(MPI_COMM_WORLD, &myrank); /* find rank */ if (myrank == 0) { MPI_Comm_size(MPI_COMM_WORLD, &grp_size); /*find group size*/ buf = (int *)malloc(grp_size*10*sizeof (int)); /*allocate memory*/ } MPI_Gather(data,10,MPI_INT,buf,grp_size*10,MPI_INT,0,MPI_COMM_WORLD) ; MPI_Gather() gathers from all processes, including root.
  • 41. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.41 Barrier routine • A means of synchronizing processes by stopping each one until they all have reached a specific “barrier” call.
  • 42. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.42 Sample MPI program #include “mpi.h” #include <stdio.h> #include <math.h> #define MAXSIZE 1000 void main(int argc, char *argv) { int myid, numprocs; int data[MAXSIZE], i, x, low, high, myresult, result; char fn[255]; char *fp; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); if (myid == 0) { /* Open input file and initialize data */ strcpy(fn,getenv(“HOME”)); strcat(fn,”/MPI/rand_data.txt”); if ((fp = fopen(fn,”r”)) == NULL) { printf(“Can’t open the input file: %snn”, fn); exit(1); } for(i = 0; i < MAXSIZE; i++) fscanf(fp,”%d”, &data[i]); } MPI_Bcast(data, MAXSIZE, MPI_INT, 0, MPI_COMM_WORLD); /* broadcast data */ x = n/nproc; /* Add my portion Of data */ low = myid * x; high = low + x; for(i = low; i < high; i++) myresult += data[i]; printf(“I got %d from %dn”, myresult, myid); /* Compute global sum */ MPI_Reduce(&myresult, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); if (myid == 0) printf(“The sum is %d.n”, result); MPI_Finalize(); }
  • 43. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.43 Evaluating Parallel Programs
  • 44. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.44 Sequential execution time, ts: Estimate by counting computational steps of best sequential algorithm. Parallel execution time, tp: In addition to number of computational steps, tcomp, need to estimate communication overhead, tcomm: tp = tcomp + tcomm
  • 45. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.45 Computational Time Count number of computational steps. When more than one process executed simultaneously, count computational steps of most complex process. Generally, function of n and p, i.e. tcomp = f (n, p) Often break down computation time into parts. Then tcomp = tcomp1 + tcomp2 + tcomp3 + … Analysis usually done assuming that all processors are same and operating at same speed.
  • 46. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.46 Communication Time Many factors, including network structure and network contention. As a first approximation, use tcomm = tstartup + ntdata tstartup is startup time, essentially time to send a message with no data. Assumed to be constant. tdata is transmission time to send one data word, also assumed constant, and there are n data words.
  • 47. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.47 Idealized Communication Time Number of data items ( n) Startup time
  • 48. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.48 Final communication time, tcomm Summation of communication times of all sequential messages from a process, i.e. tcomm = tcomm1 + tcomm2 + tcomm3 + … Communication patterns of all processes assumed same and take place together so that only one process need be considered. Both tstartup and tdata, measured in units of one computational step, so that can add tcomp and tcomm together to obtain parallel execution time, tp.
  • 49. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.49 Benchmark Factors With ts, tcomp, and tcomm, can establish speedup factor and computation/communication ratio for a particular algorithm/implementation: Both functions of number of processors, p, and number of data elements, n.
  • 50. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.50 Factors give indication of scalability of parallel solution with increasing number of processors and problem size. Computation/communication ratio will highlight effect of communication with increasing problem size and system size.
  • 51. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.51 Debugging/Evaluating Parallel Programs Empirically
  • 52. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.52 Visualization Tools Programs can be watched as they are executed in a space-time diagram (or process-time diagram): Process 1 Process 2 Process 3 Time Computing Waiting Message-passing system routine Message
  • 53. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.53 Implementations of visualization tools are available for MPI. An example is the Upshot program visualization system.
  • 54. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.54 Evaluating Programs Empirically Measuring Execution Time To measure the execution time between point L1 and point L2 in the code, we might have a construction such as . L1: time(&t1); /* start timer */ . . L2: time(&t2); /* stop timer */ . elapsed_time = difftime(t2, t1); /* elapsed_time = t2 - t1 */ printf(“Elapsed time = %5.2f seconds”, elapsed_time); MPI provides the routine MPI_Wtime() for returning time (in seconds).
  • 55. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.55 Parallel Programming Home Page http://www.cs.uncc.edu/par_prog Gives step-by-step instructions for compiling and executing programs, and other information.
  • 56. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.56 Compiling/Executing MPI Programs Preliminaries • Set up paths • Create required directory structure • Create a file (hostfile) listing machines to be used (required) Details described on home page.
  • 57. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.57 Hostfile Before starting MPI for the first time, need to create a hostfile Sample hostfile ws404 #is-sm1 //Currently not executing, commented pvm1 //Active processors, UNCC sun cluster called pvm1 - pvm8 pvm2 pvm3 pvm4 pvm5 pvm6 pvm7 pvm8
  • 58. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.58 Compiling/executing (SPMD) MPI program For LAM MPI version 6.5.2. At a command line: To start MPI: First time: lamboot -v hostfile Subsequently: lamboot To compile MPI programs: mpicc -o file file.c or mpiCC -o file file.cpp To execute MPI program: mpirun -v -np no_processors file To remove processes for reboot lamclean -v Terminate LAM lamhalt If fails wipe -v lamhost
  • 59. Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd Edition, by B. Wilkinson & M. Allen, © 2004 Pearson Education Inc. All rights reserved. 2.59 Compiling/Executing Multiple MPI Programs Create a file specifying programs: Example 1 master and 2 slaves, “appfile” contains n0 master n0-1 slave To execute: mpirun -v appfile Sample output 3292 master running on n0 (o) 3296 slave running on n0 (o) 412 slave running on n1