// Copyright 2021 Jeisson Hidalgo CC-BY 4.0 #include #include int main(int argc, char* argv[]) { if (MPI_Init(&argc, &argv) == MPI_SUCCESS) { int process_number = -1; MPI_Comm_rank(MPI_COMM_WORLD, &process_number); int process_count = -1; MPI_Comm_size(MPI_COMM_WORLD, &process_count); char process_hostname[MPI_MAX_PROCESSOR_NAME] = { '\0' }; int hostname_length = -1; MPI_Get_processor_name(process_hostname, &hostname_length); std::cout << "Hello from main thread of process " << process_number << " of " << process_count << " on " << process_hostname << std::endl; MPI_Finalize(); } else { std::cerr << "error: could not init MPI" << std::endl; } return 0; }