ortie
2008-08-21 12:11:26 UTC
Hi,
I thought myself an intermediate MPI, but I've just been demoted ...
all I am trying to do is distribute non contiguous blocks from root to
other processes, and I defined a Type_vector, for which I use
Scatterv, but I now see that the elemtns of the dataype have to be
contguous on that datatype. Not explaining myself properly? Here's my
code: it's dead simple really, a 4x4 matrix (called B), sending a
different 2x2 block to each of 4 processors (including root) which
will be stored in Bportion, their chunk of B:
[CODE]
displacements = calloc(4,sizeof(int));
counts = calloc(4,sizeof(int));
for (i=0;i<2;i++)
for (j=0;j<2;j++) {
displacements[i*2 +j] = i*2+j;
counts[i*2 +j] = 1;
}
MPI_Type_vector(2, 2, 4, MPI_FLOAT, &blockType);
MPI_Type_commit(&blockType);
MPI_Scatterv(B, counts, displacements, blockType, Bportion, 2*2,
MPI_FLOAT, 0 , MPI_COMM_WORLD);
[/CODE]
The rest of the code is running fine, but the datatype I have defined,
blockType will only allow the next element to begin at the very end of
its extent, and not in the middle somewhere. So I get the incorrect
result each time.
I've been over the MPI reference book in the relevant section, but it
doesn't quite hit this spot.
All through the hours I'll spent on this, I think I'm missing
somethign fundamental about dataypes.
Any help, suggestions appreciated.
cheers.
I thought myself an intermediate MPI, but I've just been demoted ...
all I am trying to do is distribute non contiguous blocks from root to
other processes, and I defined a Type_vector, for which I use
Scatterv, but I now see that the elemtns of the dataype have to be
contguous on that datatype. Not explaining myself properly? Here's my
code: it's dead simple really, a 4x4 matrix (called B), sending a
different 2x2 block to each of 4 processors (including root) which
will be stored in Bportion, their chunk of B:
[CODE]
displacements = calloc(4,sizeof(int));
counts = calloc(4,sizeof(int));
for (i=0;i<2;i++)
for (j=0;j<2;j++) {
displacements[i*2 +j] = i*2+j;
counts[i*2 +j] = 1;
}
MPI_Type_vector(2, 2, 4, MPI_FLOAT, &blockType);
MPI_Type_commit(&blockType);
MPI_Scatterv(B, counts, displacements, blockType, Bportion, 2*2,
MPI_FLOAT, 0 , MPI_COMM_WORLD);
[/CODE]
The rest of the code is running fine, but the datatype I have defined,
blockType will only allow the next element to begin at the very end of
its extent, and not in the middle somewhere. So I get the incorrect
result each time.
I've been over the MPI reference book in the relevant section, but it
doesn't quite hit this spot.
All through the hours I'll spent on this, I think I'm missing
somethign fundamental about dataypes.
Any help, suggestions appreciated.
cheers.