23 lines
503 B
C++
23 lines
503 B
C++
|
#define _MPI_CPP_BINDINGS
|
||
|
#include <mpi.h>
|
||
|
#include <iostream>
|
||
|
|
||
|
int main(int argc, char* argv[])
|
||
|
{
|
||
|
MPI::Init(argc, argv);
|
||
|
|
||
|
int rank = MPI::COMM_WORLD.Get_rank();
|
||
|
int size = MPI::COMM_WORLD.Get_size();
|
||
|
|
||
|
int length;
|
||
|
char* pName = new char[MPI::MAX_PROCESSOR_NAME+1];
|
||
|
MPI::Get_processor_name(pName, length);
|
||
|
std::string name(pName);
|
||
|
delete [] pName;
|
||
|
|
||
|
std::cout << "Hello World! I am " << rank << " of " << size;
|
||
|
std::cout << " running on host " << name.c_str() << std::endl;
|
||
|
|
||
|
MPI::Finalize();
|
||
|
}
|