Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0a9a5a41 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Add function to updtae expended, and global fields

parent dfb71d05
No related branches found
No related tags found
No related merge requests found
......@@ -108,6 +108,82 @@ spmInit( pastix_spm_t *spm )
spm->values = NULL;
}
/**
*******************************************************************************
*
* @ingroup pastix_spm
*
* @brief Update all the computed fields based on the static values stored
*
*******************************************************************************
*
* @param[in,out] spm
* The sparse matrix to init.
*
*******************************************************************************/
void
spmUpdateFields( pastix_spm_t *spm )
{
/**
* Compute the local expended field for multi-dofs
*/
if ( spm->dof > 0 ) {
spm->nexp = spm->n * spm->dof;
spm->nnzexp = spm->nnz * spm->dof * spm->dof;
}
else {
pastix_int_t i, j, k, dofi, dofj, baseval;
pastix_int_t *dofptr, *colptr, *rowptr;
baseval = spmFindBase( spm );
colptr = spm->colptr;
rowptr = spm->rowptr;
dofptr = spm->dofs;
spm->nexp = dofptr[ spm->n ] - baseval;
spm->nnzexp = 0;
switch(spm->fmttype)
{
case PastixCSR:
/* Swap pointers to call CSC */
colptr = spm->rowptr;
rowptr = spm->colptr;
case PastixCSC:
for(j=0; j<spm->n; j++, colptr++) {
dofj = dofptr[j+1] - dofptr[j];
for(k=colptr[0]; k<colptr[1]; k++, rowptr++) {
i = *rowptr - baseval;
dofi = dofptr[i+1] - dofptr[i];
spm->nnzexp += dofi * dofj;
}
}
break;
case PastixIJV:
for(k=0; k<spm->nnz; k++, rowptr++, colptr++)
{
i = *rowptr - baseval;
j = *colptr - baseval;
dofi = dofptr[i+1] - dofptr[i];
dofj = dofptr[j+1] - dofptr[j];
spm->nnzexp += dofi * dofj;
}
}
}
/* TODO: add communicator */
spm->gN = spm->n;
spm->gnnz = spm->nnz;
spm->gNexp = spm->nexp;
spm->gnnzexp = spm->nnzexp;
}
/**
*******************************************************************************
*
......
......@@ -61,32 +61,32 @@ typedef enum pastix_driver_e {
*/
struct pastix_spm_s {
int mtxtype; /**< Matrix structure: PastixGeneral, PastixSymmetric
or PastixHermitian. */
or PastixHermitian. */
pastix_coeftype_t flttype; /**< avals datatype: PastixPattern, PastixFloat, PastixDouble,
PastixComplex32 or PastixComplex64 */
pastix_fmttype_t fmttype; /**< Matrix storage format: PastixCSC, PastixCSR, PastixIJV */
PastixComplex32 or PastixComplex64 */
pastix_fmttype_t fmttype; /**< Matrix storage format: PastixCSC, PastixCSR, PastixIJV */
pastix_int_t gN; /**< Global number of vertices in the compressed graph */
pastix_int_t n; /**< Local number of vertices in the compressed graph */
pastix_int_t gnnz; /**< Global number of non zeroes in the compressed graph */
pastix_int_t nnz; /**< Local number of non zeroes in the compressed graph */
pastix_int_t gN; /**< Global number of vertices in the compressed graph (Computed) */
pastix_int_t n; /**< Local number of vertices in the compressed graph */
pastix_int_t gnnz; /**< Global number of non zeroes in the compressed graph (Computed) */
pastix_int_t nnz; /**< Local number of non zeroes in the compressed graph */
pastix_int_t gNexp; /**< Global number of vertices in the compressed graph */
pastix_int_t nexp; /**< Local number of vertices in the compressed graph */
pastix_int_t gnnzexp; /**< Global number of non zeroes in the compressed graph */
pastix_int_t nnzexp; /**< Local number of non zeroes in the compressed graph */
pastix_int_t gNexp; /**< Global number of vertices in the compressed graph (Computed) */
pastix_int_t nexp; /**< Local number of vertices in the compressed graph (Computed) */
pastix_int_t gnnzexp; /**< Global number of non zeroes in the compressed graph (Computed) */
pastix_int_t nnzexp; /**< Local number of non zeroes in the compressed graph (Computed) */
pastix_int_t dof; /**< Number of degrees of freedom per unknown,
if > 0, constant degree of freedom
otherwise, irregular degree of freedom (refer to dofs) */
otherwise, irregular degree of freedom (refer to dofs) */
pastix_int_t *dofs; /**< Array of the first column of each element in the
expanded matrix [+baseval] */
pastix_order_t layout; /**< PastixColMajor, or PastixRowMajor */
expanded matrix [+baseval] */
pastix_order_t layout; /**< PastixColMajor, or PastixRowMajor */
pastix_int_t *colptr; /**< List of indirections to rows for each vertex [+baseval] */
pastix_int_t *rowptr; /**< List of edges for each vertex [+baseval] */
pastix_int_t *loc2glob;/**< Corresponding numbering from local to global [+baseval] */
void *values; /**< Values stored in the matrix */
pastix_int_t *colptr; /**< List of indirections to rows for each vertex [+baseval] */
pastix_int_t *rowptr; /**< List of edges for each vertex [+baseval] */
pastix_int_t *loc2glob;/**< Corresponding numbering from local to global [+baseval] */
void *values; /**< Values stored in the matrix */
};
int
......@@ -145,6 +145,7 @@ void spmInit( pastix_spm_t *spm );
void spmExit( pastix_spm_t *spm );
pastix_spm_t *spmCopy( const pastix_spm_t *spm );
void spmBase( pastix_spm_t *spm, int baseval );
void spmUpdateFields( pastix_spm_t *spm );
int spmConvert( int ofmttype, pastix_spm_t *ospm );
void * spm2Dense( const pastix_spm_t *spm );
pastix_int_t spmFindBase( const pastix_spm_t *spm );
......
......@@ -44,15 +44,11 @@ spmDofExtend( const int type,
* Generate constant dof
*/
if (type == 0) {
newspm->dof = dof;
newspm->nexp = spm->n * dof;
newspm->gNexp = spm->gN * dof;
newspm->nnzexp = spm->nnz * dof * dof;
newspm->gnnzexp = spm->gnnz * dof * dof;
newspm->dof = dof;
}
else {
pastix_int_t i, j, k, dofi, dofj, baseval;
pastix_int_t *dofptr, *colptr, *rowptr;
pastix_int_t i, dofi, baseval;
pastix_int_t *dofptr;
baseval = spmFindBase( spm );
......@@ -69,51 +65,10 @@ spmDofExtend( const int type,
dofi = 1 + ( rand() % dof );
dofptr[1] = dofptr[0] + dofi;
}
newspm->nexp = *dofptr - baseval;
newspm->gNexp = newspm->nexp;
/**
* Count the number of non zeroes
*/
newspm->nnzexp = 0;
colptr = newspm->colptr;
rowptr = newspm->rowptr;
dofptr = newspm->dofs;
switch(spm->fmttype)
{
case PastixCSR:
/* Swap pointers to call CSC */
colptr = newspm->rowptr;
rowptr = newspm->colptr;
case PastixCSC:
for(j=0; j<newspm->n; j++, colptr++) {
dofj = dofptr[j+1] - dofptr[j];
for(k=colptr[0]; k<colptr[1]; k++, rowptr++) {
i = *rowptr - baseval;
dofi = dofptr[i+1] - dofptr[i];
newspm->nnzexp += dofi * dofj;
}
}
break;
case PastixIJV:
for(k=0; k<newspm->nnz; k++, rowptr++, colptr++)
{
i = *rowptr - baseval;
j = *colptr - baseval;
dofi = dofptr[i+1] - dofptr[i];
dofj = dofptr[j+1] - dofptr[j];
newspm->nnzexp += dofi * dofj;
}
}
newspm->gnnzexp = newspm->nnzexp;
}
spmUpdateFields( newspm );
switch (spm->flttype) {
case PastixFloat:
s_spmDofExtend( newspm );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment