NERSC logo National Energy Research Scientific Computing Center
  A DOE Office of Science User Facility
  at Lawrence Berkeley National Laboratory
 

Basic send

We're ready to do some message passing. We'll start with the most basic send routine, MPI_SEND. The function call looks like this:

Fortran

FORTRAN_TYPE::  buff
INTEGER:: count, dest, ierr

CALL MPI_SEND(buff, count, MPI_TYPE, dest, tag, comm, ierr)

C

int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest,
	int tag, MPI_Comm comm)

This single command allows the passing of any kind of variable, even a large array, to any group of tasks. We'll break it down into variables:

  • buff : The variable you want to send.
  • count : The number of variables you're passing. If you're passing only a single value, this should be 1. If you're passing an array, it's the overall size of the array. For example, if you wanted to send a 4 by 5 array, count would be 4*5=20 since you're actually passing 20 values.
  • MPI_TYPE : The kind of variable you're passing so the MPI routine knows what to expect.
  • dest : The ID number of the task you're sending the message to.
  • tag : a message tag. This is a way for the receiver to verify that it's getting the message it expects. The message tag is an integer number that you can assign any value.
  • comm : This is the group ID of tasks that your message is going to. In large, complex programs tasks may be divided into groups to speed connections and transfers. In small programs, this will more than likely be MPI_COMM_WORLD.
  • ierr : an integer error code.

LBNL Home
Page last modified: Fri, 21 May 2004 22:25:58 GMT
Page URL: http://www.nersc.gov/nusers/help/tutorials/mpi/intro/send.php
Web contact: webmaster@nersc.gov
Computing questions: consult@nersc.gov

Privacy and Security Notice
DOE Office of Science