[petsc-users] Flexiable AIJ matrix for nonzeros -- hash table version

Gong Ding gdiso at ustc.edu
Tue May 10 03:16:18 CDT 2011


> 2011/5/9 Gong Ding <gdiso at ustc.edu>:
> 
> > Hi
> 
> > I created a flexible AIJ matrix type –named as FAIJ. It has an extra hash table for nonzero which do not have pre-allocated position. And the buffered values in hash table will be flushed to AIJ array at MatAssemblyEnd. Both sequential and parallel version have been implemented and tested.
> 
> >
> 
> 
> 
> Great!! Have you thought about extending regular AIJ matrices to use a
> 
> hash table on first assembly (perhaps activated with an option) and
> 
> switch back to regular assembly for the next assemblies? I'm assuming
> 
> here that calls to MatSetValues() fill the hash table even if values
> 
> are zero.

MatSetValues will first search position of matrix entry in AIJ array. 
If entry already exists or having empty space for new entry, only AIJ array will be used.
Hash table only be used when no more space exist and MatSeqXAIJReallocateAIJ is required.
Add zero is still controled by flag ignorezeroentries. 
 
 
> 
> > The test results show that for middle size problem – matrix size around 1M, FAIJ without any pre-allocation still pretty fast. The shortcoming is memory overkill exists. Fortunately, modern computers have larger and larger memory.  User with FAIJ matrix only needs to provide approximate nonzero pattern or even skip this step.
> 
> >
> 
> 
> 
> How did you wrote your hash table? What are the keys and values? Are
> 
> you using a hash table per row? Or it is actuallyan  (i,j)->a hash
> 
> table?

I just use uthash http://uthash.sourceforge.net. It is a bsd licensed hash table implementation. 
At present, the hash key is <row,col> pair. Using row index as hash key, and store each row as dynamic array of col, value
is possible. 
In general, hash table with key <row,col> is fast enough. 
   
 
> > However, direct solvers such as mumps and superlu_dist will crash. This is caused by type compare functions, i.e.:
> 
> > ierr = PetscTypeCompare((PetscObject)A,MATMPIAIJ,&isAIJ);CHKERRQ(ierr);
> 
> > FAIJ matrix is derived from AIJ, but it has its own type name, i.e. MATMPIFAIJ. The above function will assign isAIJ false.
> 
> >
> That's the reason I think that adding this feature to regular AIJ
> 
> matrices could be better.

Add hash table to original AIJ avoid the type name problem. However, there are some other matrix types also derived from AIJ. i.e. 
CSRPERM. As a result, I guess CSRPERM will also crash...
I think each sub type (of AIJ matrix, i.e.) should hold its base type. And mumps interface only needs to check the base type.   


 
> > Is there any function like “PetscBaseType” exist?  FAIJ matrix can hold its type name as well as its base type name.
> 
> >
> 
> > I hope FAIJ can be accepted by petsc 3.2.
> 
> > Thanks.
> 
> >
> 
> 
> 
> I think Satish pushed something related to this a few days ago...
> 
> 
> 
> 
> 
> -- 
> 
> Lisandro Dalcin
> 
> ---------------
> 
> CIMEC (INTEC/CONICET-UNL)
> 
> Predio CONICET-Santa Fe
> 
> Colectora RN 168 Km 472, Paraje El Pozo
> 
> 3000 Santa Fe, Argentina
> 
> Tel: +54-342-4511594 (ext 1011)
> 
> Tel/Fax: +54-342-4511169
> 
>


More information about the petsc-users mailing list