hello.cpp for mpi

master
patrick 2013-12-09 13:46:23 +01:00
parent 210aeb7874
commit 34c4615fa4
2 changed files with 26 additions and 0 deletions

22
aufgabe4.5/hello.cpp Normal file
View File

@ -0,0 +1,22 @@
#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();
}

4
aufgabe4.5/hosts Normal file
View File

@ -0,0 +1,4 @@
zotac1
zotac2
zotac3
zotac4