message: fix non-mpi rank->device_id map and mpi wait
diff: @@ -87,6 +87,7 @@ static constexpr bool is_gpu_aware()
  */
  static int map_rank_to_device_id(MPI_Comm comm, const int num_devices)
  {
  + GKO_ASSERT(num_devices > 0);
  if (num_devices == 1) {
  return 0;
  } else {
  @@ -106,8 +107,14 @@ static int map_rank_to_device_id(MPI_Comm comm, const int num_devices)
  // we determine the node-local rank with MPI calls.
  int local_rank;
  int compare_result;
  + int is_initialized;
  + GKO_ASSERT_NO_MPI_ERRORS(MPI_Initialized(&is_initialized));
  + if (is_initialized) {
  GKO_ASSERT_NO_MPI_ERRORS(
  MPI_Comm_compare(comm, MPI_COMM_WORLD, &compare_result));
  + } else {
  + compare_result = MPI_IDENT;
  + }
  if (compare_result != MPI_IDENT && compare_result != MPI_CONGRUENT) {
  local_rank = mpi_node_local_rank(comm);
  } else {
  @@ -1904,17 +1911,11 @@ constexpr MPI_Comm MPI_COMM_WORLD{};
  namespace gko {
  namespace mpi {
  +
  /**
  - * Maps each MPI rank to a single device id in a round robin manner.
  - * @param comm used to determine the node-local rank, if no suitable
  - * environment variable is available.
  - * @param num_devices the number of devices per node.
  - * @return device id that this rank should use.
  + * Dummy implementation that always returns 0.
  */
  -int map_rank_to_device_id(MPI_Comm comm, const int num_devices)
  -{
  - return num_devices;
  -}
  +int map_rank_to_device_id(MPI_Comm comm, const int num_devices) { return 0; }
  } // namespace mpi
  