LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: a17567182 (a17567182_at_[hidden])
Date: 2005-08-01 09:10:51


Hello,

Could someone explain, why the following code works for MSG_SIZE=4096, but does
no work for MSG_SIZE=16384. The messages are composed of doubles, so the bigger
message has 131072 bytes length, which, as far as I know, involves rendez-vous
communication protocol for implementation of communications.

#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>

//#define MSG_SIZE 16384
#define MSG_SIZE 4096

int main(int argc, char** argv){

    int iMyRank, iPeerRank;
    int iIntTypeSize, iDoubleTypeSize, iRecvdCount;
    double* pdBufIn, *pdBufOut;
    MPI_Status status1, status2;

    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&iMyRank);

    MPI_Type_size(MPI_INT,&iIntTypeSize);
    MPI_Type_size(MPI_DOUBLE,&iDoubleTypeSize);
    if( sizeof(double) != iDoubleTypeSize ) {fprintf(stderr,"Different sizes
for DOUBLE type\n"); return 0;}
    if( sizeof(int) != iIntTypeSize ) {fprintf(stderr,"Different sizes for INT
type\n"); return 0;}
    pdBufIn = (double *)calloc(MSG_SIZE,sizeof(double));
    pdBufOut = (double *)calloc(MSG_SIZE,sizeof(double));

    fprintf(stderr,"%d: start %d bytes\n", iMyRank, MSG_SIZE*iDoubleTypeSize);
fflush(stderr);
    if(iMyRank==0){
        MPI_Send(&iMyRank,1,MPI_INT,1,10,MPI_COMM_WORLD);
        MPI_Send(pdBufOut,MSG_SIZE,MPI_DOUBLE,1,30,MPI_COMM_WORLD);
      
MPI_Recv(&iPeerRank,1,MPI_INT,MPI_ANY_SOURCE,11,MPI_COMM_WORLD,&status1);
MPI_Recv(pdBufIn,MSG_SIZE,MPI_DOUBLE,status1.MPI_SOURCE,31,MPI_COMM_WORLD,&status2);
    }else{
        MPI_Send(&iMyRank,1,MPI_INT,0,11,MPI_COMM_WORLD);
        MPI_Send(pdBufOut,MSG_SIZE,MPI_DOUBLE,0,31,MPI_COMM_WORLD);
      
MPI_Recv(&iPeerRank,1,MPI_INT,MPI_ANY_SOURCE,10,MPI_COMM_WORLD,&status1);
MPI_Recv(pdBufIn,MSG_SIZE,MPI_DOUBLE,status1.MPI_SOURCE,30,MPI_COMM_WORLD,&status2);
    }
    fprintf(stderr,"%d: done\n",iMyRank);
    MPI_Finalize();

    return 0;
}

Thanks!

Anton

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com