MPI_Scatterv: Broadcasting Data with Variably Sized Messages

MPI_Scatterv: Broadcasting Data with Variably Sized Messages

MPI (Message Passing Interface) is a standard for developing parallel applications. In this article, we will explore the MPI_Scatterv function, which allows broadcasting data with variably sized messages.

Function Signature

int MPI_Scatterv(void* sendbuf, int sendcount[], int sendtype, void* recvbuf, int recvcount, int recvtype, int root, MPI_Comm comm)

Parameters

  • sendbuf: the buffer containing the data to be sent.
  • sendcount[]: an array of integers specifying the size of each message in the sendbuf buffer.
  • sendtype: the type of each element in the sendbuf buffer.
  • recvbuf: a pointer to a buffer that will receive the scattered data. The buffer must be large enough to hold all the received data.
  • recvcount[]: an array of integers specifying the size of each message in the recvbuf buffer.
  • recvtype: the type of each element in the recvbuf buffer.
  • root: the rank of the root process, which is responsible for sending data to all other processes.
  • comm: the communicator handle.

Return Value
The return value is MPI_SUCCESS if the operation is successful. If an error occurs, the return value will be a corresponding error code.

Fortran Signature

For Fortran users, the function signature is:

integer MPI_SCATTERV(s_sendbuf, s_sendcount, s_displs, s_sendtype, &
 r_recvbuf, r_recvcount, r_recvable, root, comm, ierror)

Description
The MPI_Scatterv function allows broadcasting data with variably sized messages. This function is an extension of the MPI_Scatter function, which only supports fixed-sized messages.

Requirements

To use the MPI_Scatterv function, you must have a Fortran 90-compliant compiler and the MS-MPI package installed on your system. The required packages are:

  • HPC Pack 2012 MS-MPI redistributable package
  • HPC Pack 2008 R2 MS-MPI redistributable package
  • HPC Pack 2008 MS-MPI redistributable package or
  • HPC Pack 2008 client utility

Header Files

The necessary header files are:

  • Mpi.h
  • Mpif.h

Library

You will need to link against the following library:

  • Msmpi.lib

DLL

The required DLL is:

  • Msmpi.dll

Additional Information

For more information on MPI functions, see the following:

  • MPI_Datatype
  • MPI_Gather
  • MPI_Gatherv
  • MPI_Scatter

In this article, we have explored the MPI_Scatterv function, which allows broadcasting data with variably sized messages. This function is useful when you need to send different amounts of data to each process in your parallel application.