/********************************************************** File: master.h Description: A program that inputes an integer number and determines if it is a prime number or not in parallel. The functions for the master process. Author: Dana Vrajitoru Organization: IUSB Date: August 23, 2002 ***********************************************************/ #ifndef MASTER_H #define MASTER_H // A function that sends the divisor to all of the processes except // for the master. If the divisor is > 1, this causes all of them to // stop loop that searches for a divisor. The function also makes sure // that it only sends the divisor once to each process by the use of // the static variable count. void Finalize_all(int nr_proc, int divisor); // A function that checks if there is any incoming message from any // slave process. In case there is a message with a non-trivial // divisor, it stops all of them. void Check_incoming(int nr_proc, MPI_Request &request, int &div, int &nr_done, int &divisor); // The function that checks if n is a prime. While it is testing for // the divisors between start and end, it also checks if any other // process has already found a non-trivial divisor, and in this case, // it stops all of them. It also makes sure there are no pending // processes waiting to send or receive something. int Check_prime_master(int nr_proc, int start, int end, int n); // The master function that inputs the number, finds out if it is a // prime by coordinating all of the others, then outputs the result. void Master(int nr_proc); #endif