most efficient way to use local CSR matrix?

Chris Kees christopher.e.kees at usace.army.mil
Tue Oct 20 20:04:55 CDT 2009


Hi,

Our unstructured finite element code does a fairly standard  
overlapping decomposition that allows it to calculate all the non-zero  
column entries for the rows owned by the processor (rows 0...ldim-1 in  
the local numbering).  We assemble them into a local CSR matrix and  
then copy them into a PETSc matrix like this:

for (int i=0;i<ldim;i++)
{
   irow[0] = i;
   MatSetValuesLocal(PETSCMAT(par_L),1,irow,rowptr[i+1]- 
rowptr[i],&colind[rowptr[i]],&a[rowptr[i]],INSERT_VALUES);
}

where rowptr and colind are the CSR indexing arrays in the local  
numbering.

I would like to eliminate the duplicate memory (and the copy above).  
Is there a recommended way to let PETSc reference array 'a' directly  
or a way to get rid of 'a' and translate our CSR assembly routines to  
use low level PETSc data structures?

So far I've added MatMPIAIJSetPreallocationCSR to try to speed up the  
first solve, but the documentation is clear that 'a' is not a pointer  
to the AIJ storage so I still need the copy. I tried using  
MatCreateMPIAIJWithSplitArrays with the 'o' arrays set to zero but I  
got indexing errors, and the documentation really seems to imply that  
the local matrix is really not a standard CSR anyway. If that's true  
then it seems like the options I have are to write a shell matrix for  
parallel CSR storage or write some new assembly routines that use  
MatSetValuesLocal. I'm more concerned about the memory than the  
overhead of MatSetValuesLocal, but it would certainly be easier on me  
to use the CSR-based assembly routines we already have.

Thanks,
Chris



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20091020/8e825b38/attachment.html>


More information about the petsc-dev mailing list