LAM/MPI logo

LAM/MPI General User's Mailing List Archives

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

From: Alysson Nunes Diógenes (nunes_at_[hidden])
Date: 2007-09-26 14:34:59


Hi all.

I have a c++ application using stl vectors. Actually, vectors of vectors,
like the one below.

using namespace std;
typedef vector <int> iVec;
typedef vector <iVec> image;
typedef vector <image> image3D;

int tam=10;
image3D test (tam) ;
iVec b ( 10 );

for ( int i=0; i<tam; i++ ) {
    test[i].resize( tam );
    b[i] = i;
    for ( int j=0; j<tam; j++ ) {
        test[i][j].resize( tam );
        for ( int k=0; k<tam; k++ ) {
            test[i][j][k] = i*j*k;
        }
    }
}

I would like to send that to other processor. I read some other emails which
said things about resizing vectors and that really did work for one
dimension vectors, but it doesn't work for 2D or 3D vectors.

MPI_Send(&tam, sizeof( tam ), MPI_INT, 1, 17, MPI_COMM_WORLD);
MPI_Send(&b[0], b.size(), MPI_INT, 1, 17, MPI_COMM_WORLD); /*this work for
1D*/

Receiving

int tam;
MPI_Recv( &tam, sizeof( tam ), MPI_INT, 0, 17, MPI_COMM_WORLD, &status );

b.resize( tam );
MPI_Recv( &b[0], b.size(), MPI_INT, 0, 17, MPI_COMM_WORLD, &status );

I'd like to do the same, but for 2D and 3D vectors. Has anyone ever tried
anything like that?

Thanks in advance

-- 
Alysson Nunes Diógenes
Mechanical Engineering PhD Student
Laboratório de Meios Porosos e Propriedades Termofísicas
Universidade Federal de Santa Catarina