|
List Info
Thread: LAM: using an stl vector of vectors
|
|
| LAM: using an stl vector of vectors |

|
2006-10-23 19:51:23 |
|
Hi,
I am trying to scatterv/gatherv an stl vector of vectors, but it
doesn't seem to work, but if I try to do it using a 2d array, it works
fine, is there anything special in the way the memory is allocated in
the case of stl vectors, that is making it not to work correctly?.
Here is my piece of code
tmpSkyMatrix[size][d]
vector <vector<int> > PointsTmp (size, vector<int>(d)); //allocate space in the vector of vectors
....//do some computation
//with a 2d matrix works fine
MPI_Gatherv(skyMatrix, localSkySize, MPI::INT, tmpSkyMatrix, receiveCount, disp, MPI::INT, ROOT, MPI_COMM_WORLD);
//with a vector of vector crashes
MPI_Gatherv(&localSkyline[0][0], localSkySize, MPI::INT,
&PointsTmp[0][0], receiveCount, disp, MPI::INT, ROOT,
MPI_COMM_WORLD);
In case you wonder why I rather use an stl vector, it is because my
computation is making use of some stl algorithms, I just need to
send the resulting data accross the processor, but this data is stored
in a vector of vectors, and is very costly, to load that data into a 2d
array, then receive it, and load it in a vector of vectors again to do
some other processing.
Thanks in advance
|
| LAM: using an stl vector of vectors |

|
2006-10-23 23:48:03 |
Hi Adán,
Unfortunately using STL vectors will probably not work as
they are not
guaranteed to have any particular memory layout, and MPI
requires a
contiguous allocation of memory.
This is a problem that has been studied and there was
recently a paper
published about one way to solve it (http://dx.doi.o
rg/10.1007/11846802_39).
Hope this helps,
Tim
On Monday 23 October 2006 02:51 pm, Adán Cosgaya wrote:
> Hi,
>
> I am trying to scatterv/gatherv an stl vector of
vectors, but it doesn't
> seem to work, but if I try to do it using a 2d array,
it works fine, is
> there anything special in the way the memory is
allocated in the case of
> stl vectors, that is making it not to work correctly?.
>
> Here is my piece of code
> tmpSkyMatrix[size][d]
> vector <vector<int> > PointsTmp (size,
vector<int>(d)); //allocate space in
> the vector of vectors
> ....//do some computation
>
> //with a 2d matrix works fine
> MPI_Gatherv(skyMatrix, localSkySize, MPI::INT,
tmpSkyMatrix, receiveCount,
> disp, MPI::INT, ROOT, MPI_COMM_WORLD);
>
> //with a vector of vector crashes
> MPI_Gatherv(&localSkyline[0][0], localSkySize,
MPI::INT, &PointsTmp[0][0],
> receiveCount, disp, MPI::INT, ROOT, MPI_COMM_WORLD);
>
> In case you wonder why I rather use an stl vector, it
is because my
> computation is making use of some stl algorithms, I
just need to send the
> resulting data accross the processor, but this data is
stored in a vector
> of vectors, and is very costly, to load that data into
a 2d array, then
> receive it, and load it in a vector of vectors again to
do some other
> processing.
>
> Thanks in advance
_______________________________________________
This list is archived at http://www.l
am-mpi.org/MailArchives/lam/
|
|
[1-2]
|
|