Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI::broadcast() can't deal with more than 2GB of data #13357

Closed
bangerth opened this issue Feb 10, 2022 · 4 comments · Fixed by #13379
Closed

MPI::broadcast() can't deal with more than 2GB of data #13357

bangerth opened this issue Feb 10, 2022 · 4 comments · Fixed by #13379
Milestone

Comments

@bangerth
Copy link
Member

Follow-up to geodynamics/aspect#4484: I looked at Utilities::MPI::broadcast(), and it does this:

      std::vector<char> buffer;
      unsigned int      buffer_size = numbers::invalid_unsigned_int;

      // On the root process, pack the data and determine what the
      // buffer size needs to be.
      if (this_mpi_process(comm) == root_process)
        {
          buffer      = Utilities::pack(object_to_send, false);
          buffer_size = buffer.size();
        }

      // Exchange the size of buffer
      int ierr = MPI_Bcast(&buffer_size, 1, MPI_UNSIGNED, root_process, comm);
      AssertThrowMPI(ierr);

      // If not on the root process, correctly size the buffer to
      // receive the data, then do exactly that.
      if (this_mpi_process(comm) != root_process)
        buffer.resize(buffer_size);

      ierr =
        MPI_Bcast(buffer.data(), buffer_size, MPI_CHAR, root_process, comm);
      AssertThrowMPI(ierr);

The assignment

          buffer_size = buffer.size();

can overflow if we are trying to send large objects, and it will only go downhill from there.

@tjhei
Copy link
Member

tjhei commented Feb 10, 2022

Well, MPI_Bcast (like all other MPI routines) takes the count as a signed int, so you are limited to 2^31 bytes when compressing or 2^31 objects (doubles/...) if not.
But yes, this routine should check and AssertThrow about this.

This is all related to my work about large MPI IO and Utilities::MPI::create_mpi_data_type_n_bytes

@bangerth
Copy link
Member Author

Ah, yes, crap. So we need that same trick that you did with the large-data output.

@tjhei
Copy link
Member

tjhei commented Feb 10, 2022

This case is easier, though. We can fall back to a sequence of broadcasts if necessary.

@tjhei
Copy link
Member

tjhei commented Feb 12, 2022

See #13368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants