Download the shell practice quiz program, quizshell.c
Also see the answer form (.doc version)
Remember to try and run programs using the /tmp directory - Here's how
Write a parallel application for factorial(n)
Number = 4, numprocesses = 4 Rank 0: 1 Rank 1: 2 Rank 2: 3 Rank 3: 4 Rank 0, using MPI_Reduce and MPI_PROD, calculates: 1*2*3*4=24 Number = 12, numprocesses = 4 Rank 0: 1*2*3 Rank 1: 4*5*6 Rank 2: 7*8*9 Rank 3: 10*11*12 Rank 0, using MPI_Reduce and MPI_PROD, calculates: 6*120*504*1320=479001600In these examples, the number of processes divides evenly into n
Example of the extra version:
Number = 10, numprocesses = 4 Rank 0: 1*2*3 Rank 1: 4*5*6 Rank 2: 7*8*9 Rank 3: 10 Rank 0, using MPI_Reduce and MPI_PROD, calculates: 6*120*504*10=3628800 Number = 11, numprocesses = 4 Rank 0: 1*2*3 Rank 1: 4*5*6 Rank 2: 7*8*9 Rank 3: 10*11 Rank 0, using MPI_Reduce and MPI_PROD, calculates: 6*120*504*110=39916800 Number = 9, numprocesses = 4 Rank 0: 1*2 Rank 1: 3*4 Rank 2: 5*6 Rank 3: 7*8*9 Rank 0, using MPI_Reduce and MPI_PROD, calculates: 2*12*30*504=362880