/* Use csbackup.joensuu.fi instead of cs compile: /usr/local/mpich-1.2.0/bin/mpicc ds.ex2.7.skel.c run : /usr/local/mpich-1.2.0/bin/mpirun -np 5 a.out To understand the program, draw the processors and slowly draw each message. 7) Implement your solution to exercise 3 using C, MPI, and ready communication macros from the course examples page. Here, participants are MPI processes, time list is a bit array, and communication is done with Send/Receive -macros. For simplicity, you may assume that only 1 hour reservation is needed, scope of time is one day (24h), and PID 0 starts the negotiation. */ #include #include #include /* a variable needeed for call, result not used */ static MPI_Status tmpstat; /* logical directions */ #define Left (PID-1) #define Right (PID+1) #define Any MPI_ANY_SOURCE /* Send and Receive operations DEST & SOURCE can be Left/Right or a PID (int 0..P-1) SOURCE can be Any Thes are actually non-blocking at cs, even if the MPI-standard would require these to be assumed blocking Thus: you can do, e.g., send(left), send(right), recv(left), recv(right) Hint on printing: pipe the output of the program to sort /usr/local/mpich-1.2.0/bin/mpirun -np 5 a.out | sort */ /* Send the value of an int _variable_ VAR to destination process DEST */ #define Send(DEST, VAR) MPI_Send(&VAR, 1, MPI_INT, DEST, 0, MPI_COMM_WORLD) /* Receive an integer to an int variable VAR from destination process SOURCE */ #define Receive(SOURCE, VAR) MPI_Recv(&VAR, 1, MPI_INT, SOURCE, 0, MPI_COMM_WORLD, &tmpstat) #define PRINT 1 #define DAY 24 typedef unsigned int TimeList; /* has to be at least DAY bits */ /* set a time on a list */ #define Set(tlist, hour) tlist |= 1<