Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a MSMPI project using the following code, compile and execute the code. /

ID: 3716109 • Letter: C

Question

Create a MSMPI project using the following code, compile and execute the code.

// File-IO-Lab.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include <iostream>

using namespace std;

#include <mpi.h>

int main(int argc, char *argv[])

{

   const int size = 10;

   MPI_File fh;

   int rank;

   int buf[size];

   MPI_Status status;

   MPI_Init(&argc, &argv);

   MPI_Comm_rank(MPI_COMM_WORLD, &rank);

   MPI_File_open(MPI_COMM_WORLD, "test.txt", MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &fh);

   if (rank == 0)

   {

       for (int i = 0; i < size; i++)

           buf[i] = i+65;

      

       MPI_File_write(fh, buf, size, MPI_INT, &status);

       printf("Status: %d ", status);

       system("PAUSE");

   }

   MPI_File_close(&fh);

   MPI_Finalize();

   return 0;

}

Explanation / Answer

#include #include "mpi.h" #include using namespace std; int numOfProc, id, array_size, portion; int *arr = NULL; MPI_Status status; const static int tag = 1; int main(int argc, char *argv[]) { MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &numOfProc); MPI_Comm_rank(MPI_COMM_WORLD, &id); cout