From 34c4615fa4df06663d474968b61f9a12c411e71b Mon Sep 17 00:00:00 2001 From: patrick Date: Mon, 9 Dec 2013 13:46:23 +0100 Subject: [PATCH] hello.cpp for mpi --- aufgabe4.5/hello.cpp | 22 ++++++++++++++++++++++ aufgabe4.5/hosts | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 aufgabe4.5/hello.cpp create mode 100644 aufgabe4.5/hosts diff --git a/aufgabe4.5/hello.cpp b/aufgabe4.5/hello.cpp new file mode 100644 index 0000000..f4914ca --- /dev/null +++ b/aufgabe4.5/hello.cpp @@ -0,0 +1,22 @@ +#define _MPI_CPP_BINDINGS +#include +#include + +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(); +} diff --git a/aufgabe4.5/hosts b/aufgabe4.5/hosts new file mode 100644 index 0000000..a7df98d --- /dev/null +++ b/aufgabe4.5/hosts @@ -0,0 +1,4 @@ +zotac1 +zotac2 +zotac3 +zotac4