/********************************************************** File: find_min.h Description: Functions to find the minimum in an array that is split among the processes Author: Dana Vrajitoru Class: B424 Date: September 21, 2004 ***********************************************************/ #ifndef FIND_MIN_H #define FIND_MIN_H // A function that generates a random array. int *Generate_array(int size, int limit); // A function that finds the minimum in an array. int Find_min(int *the_array, int size); // The function that inputs the size and the upper limit for the // elements of the array for the first process, shares this // information with the others, then calls the function that generates // the array for each proc. void Initialize_array(int *&array, int &size, int proc_id, int nb_proc); // The function that finds the global minimum. Each process finds the // minimum in its part of the array. Each process but the last waits // for the previous process to send it the minimum so far, then // updates its own minimum according to it. Then each process but the // first sends the current minimum to the next one. The last process // writes the global minimum. void Find_global_min(int my_min, int proc_id, int nb_proc); // The function that finds the global minimum. Each process finds the // minimum in its part of the array. Each process but the first waits // for the previous process to send it the minimum so far, then // updates its own minimum according to it. Then each process but the // last sends the current minimum to the next one. The last process // writes the global minimum. void Find_global_min_last(int my_min, int proc_id, int nb_proc); /**********************************************************************/ // Functions to be implemented by the student. // The function that finds the global minimum using a binary tree // communication scheme. The complexity is the binary logarithm of the // number of processes. void Find_global_min_lnp(int my_min, int proc_id, int nb_proc); // This function should allocate an array with the given size for each // process. Each process inputs their own part of the array in // order. Then process 0 can start to input the numbers from the // user. Each process except for 0 should wait for a message from the // previous process telling them when their time to start the // input. After they are done, each process except for the last one // should send a message to the next process telling them to start the // input. Each process should output their id just before they start // asking the user for numbers. int *Input_array(int proc_id, int nb_proc, int size); #endif