Definition
MPI_Aint_add calculates an address by summing a start address and adding to it a displacement.
MPI_Aint MPI_Aint_add(MPI_Aint addr,
MPI_Aint displacement);
Addressing
C | Fortran-2008 | Fortran-90
MPI_Aint_add calculates an address by summing a start address and adding to it a displacement.
MPI_Aint MPI_Aint_add(MPI_Aint addr,
MPI_Aint displacement);
The address to start from.
The displacement to apply to the start address.
The address obtained by adding the displacement to the address given.
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
/**
* @brief Illustrate how to apply a displacement to an address.
* @details This application takes the address of an element in an array, then
* gets the address of another element by applying a displacement to the address
* of the first element taken.
**/
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
int a[10];
MPI_Aint address_third_element;
MPI_Get_address(&a[2], &address_third_element);
MPI_Aint displacement = sizeof(int) * 2;
MPI_Aint address_fifth_element;
address_fifth_element = MPI_Aint_add(address_third_element, displacement);
printf("The address of the 3th element is %ld.\n", address_third_element);
printf("The address of the 5th element is %ld.\n", address_fifth_element);
MPI_Finalize();
return EXIT_SUCCESS;
}