Skip to content

Improve data exchange in fastscape interfaces. #6749

@bangerth

Description

@bangerth

As also found in #6723, the current fastscape interface has the following code:

      else
        // For ranks other than the root:
        {
          for (unsigned int i=0; i<local_aspect_values.size(); ++i)
            MPI_Ssend(&local_aspect_values[i][0], local_aspect_values[i].size(), MPI_DOUBLE,
                      /* destination is root= */ 0,
                      /* tag= */ 42,
                      this->get_mpi_communicator());
            ...

@Djneu says he doesn't remember why he used an Ssend here instead of the usual Send or Isend. That said, the corresponding receive is here, in fill_fastscape_arrays():

          // First, find out the size of the array a process wants to send.
          MPI_Status status;
          MPI_Probe(p, 42, this->get_mpi_communicator(), &status);
          int incoming_size = 0;
          MPI_Get_count(&status, MPI_DOUBLE, &incoming_size);

          // Resize the array so it fits whatever the process sends.
          for (unsigned int i=0; i<local_aspect_values.size(); ++i)
            {
              local_aspect_values[i].resize(incoming_size);
            }

          for (unsigned int i=0; i<local_aspect_values.size(); ++i)
            MPI_Recv(&local_aspect_values[i][0], incoming_size, MPI_DOUBLE, p, 42, this->get_mpi_communicator(), &status);

This is really just a gather operation: process 0 needs to obtain information from all other processes. We could save a whole bunch of code by just calling Utilities::MPI::gather(). I'll implement that once we have #6723 merged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions