Parallel Computing Platforms: Chieh-Sen (Jason) Huang
Parallel Computing Platforms: Chieh-Sen (Jason) Huang
PE
+
INTERCONNECTION NETWORK
INTERCONNECTION NETWORK
PE control unit
PE PE
+
control unit
PE
Global
control
unit
PE
+
PE control unit
PE PE
+
control unit
(a) (b)
Interconnection Network
Interconnection Network
Interconnection Network
C C M
P P P
M M
C C M
P P
M M
P
C C M
(a) (b) (c)
• Per-word transfer time (tw ): This time includes all overheads that
are determined by the length of the message. This includes
bandwidth of links, error checking and correction, etc.
Store-and-Forward Routing
tcomm = ts + mtw .
• See homework.
MPI: the Message Passing Interface
#include <mpi.h>
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &npes);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
printf("From process %d out of %d, Hello World!\n",
myrank, npes);
MPI_Finalize();
}
Sending and Receiving Messages
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &npes);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
if (myrank==0){
a[0]=0; b[0]=1;
MPI_Send(a,1,MPI_INT,1,1,MPI_COMM_WORLD);
}
else{
a[0]=2; b[0]=3;
MPI_Recv(a,1,MPI_INT,0,1,MPI_COMM_WORLD,&status);
}
printf("From processor: %d out of %d a=%d b=%d\n"
,myrank,npes,a[0],b[0]);
MPI_Finalize();
}