Ejemplo n.º 1
0
void MPIApplication::Recv(void *buffer, size_t count, int source)
{
	size_t recvd = 0;
	do {
		Status status;
		COMM_WORLD.Recv(buffer+recvd, count-recvd, MPI_BYTE, source, MPI_ANY_TAG, status);
		recvd += status.Get_count(MPI_BYTE);
	} while(recvd < count);
}
Ejemplo n.º 2
0
 void task5() {
     barrier("Task 5");
     if (id != size - 1) {
         int data = rand();
         int to = size - 1;
         comm.Send(&data, 1, INTEGER, to, 0);
         printf("Process %d sent data [%d] to %d\n", id, data, to);
     } else {
         Status s;
         comm.Probe(ANY_SOURCE, ANY_TAG, s);
         int count = s.Get_count(INTEGER);
         int* buffer = new int[count];
         int from = s.Get_source();
         comm.Recv(buffer, count, INTEGER, from, 0);
         for (int i = 0; i < count; ++i) {
             printf("Process %d recieved data [%d] from %d\n", id, *(buffer + i), from);
         }
         delete buffer;
     }
 }