MPI send/recv part of matrix dinamic allocation

  • Follow


Hi,
sorry if this post is duplicated, but i not have a fast line, and i
can't read all old post.
This is my problem:

I create 2 matrix in this way:
int *matrix, *matrix_local,n;

matrix is the master, and every processor have a part of it, and store
this part in matrix_local

i allocate the matrix so:

matrix=(int*) calloc(n*n,sizeof(int))
matrix_local=(int*) calloc(n*n_local,sizeof(int))

n_local is the 2 dimension of every local matrix

Now Processor 0 send the pices of matrix at every other processor in
this way:

MPI_Send((matrix+step+j),n,MPI_INT,i,tag,MPI_COMM_WORLD);

and the processor receve in this way:

MPI_Recv((matrice_locale+j),n,MPI_INT,0,tag,MPI_COMM_WORLD,&status);

My problem is that the elements that i send in not correct received,
only the first element sent to every processor is good.

Can you help me???
Sorry for my english bye & thank's

0
Reply rhoss78 (9) 1/15/2007 8:21:48 PM

> Now Processor 0 send the pices of matrix at every other processor in
> this way:
>
> MPI_Send((matrix+step+j),n,MPI_INT,i,tag,MPI_COMM_WORLD);
>
> and the processor receve in this way:
>
> MPI_Recv((matrice_locale+j),n,MPI_INT,0,tag,MPI_COMM_WORLD,&status);

Have you verifyed, that the values of "step" and "j" are correct (whatever this means in your programm) before calling MPI_Send/MPI_Recv?

> My problem is that the elements that i send in not correct received,
> only the first element sent to every processor is good.

Perhaps, the actual value of "n" is wrong?


Have a look at MPI_Scatter or MPI_Scatterv, too. They can be used to distribute data in a one-to-all fashion.


Michael
0
Reply Michael 1/16/2007 8:37:40 AM


1 Replies
480 Views

(page loaded in 0.064 seconds)

Similiar Articles:




7/23/2012 6:23:50 PM


Reply: