Sending in a Ring
Sending in a Ring
Sending in a Ring The sample program that takes data from process zero and sends it to all of the other processes by sending it in a ring. That is, process i should receive the data and send it to process 1+1, until the last process is reached Assume that the data consists of a single integer Process zero reads the data from the user You may want to use these mpi routines in your solution MP Send. MP Recv
Sending in a Ring • The sample program that takes data from process zero and sends it to all of the other processes by sending it in a ring. That is, process i should receive the data and send it to process i+1, until the last process is reached. • Assume that the data consists of a single integer. Process zero reads the data from the user. • You may want to use these MPI routines in your solution: MPI_Send, MPI_Recv
Sending in a Ring Process o Value Process 1 Value Process 2 Value Process Process n-1 Value
Sending in a Ring Value Value Value … Value Process 0 Process 1 Process 2 Process i Process n -1
Sending in a Ring Source casestudy/ring/ring. c casestudyring/ makefile Compile and run o picc -o ringring.C mpirun -np 4 ring Sample Output Process o got 10 22 Process 0 got Process o got-1 Process 3 got 10 Process 3 got 22 Process 3 got-1 Process 2 got 10 Process 2 got 22 Process 2 got-1 Process 1 got 10 Process 1 got 22 Process 1 got-1
Sending in a Ring Source casestudy/ring/ring.c casestudy/ring/Makefile Compile and run % mpicc -o ring ring.c % mpirun -np 4 ring Sample Output 10 Process 0 got 10 22 Process 0 got 22 -1 Process 0 got -1 Process 3 got 10 Process 3 got 22 Process 3 got -1 Process 2 got 10 Process 2 got 22 Process 2 got -1 Process 1 got 10 Process 1 got 22 Process 1 got -1
Finding Pl using MPl collective operations
Finding PI using MPI collective operations