| 53 | #endif |
| 54 | |
| 55 | void seissol::MPI::init(int& argc, char**& argv) { |
| 56 | // Note: Strictly speaking, we only require MPI_THREAD_MULTIPLE if using |
| 57 | // a communication thread and/or async I/O. |
| 58 | // The safer (and more sane) option is to enable it by default. |
| 59 | const int required = MPI_THREAD_MULTIPLE; |
| 60 | int provided = 0; |
| 61 | MPI_Init_thread(&argc, &argv, required, &provided); |
| 62 | |
| 63 | setComm(MPI_COMM_WORLD); |
| 64 | |
| 65 | std::string hostName(256, ' '); |
| 66 | if (gethostname(const_cast<char*>(hostName.c_str()), 256) != 0) { |
| 67 | hostName = "unknown-host"; |
| 68 | } else { |
| 69 | utils::StringUtils::rtrim(hostName); |
| 70 | hostName.pop_back(); |
| 71 | } |
| 72 | hostNames = collectContainer(hostName); |
| 73 | |
| 74 | // Test this after setComm() to get the correct m_rank |
| 75 | if (provided < required) { |
| 76 | logError() << utils::nospace << "Provided MPI thread support (" << provided |
| 77 | << ") is smaller than required thread support (" << required << ")."; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | void seissol::MPI::setComm(MPI_Comm comm) { |
| 82 | m_comm = comm; |