This may be a trivial thing but:
May the size of an underlying array be longer than the count argument send along with the buffer pointer in a MPI_Send( ... ) call?
As for MPI_Recv( ... ) I've found sources that clearly state that this is legitimate (i.e., the buffer is larger than the message).
Plus, it seems to be OK when I compile and run the below program
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <mpi.h>
int main(int argc, char **argv){
int i;
MPI_Init(&argc, &argv);
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
if( world_size != 2 ) {
printf("You're supposed to use exactly 2 processes, dude!\n");
MPI_Abort( MPI_COMM_WORLD, 0 );
}
int *ids = (int*)( malloc( 10*sizeof(int) ) );
if( world_rank == 0 ) {
for( i=0; i<10; i++)
ids[i]=i+1;
MPI_Send( ids, 5, MPI_INT, 1, 0, MPI_COMM_WORLD);
}else{
for( i=0; i<10; i++)
ids[i]=20-i;
MPI_Recv( ids, 5, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
for( i=0; i<10; i++)
printf("me %d %d %d\n",world_rank,i,ids[i]);
free(ids);
MPI_Finalize();
return 0;
}
because I get following output with no error messages:
me 0 0 1
me 0 1 2
me 0 2 3
me 0 3 4
me 0 4 5
me 0 5 6
me 0 6 7
me 0 7 8
me 0 8 9
me 0 9 10
me 1 0 1
me 1 1 2
me 1 2 3
me 1 3 4
me 1 4 5
me 1 5 15
me 1 6 14
me 1 7 13
me 1 8 12
me 1 9 11
But I'd like to have reassurance because I'm still a newbie...