efficiency of tranposing a Matrix?

Hong Zhang hzhang at mcs.anl.gov
Thu Feb 22 16:35:54 CST 2007


I added preallocation to MatTranspose_MPIAIJ(),
in which, d_nnz is computed from L, but
o_nnz is set as d_nnz.
This avoids data communication,
and allocates sufficient space in most cases,
I believe :-)

You may either get petsc-dev,
or replace MatTranspose_MPIAIJ() in your
with the one attached. Then rebuild the petsc lib.

Let us know if you still have slow down
in MatTranspose().


On Wed, 21 Feb 2007, Shi Jin wrote:

> Hi there,
> I have a code that keeps on using the same matrix L
> and its transpose in all time updates.
> I can improve the performance of the code by replacing
> the MatMultTranspose() with MatMult() and computing
> the transposed matrix at the beginning of the code for
> only once. The cost is of course extra storage of the
> transposed matrix.
> However, I have a question regarding the efficiency of
> transposing the matrix. I created the Matrix L with
> MPIAIJ and preallocated the proper memory for it.
> Then I call MatTranspose(L,&LT) to compute LT which is
> the transposed L. But I noticed that this process is
> extremely slow, 6 times slower than the creation of
> Matrix L itself.
> The first question is do I need to preallocate the
> memory  for LT also? I didn't do it since I suppose
> PETSc is smart enough to figure out the necessary
> storage.
> Secondly, I am not sure why MatTranspose is so slow. I
> understand in order to transpose a Matrix, one may
> need to call MPI_Alltoall which is extremely
> expensive. But it seems trivial that I can go through
> a similar process of creating the Matrix L and be much
> faster. I am not sure how MatTraspose() is implemented
> and whether I should actually compose LT instead of
> transpose L.
> Thank you very much.
> Shi
> ____________________________________________________________________________________
> Don't get soaked.  Take a quick peak at the forecast
> with the Yahoo! Search weather shortcut.
> http://tools.search.yahoo.com/shortcuts/#loc_weather
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mattranspose.c
Type: text/x-csrc
Size: 2314 bytes
Desc: mattranspose.c
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20070222/3493b5ee/attachment.c>

More information about the petsc-users mailing list