SpM Handbook 1.2.4
Loading...
Searching...
No Matches
spm_symmetrize.c File Reference
#include "common.h"

Go to the source code of this file.

Macros

#define TAG_SPM_SYMM   3483
 Arbitrary tag for the symmetry exchange communications.
 

Functions

static void spm_symm_add_missing_elt (spm_int_t *miss_sze, spm_int_t **miss_buf, spm_int_t *miss_nbr, spm_int_t jg, spm_int_t ig, int owner)
 Add a couple (ig, jg) in the list of missing entries of the owner.
 
static int spm_symm_local_search (const spm_int_t *colptr, const spm_int_t *rowptr, spm_int_t jl, spm_int_t ig, spm_int_t baseval)
 Search locally if an element exists.
 
static void spm_symm_check_local_pattern (spmatrix_t *spm, spm_int_t *miss_sze, spm_int_t **miss_buf, spm_int_t *miss_nbr)
 Check the local symmetry of the pattern.
 
static spm_int_t spm_symm_values_newsize (const spmatrix_t *spm, spm_int_t miss_nbr, const spm_int_t *miss_buf)
 Compute the new size of the values array.
 
static spm_int_t spm_symm_local_copy_column (const spmatrix_t *spm, size_t eltsize, spm_int_t jg, const spm_int_t *colptr, const spm_int_t **oldrow, spm_int_t **newrow, const char **oldval, char **newval)
 Copy the former column into the new one.
 
static spm_int_t spm_symm_local_extend_column (spmatrix_t *spm, size_t eltsize, spm_int_t jl, spm_int_t jg, const spm_int_t *colptr, const spm_int_t **oldrowptr, spm_int_t **newrowptr, const char **oldvalptr, char **newvalptr, spm_int_t *miss_nbr, spm_int_t **miss_buf)
 Add the missing entries to the local spm.
 
static void spm_symm_local_add (spmatrix_t *spm, spm_int_t miss_nbr, spm_int_t *miss_buf)
 Add the missing entries to the local spm.
 
spm_int_t spmSymmetrize (spmatrix_t *spm)
 Symmetrize the pattern of the spm.
 

Detailed Description

SParse Matrix package symmetrize routines.

Version
1.2.4
Author
Pierre Ramet
Mathieu Faverge
Tony Delarue
Date
2024-06-25
Remarks
All routines in this files consider the order (j, i) as we usually store the matrix in CSC format.

Definition in file spm_symmetrize.c.

Macro Definition Documentation

◆ TAG_SPM_SYMM

#define TAG_SPM_SYMM   3483

Arbitrary tag for the symmetry exchange communications.

Remarks
We may need to use a tag per spm when solving multiple problem in parallel

Definition at line 26 of file spm_symmetrize.c.

Function Documentation

◆ spm_symm_add_missing_elt()

static void spm_symm_add_missing_elt ( spm_int_t miss_sze,
spm_int_t **  miss_buf,
spm_int_t miss_nbr,
spm_int_t  jg,
spm_int_t  ig,
int  owner 
)
static

Add a couple (ig, jg) in the list of missing entries of the owner.

Parameters
[in,out]miss_szeArray of size spm->clustnbr Contains the allocated sizes of the miss_buf arrays.
[in,out]miss_bufArray of size spm->clustnbr. Contains the pointer to the allocated array of looked for elements.
[in,out]miss_nbrArray of size spm->clustnbr. Contains the number of looked for entries per process.
[in]jgGlobal column index of the looked for element.
[in]igGlobal row index of the looked for element.
[in]ownerIndex of the owner of the looked for element.

Definition at line 60 of file spm_symmetrize.c.

Referenced by spm_symm_check_local_pattern().

◆ spm_symm_local_search()

static int spm_symm_local_search ( const spm_int_t colptr,
const spm_int_t rowptr,
spm_int_t  jl,
spm_int_t  ig,
spm_int_t  baseval 
)
static

Search locally if an element exists.

Parameters
[in]colptrColptr of the local spm.
[in]rowptrRowptr of the local spm.
[in]jlLocal column index of the looked for element. 0-based.
[in]igGlobal row index of the looked for element. O-based.
[in]basevalBaseval of the spm.
Return values
1if a symmetric element is found at (jl, ig);
0otherwise.

Definition at line 115 of file spm_symmetrize.c.

Referenced by spm_symm_check_local_pattern().

◆ spm_symm_check_local_pattern()

static void spm_symm_check_local_pattern ( spmatrix_t spm,
spm_int_t miss_sze,
spm_int_t **  miss_buf,
spm_int_t miss_nbr 
)
static

Check the local symmetry of the pattern.

This function checks the local symmetry of the pattern, and for all missing elements stores them in the miss_xxx arrays for later checks. Local miss will need to be added. Remote miss will need to be first check for existence, and eventually be added to the remote structure.

Parameters
[in,out]spmThe spm for which the pattern symmetry must be checked. On exit, the glob2loc array is allocated if need for later checks.
[in,out]miss_szeArray of size spm->clustnbr Contains the allocated sizes of the miss_buf arrays.
[in,out]miss_bufArray of size spm->clustnbr. Contains the pointer to the allocated array of looked for elements.
[in,out]miss_nbrArray of size spm->clustnbr. Contains the number of looked for entries per process.

Definition at line 176 of file spm_symmetrize.c.

References spmatrix_s::baseval, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::replicated, spmatrix_s::rowptr, spm_getandset_glob2loc(), spm_symm_add_missing_elt(), spm_symm_local_search(), and SpmCSC.

Referenced by spmSymmetrize().

◆ spm_symm_values_newsize()

static spm_int_t spm_symm_values_newsize ( const spmatrix_t spm,
spm_int_t  miss_nbr,
const spm_int_t miss_buf 
)
static

Compute the new size of the values array.

Parameters
[in]spmPointer to the spm matrix
[in]miss_nbrNumber of local missing entries.
[in]miss_bufArray of missing entries.
Returns
The new size of the values array in number of entries.

Definition at line 463 of file spm_symmetrize.c.

References spmatrix_s::baseval, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::loc2glob, spmatrix_s::nnzexp, and spmatrix_s::replicated.

Referenced by spm_symm_local_add().

◆ spm_symm_local_copy_column()

static spm_int_t spm_symm_local_copy_column ( const spmatrix_t spm,
size_t  eltsize,
spm_int_t  jg,
const spm_int_t colptr,
const spm_int_t **  oldrow,
spm_int_t **  newrow,
const char **  oldval,
char **  newval 
)
static

Copy the former column into the new one.

Parameters
[in,out]spmOn entry, the non symmetric local spm. On exit, the spm contains the symmetric elements with a value of 0.
Warning
The computed fields are not updated. Only nnz and nnzexp are.
Parameters
[in]eltsizeThe element size in byte
[in]jgThe global column index.
[in]colptrNumber of local missing entries.
[in,out]oldrowPointer to the current position in the former rowptr array.
[in,out]newrowPointer to the current position in the new rowptr array.
[in,out]oldvalPointer to the current position in the former values array.
[in,out]newvalPointer to the current position in the new values array.
Returns
The number of added elements to symmetrize the pattern.

Definition at line 532 of file spm_symmetrize.c.

References spmatrix_s::baseval, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, and SpmPattern.

Referenced by spm_symm_local_add().

◆ spm_symm_local_extend_column()

static spm_int_t spm_symm_local_extend_column ( spmatrix_t spm,
size_t  eltsize,
spm_int_t  jl,
spm_int_t  jg,
const spm_int_t colptr,
const spm_int_t **  oldrowptr,
spm_int_t **  newrowptr,
const char **  oldvalptr,
char **  newvalptr,
spm_int_t miss_nbr,
spm_int_t **  miss_buf 
)
static

Add the missing entries to the local spm.

This function adds the entries that have been discovered missing in the previous checks. The spm arrays are realllocated to include these entries.

Parameters
[in,out]spmOn entry, the non symmetric local spm. On exit, the spm contains the symmetric elements with a value of 0.
Warning
The computed fields are not updated. Only nnz and nnzexp are.
Parameters
[in]eltsizeThe element size in byte
[in]jlThe local column index.
[in]jgThe global column index.
[in]colptrNumber of local missing entries.
[in,out]oldrowptrPointer to the current position in the former rowptr array.
[in,out]newrowptrPointer to the current position in the new rowptr array.
[in,out]oldvalptrPointer to the current position in the former values array.
[in,out]newvalptrPointer to the current position in the new values array.
[in,out]miss_nbrThe current remaining number of unnknowns to add.
[in,out]miss_bufThe point to the current missing entry to add.
Returns
The number of added elements to symmetrize the pattern.

Definition at line 631 of file spm_symmetrize.c.

References spmatrix_s::baseval, spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, and SpmPattern.

Referenced by spm_symm_local_add().

◆ spm_symm_local_add()

static void spm_symm_local_add ( spmatrix_t spm,
spm_int_t  miss_nbr,
spm_int_t miss_buf 
)
static

Add the missing entries to the local spm.

This function adds the entries that have been discovered missing in the previous checks. The spm arrays are realllocated to include these entries.

Parameters
[in,out]spmOn entry, the non symmetric local spm. On exit, the spm contains the symmetric elements with a value of 0.
Warning
The computed fields are not updated. Only nnz and nnzexp are.
Parameters
[in]miss_nbrNumber of local missing entries.
[in]miss_bufArray of missing entries.

Definition at line 759 of file spm_symmetrize.c.

References spmatrix_s::baseval, spmatrix_s::colptr, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::nnz, spmatrix_s::nnzexp, spmatrix_s::replicated, spmatrix_s::rowptr, spm_size_of(), spm_symm_local_copy_column(), spm_symm_local_extend_column(), spm_symm_values_newsize(), SpmCSC, SpmPattern, and spmatrix_s::values.

Referenced by spmSymmetrize().