Experiencing Cluster Computing Case Studies Class 8
Case Studies Class 8 Experiencing Cluster Computing
I Description Download the source from http://www.sci.hkbu.eduhk/tdac/tutorial/expcluster Comp/casestudy/casestudy. zip Unzip the package Follow the instructions from each example
Description • Download the source from http://www.sci.hkbu.edu.hk/tdgc/tutorial/ExpCluster Comp/casestudy/casestudy.zip • Unzip the package • Follow the instructions from each example
Hello World The sample program uses MPI and has each MPI process print Hello world from process i of n using the rank in MPI COMM WORLD for i and the size of mpi comm world for n you can assume that all processes support output for this example Note the order that the output appears in. Depending on your MPI implementation, characters from different lines may be intermixed. A subsequent exercise(7O master/slaves)will show how to order the output You may want to use these mpi routines in your solution MPI Init. MPI Comm size. MPI Comm rank, MPI Finalize
Hello World • The sample program uses MPI and has each MPI process print Hello world from process i of n • using the rank in MPI_COMM_WORLD for i and the size of MPI_COMM_WORLD for n. You can assume that all processes support output for this example. • Note the order that the output appears in. Depending on your MPI implementation, characters from different lines may be intermixed. A subsequent exercise (I/O master/slaves) will show how to order the output. • You may want to use these MPI routines in your solution: MPI_Init, MPI_Comm_size, MPI_Comm_rank, MPI_Finalize
Hello World Source casestudy/helloworld/helloworld.c casestudy/helloworld/Makefile Compile and run 8 picc -o helloworldhelloworld.c 8 mpirun -np 4 helloworld Sample output Hello world from process 0 of 4 Hello world from process 3 of 4 Hello world from process 1 of 4 Hello world from process 2 of 4
Hello World Source casestudy/helloworld/helloworld.c casestudy/helloworld/Makefile Compile and run % mpicc -o helloworld helloworld.c % mpirun -np 4 helloworld Sample output Hello world from process 0 of 4 Hello world from process 3 of 4 Hello world from process 1 of 4 Hello world from process 2 of 4
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