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
?