hello.cpp for mpi
This commit is contained in:
parent
210aeb7874
commit
34c4615fa4
22
aufgabe4.5/hello.cpp
Normal file
22
aufgabe4.5/hello.cpp
Normal 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
4
aufgabe4.5/hosts
Normal file
@ -0,0 +1,4 @@
|
||||
zotac1
|
||||
zotac2
|
||||
zotac3
|
||||
zotac4
|
Loading…
Reference in New Issue
Block a user