Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] Problems Broadcasting/Scattering Data
From: Dino Rossegger (dino.rossegger_at_[hidden])
Date: 2008-01-08 09:54:36

I have a problem distributing a 2 dimensional array over 3 processes.

I tried different methods to distribute the data (Broadcast, Send/Recv,
Scatter) but all of them didn't work for me. The output of the root
processor (0 in my case) is always okay, the output of the others are
simple 0.

The Array stat is filled with entrys from a file (I left out the
generation of the Array Data since this is much code and it works
(tested the whole thing in "single" mode.))

Here are the important parts of the Source Code:

const int ARRAYSIZE = 150;
int main(int argc, char* argv[])
        int rank, anzprocs,recvcount,sendcnt;
        const int WORKING = ARRAYSIZE/anzprocs;
        double stat[ARRAYSIZE][2];
        double stathlp[WORKING][2];

        double stat2[WORKING][5];
        double stat3[anzprocs][ARRAYSIZE][5];

        for(int i=0;i<WORKING;i++){
                if (rank==0) recvcount=WORKING*5;
        MPI_Gather(&stat2, WORKING*5, MPI_DOUBLE,&stat3, recvcount, MPI_DOUBLE,
        if (rank==0){
                cout << stat3[0][0][0] << endl;
                cout << stat3[1][0][0] << endl;
                cout << stat3[2][0][0] << endl;

I don't know any further since my experience with OMPI is also not too
big. Is there anything specific I have to know about distributing 2
Dimensional Arrays? I don't think that the error is in the MPI_Gather,
since I did a cout of the data on all nodes and the output was the same.

Thanks in advance and sorry for my bad english