// ================================================================== // Author: Jean-Michel Richer // Date: Aug 2020 // Last modified: November 2020 // Purpose: Use of MPI::Gather // Each process creates its own local data and they are all send // to the master process (of rank 0) // ================================================================== #include #include #include #include // for sleep #include using namespace std; #include "ezmpi.h" using namespace ez::mpi; /** * run master and slaves */ void run(int argc, char *argv[]) { // data to send float *data; int data_size; // Create Process from ezmpi // that retrives cpu rank (id), # cpus (max), cpu name (name) Process p(argc, argv); const int local_data_size = 10; int *local_data; int global_data_size = 0; int *global_data = NULL; // each processor creates its local data local_data = new int [ local_data_size ]; for (int i=0; i