Finding Pl using MPl collective operations The method evaluates PI using the integral of 4/(1+X*x) between 0 and 1. The integral is approximated by a sum of n intervals The approximation to the integral in each interval is (1/h)*4(1×xx) The master process asks the user for the number of intervals The master then broadcast this number to all of the other processes Each process then adds up every n'th interval (x 0+rank/n, 0+rank/n+size/n,.) Finally, the sums computed by each process are added together using a reduction
Finding PI using MPI collective operations • The method evaluates PI using the integral of 4/(1+x*x) between 0 and 1. The integral is approximated by a sum of n intervals • The approximation to the integral in each interval is (1/n)*4/(1+x*x). • The master process asks the user for the number of intervals • The master then broadcast this number to all of the other processes. • Each process then adds up every n'th interval (x = 0+rank/n, 0+rank/n+size/n,...). • Finally, the sums computed by each process are added together using a reduction
Finding Pl using MPl collective operations Source casestudy/pi/pic casestudy/pi/Makefile Sample Output Enter the number of intervals: (0 quits)100 i is approximately3.1416009869231249, Error is0.00000833333318 Enter the number of intervals:(0 quits )1000 pi is approximately3.1415927369231262, Error is0.0000083333331 Enter the number of intervals: (0 quits)10000 pi is approximately3.1415926544231256, Error is0.00000008333325 Enter the number of intervals: (0 quits)100000 pi is approximately3.1415926535981269, Error is0.000000003338 Enter the number of intervals:(0 quits)1000000 pi is approximately3.1415926535898708, Error is0.000000000077 Enter the number of intervals:(0 quits)10000000 pi is approximately 3. 1415926535897922, Error is 0.0000000000000009
Finding PI using MPI collective operations Source casestudy/pi/pi.c casestudy/pi/Makefile Sample Output: Enter the number of intervals: (0 quits) 100 pi is approximately 3.1416009869231249, Error is 0.0000083333333318 Enter the number of intervals: (0 quits) 1000 pi is approximately 3.1415927369231262, Error is 0.0000000833333331 Enter the number of intervals: (0 quits) 10000 pi is approximately 3.1415926544231256, Error is 0.0000000008333325 Enter the number of intervals: (0 quits) 100000 pi is approximately 3.1415926535981269, Error is 0.0000000000083338 Enter the number of intervals: (0 quits) 1000000 pi is approximately 3.1415926535898708, Error is 0.0000000000000777 Enter the number of intervals: (0 quits) 10000000 pi is approximately 3.1415926535897922, Error is 0.0000000000000009
Implementing Fairness using Waitsome
Implementing Fairness using Waitsome
Implementing Fairness using Waitsome Write a program to provide fair reception of message from all sending processes. Arrange the program to have all processes except process O send 100 messages to process 0 Have process 0 print out the messages as it receives them. Use nonblocking receives and MPI Waitsome Is the MPl implementation fair You may want to use these mpi routines in your solution MPI Waitsome, MPI Recv, MPI Cancel
Implementing Fairness using Waitsome • Write a program to provide fair reception of message from all sending processes. Arrange the program to have all processes except process 0 send 100 messages to process 0. Have process 0 print out the messages as it receives them. Use nonblocking receives and MPI_Waitsome. Is the MPI implementation fair? • You may want to use these MPI routines in your solution: MPI_Waitsome, MPI_Irecv, MPI_Cancel
Implementing Fairness using Waitsome Source casestudy/fairness/fairness.C casestudy/fairness/Makefile Sample Output Msg from 1 with tag 0 Msg from 1 with tag 1 Msg from 1 with tag 2 Msg from 1 with tag 3 Msg from 1 with tag 4 Msg from 2 With tag 21 Msg from 1 with tag 55 Msg from 2 with tag 22 Msg from 1 with tag 56
Implementing Fairness using Waitsome Source: casestudy/fairness/fairness.c casestudy/fairness/Makefile Sample Output: Msg from 1 with tag 0 Msg from 1 with tag 1 Msg from 1 with tag 2 Msg from 1 with tag 3 Msg from 1 with tag 4 … Msg from 2 with tag 21 Msg from 1 with tag 55 Msg from 2 with tag 22 Msg from 1 with tag 56 …