1 //
2 // Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
3 // University Research and Technology
4 // Corporation. All rights reserved.
5 // Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
6 //
7 // Sample MPI "hello world" application in C++
8 //
9 // NOTE: The MPI C++ bindings were deprecated in MPI-2.2 and removed
10 // from the standard in MPI-3. Open MPI still provides C++ MPI
11 // bindings, but they are no longer built by default (and may be
12 // removed in a future version of Open MPI). You must
13 // --enable-mpi-cxx when configuring Open MPI to enable the MPI C++
14 // bindings.
15 //
16
17 #include "mpi.h"
18 #include <iostream>
19
20 int main(int argc, char **argv)
21 {
22 int rank, size, len;
23 char version[MPI_MAX_LIBRARY_VERSION_STRING];
24
25 MPI::Init();
26 rank = MPI::COMM_WORLD.Get_rank();
27 size = MPI::COMM_WORLD.Get_size();
28 MPI_Get_library_version(version, &len);
29 std::cout << "Hello, world! I am " << rank << " of " << size
30 << "(" << version << ", " << len << ")" << std::endl;
31 MPI::Finalize();
32
33 return 0;
34 }