#include <mpi.h>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <thread>
#include <vector>
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 14 of file mpihello.cc.
16 MPI_Init(&argc, &argv);
19 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
21 MPI_Comm_size(MPI_COMM_WORLD, &
size);
23 char processor_name[MPI_MAX_PROCESSOR_NAME];
25 MPI_Get_processor_name(processor_name, &name_len);
27 std::cout <<
"Hi, I am process " << rank <<
" of " <<
size
28 <<
" and I am running on " << processor_name << std::endl;
34 for (
int i = 1; i <
size; ++i)
47 std::cout <<
"I got value = " <<
value <<
" from "
48 << status.MPI_SOURCE << std::endl;
53 std::this_thread::sleep_for(std::chrono::milliseconds(3000));
55 double my_value = (rand() % 1000) / 1000.0;