ltcp/aufgabe4.5/hello.cpp

23 lines
503 B
C++
Raw Normal View History

2013-12-09 12:46:23 +00:00
#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();
}