0

I've got an MPI program like below:

#include "mpi.h"
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]){
      int myid;
      int numprocs;
      int namelen;
      char processor_name[MPI_MAX_PROCESSOR_NAME];
      MPI_Init(&argc,&argv);
      MPI_Comm_rank(MPI_COMM_WORLD,&myid);
      MPI_Get_processor_name(processor_name,&namelen);
      for(int i=0; i<4; ++i){
            cout<<"I'm"<<myid<<", sending "<<i<<endl;
            sleep(1);
            if(0 == myid && 0 == i){
                  MPI_Barrier(MPI_COMM_WORLD);
            }
      }
      MPI_Finalize();
      return 0;
}

Well, the internet says we require mpirun to run test04_omp, but in my test Linux environment, I can run it directly.

So my question is, when do I need mpirun?

Troskyvs
  • 7,537
  • 7
  • 47
  • 115
  • 2
    Possible duplicate of [Difference between running a program with and without mpirun](http://stackoverflow.com/questions/15578009/difference-between-running-a-program-with-and-without-mpirun) – Zulan Apr 22 '17 at 12:50
  • 1
    Please note that OpenMPI != OpenMP, OpenMP != MPI, OpenMPI is an implementation of MPI – Zulan Apr 22 '17 at 12:50

0 Answers0