/************************************************************** File: pool_tasks.cc Description: A program that implements a pool of tasks model for encrypting a text. Author: Dana Vrajitoru Organization: IUSB, Computer and Information Sciences Date: October 2020 ***************************************************************/ #include #include #include #include #include using namespace std; #include "pool_tasks.h" // Master process. Inputs the text, and sends it to other processes, // receives the results, and outputs them. void Master(int nr_proc) { ofstream fout("output.txt"); MPI_Status status; int n, tag = 0, source; MPI_Recv(&n, 1, MPI_INT, MPI_ANY_SOURCE, tag, MPI_COMM_WORLD, &status); source = status.MPI_SOURCE; cout << "Received the value " << n << " from process " << source << endl; } // Worker process. Receives a word from the master process, encrypts // it, then sends it back to the master. void Worker(int my_id, int nr_proc) { int n = 4, tag = 0, dest = 0; if (my_id == 2) MPI_Send(&n, 1, MPI_INT, dest, tag, MPI_COMM_WORLD); }