Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code Below: // #include #include #include using std::cout; using std::ios; using std::cerr; #include using std::ifstream; #define MAXSIZE 1000 // using namespace std; // int main(int

Code Below:

// #include  #include  #include  using std::cout; using std::ios; using std::cerr; #include  using std::ifstream; #define MAXSIZE 1000 // using namespace std; // int main(int argc, char **argv) { int myid, numprocs, greatest, data[MAXSIZE], i, x, low, high, result, packet[2]; // [0] = local sum, [1] = local max // // ofstream DebugFile; // Debug file. // // MPI initialization routines. // MPI_Status status; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid); // // Activity for root process, 0. // if (myid == 0) { // // Read file containing MAXSIZE numbers. // std::ifstream infile("rand_data.txt", ios::in); // //DebugFile.open ("rand_dataV1.txt"); //DebugFile << "Writing this to a file. "; // if( !infile ) { // checks for file access cerr << "File could not be opened "; return( 1 ); } //if( numprocs != 10 ) // // Check that the number of subdivisions of the file is a multiple of // the number of processes. // if( MAXSIZE%numprocs != 0 ) { cerr << " !!! WARNING - This program requires MAXSIZE%numprocs == 0 processes "; return( 2 ); } for(i = 0; i < MAXSIZE; i++) // load data from file into an array { infile >> data[i]; // // DebugFile< packet[1] ) packet[1] = data[i]; packet[0] += data[i]; // // Error check output. // // DebugFile<
                        

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2022 Workshops 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 In Computer And Information Science 33

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Alfred Taudes ,Atif Mashkoor ,Johannes Sametinger ,Jorge Martinez-Gil ,Florian Sobieczky ,Lukas Fischer ,Rudolf Ramler ,Maqbool Khan ,Gerald Czech

1st Edition

3031143426, 978-3031143427

More Books

Students also viewed these Databases questions

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago

Question

Prepare a short profile of Lucy Clifford ?

Answered: 1 week ago

Question

Prepare a short profile of Rosa parks?

Answered: 1 week ago