My Project
programmer's documentation
|
Go to the source code of this file.
Macros | |
#define | CS_MATRIX_DISTANT_ROW_USE_COL_IDX (1 << 0) |
#define | CS_MATRIX_DISTANT_ROW_USE_COL_G_ID (1 << 1) |
#define | CS_MATRIX_EXTERNAL_HALO (1 << 2) |
Typedefs | |
typedef struct _cs_matrix_assembler_t | cs_matrix_assembler_t |
typedef struct _cs_matrix_assembler_values_t | cs_matrix_assembler_values_t |
typedef void() | cs_matrix_assembler_values_init_t(void *matrix, const cs_lnum_t *db_size, const cs_lnum_t *eb_size) |
Function pointer for initialization of matrix coefficients using local row ids and column indexes. More... | |
typedef void() | cs_matrix_assembler_values_add_t(void *matrix, cs_lnum_t n, cs_lnum_t stride, const cs_lnum_t row_id[], const cs_lnum_t col_idx[], const cs_real_t vals[]) |
Function pointer for addition to matrix coefficients using local row ids and column indexes. More... | |
typedef void() | cs_matrix_assembler_values_cdo_add_t(void *matrix, cs_lnum_t row_id, cs_lnum_t stride, cs_lnum_t n_cols, const cs_real_t diag_val[], const cs_lnum_t col_idx[], const cs_real_t vals[]) |
Function pointer for addition to matrix coefficients using local row ids and column indexes in case of CDO schemes. Contrary to other add_values() function. Here values are structured in a CSR-like way. By this way one avoids to allocate specific arrays for this step. More... | |
typedef void() | cs_matrix_assembler_values_add_g_t(void *matrix, cs_lnum_t n, cs_lnum_t stride, const cs_gnum_t row_g_id[], const cs_gnum_t col_g_id[], const cs_real_t vals[]) |
Function pointer for addition to matrix coefficients using global row ids and column indexes. More... | |
typedef void() | cs_matrix_assembler_values_begin_t(void *matrix) |
Function pointer to start the final assembly of matrix coefficients. More... | |
typedef void() | cs_matrix_assembler_values_end_t(void *matrix) |
Function pointer to complete the final assembly of matrix coefficients. More... | |
Functions | |
cs_matrix_assembler_t * | cs_matrix_assembler_create (const cs_gnum_t l_range[2], bool separate_diag) |
Create a matrix assembler structure. More... | |
cs_matrix_assembler_t * | cs_matrix_assembler_create_from_shared (cs_lnum_t n_rows, bool separate_diag, const cs_lnum_t row_idx[], const cs_lnum_t col_id[], const cs_halo_t *halo) |
Create a matrix assembler structure based on a given connectivity and associated halo structure. More... | |
void | cs_matrix_assembler_destroy (cs_matrix_assembler_t **ma) |
Destroy a matrix assembler structure. More... | |
void | cs_matrix_assembler_add_g_ids (cs_matrix_assembler_t *ma, cs_lnum_t n, const cs_gnum_t g_row_id[], const cs_gnum_t g_col_id[]) |
Add entries to a matrix assembler structure. More... | |
void | cs_matrix_assembler_compute (cs_matrix_assembler_t *ma) |
Compute internal structures required by a matrix assembler. More... | |
void | cs_matrix_assembler_set_options (cs_matrix_assembler_t *ma, int flags) |
Set option flags for a given matrix assembler structure. More... | |
int | cs_matrix_assembler_get_options (const cs_matrix_assembler_t *ma) |
Return the option flags for a given matrix assembler structure. More... | |
const cs_gnum_t * | cs_matrix_assembler_get_l_range (const cs_matrix_assembler_t *ma) |
Return a pointer to local global row range associated with a matrix assembler. More... | |
const cs_halo_t * | cs_matrix_assembler_get_halo (const cs_matrix_assembler_t *ma) |
Return a pointer to the halo structure associated with a matrix assembler. More... | |
bool | cs_matrix_assembler_get_separate_diag (const cs_matrix_assembler_t *ma) |
Indicate if the matrix assembler is based on a separate diagonal. More... | |
cs_lnum_t | cs_matrix_assembler_get_n_rows (const cs_matrix_assembler_t *ma) |
Return the number of rows associated with a matrix assembler. More... | |
cs_lnum_t | cs_matrix_assembler_get_n_columns (const cs_matrix_assembler_t *ma) |
Return the number of columns associated with a matrix assembler. More... | |
const cs_lnum_t * | cs_matrix_assembler_get_row_index (const cs_matrix_assembler_t *ma) |
Return a row index associated with a matrix assembler. More... | |
const cs_lnum_t * | cs_matrix_assembler_get_col_ids (const cs_matrix_assembler_t *ma) |
Return a column ids associated with a matrix assembler. More... | |
void | cs_matrix_assembler_get_rank_counts (const cs_matrix_assembler_t *ma, int rc[4]) |
Return info on the number of neighbor ranks a matrix assembler may communicate with. More... | |
void | cs_matrix_assembler_log_rank_counts (const cs_matrix_assembler_t *ma, cs_log_t log_id, const char *name) |
Log rank counts for a given matrix assembler. More... | |
cs_matrix_assembler_values_t * | cs_matrix_assembler_values_create (const cs_matrix_assembler_t *ma, bool sep_diag, const cs_lnum_t *db_size, const cs_lnum_t *eb_size, void *matrix, cs_matrix_assembler_values_init_t *init, cs_matrix_assembler_values_add_t *add, cs_matrix_assembler_values_add_g_t *add_g, cs_matrix_assembler_values_begin_t *begin, cs_matrix_assembler_values_end_t *end) |
Create and initialize a matrix assembler values structure. More... | |
void | cs_matrix_assembler_values_finalize (cs_matrix_assembler_values_t **mav) |
Finalize matrix assembler values structure. More... | |
void | cs_matrix_assembler_values_add (cs_matrix_assembler_values_t *mav, cs_lnum_t n, const cs_lnum_t row_id[], const cs_lnum_t col_id[], const cs_real_t val[]) |
Add values to a matrix assembler values structure using local row and column ids. More... | |
void | cs_matrix_assembler_values_add_g (cs_matrix_assembler_values_t *mav, cs_lnum_t n, const cs_gnum_t g_row_id[], const cs_gnum_t g_col_id[], const cs_real_t val[]) |
Add values to a matrix assembler values structure using global row and column ids. More... | |
void | cs_matrix_assembler_values_done (cs_matrix_assembler_values_t *mav) |
Start assembly of matrix values structure. More... | |
#define CS_MATRIX_DISTANT_ROW_USE_COL_G_ID (1 << 1) |
#define CS_MATRIX_DISTANT_ROW_USE_COL_IDX (1 << 0) |
Matrix assembler option flags
#define CS_MATRIX_EXTERNAL_HALO (1 << 2) |
typedef struct _cs_matrix_assembler_t cs_matrix_assembler_t |
Structure used to pre-build a matrix structure
typedef void() cs_matrix_assembler_values_add_g_t(void *matrix, cs_lnum_t n, cs_lnum_t stride, const cs_gnum_t row_g_id[], const cs_gnum_t col_g_id[], const cs_real_t vals[]) |
Function pointer for addition to matrix coefficients using global row ids and column indexes.
Values whose global row id is outside the local range should be ignored (this allows simply filtering values before calling this function, avoiding an extra copy (a copy will probably be done by the function anyways).
[in,out] | matrix | untyped pointer to matrix description structure |
[in] | n | number of values to add |
[in] | stride | associated data block size |
[in] | g_row_id | associated global row ids |
[in] | g_col_id | associated global column ids |
[in] | val | pointer to values (size: n*stride) |
typedef void() cs_matrix_assembler_values_add_t(void *matrix, cs_lnum_t n, cs_lnum_t stride, const cs_lnum_t row_id[], const cs_lnum_t col_idx[], const cs_real_t vals[]) |
Function pointer for addition to matrix coefficients using local row ids and column indexes.
Values whose associated row index is negative should be ignored; Values whose column index is -1 are assumed to be assigned to a separately stored diagonal. Other indexes should be valid.
[in,out] | matrix | untyped pointer to matrix description structure |
[in] | n | number of values to add |
[in] | stride | associated data block size |
[in] | row_id | associated local row ids |
[in] | col_idx | associated local column indexes |
[in] | val | pointer to values (size: n*stride) |
typedef void() cs_matrix_assembler_values_begin_t(void *matrix) |
Function pointer to start the final assembly of matrix coefficients.
[in,out] | matrix | untyped pointer to matrix description structure |
typedef void() cs_matrix_assembler_values_cdo_add_t(void *matrix, cs_lnum_t row_id, cs_lnum_t stride, cs_lnum_t n_cols, const cs_real_t diag_val[], const cs_lnum_t col_idx[], const cs_real_t vals[]) |
Function pointer for addition to matrix coefficients using local row ids and column indexes in case of CDO schemes. Contrary to other add_values() function. Here values are structured in a CSR-like way. By this way one avoids to allocate specific arrays for this step.
Values whose associated row index is negative should be ignored; Values whose column index is -1 are assumed to be assigned to a separately stored diagonal. Other indexes should be valid.
[in,out] | matrix_p | untyped pointer to matrix description structure |
[in] | row_id | local row id to deal with |
[in] | stride | associated data block size |
[in] | n_cols | number of columns for the row to deal with |
[in] | diag_val | pointer to the diagonal value(s) |
[in] | col_idx | associated local column indexes |
[in] | vals | pointer to values (size: n*stride*row_size) |
typedef void() cs_matrix_assembler_values_end_t(void *matrix) |
Function pointer to complete the final assembly of matrix coefficients.
[in,out] | matrix | untyped pointer to matrix description structure |
typedef void() cs_matrix_assembler_values_init_t(void *matrix, const cs_lnum_t *db_size, const cs_lnum_t *eb_size) |
Function pointer for initialization of matrix coefficients using local row ids and column indexes.
[in,out] | matrix | untyped pointer to matrix description structure |
[in] | db | size optional diagonal block sizes |
[in] | eb | size optional extra-diagonal block sizes |
typedef struct _cs_matrix_assembler_values_t cs_matrix_assembler_values_t |
Structure used to set matrix coefficients
void cs_matrix_assembler_add_g_ids | ( | cs_matrix_assembler_t * | ma, |
cs_lnum_t | n, | ||
const cs_gnum_t | g_row_id[], | ||
const cs_gnum_t | g_col_id[] | ||
) |
Add entries to a matrix assembler structure.
This function should be called by a single thread for a given assembler.
[in,out] | ma | pointer to matrix assembler structure |
[in] | n | number of entries |
[in] | g_col_id | global column ids associated with entries |
[in] | g_row_id | global row ids associated with entries |
void cs_matrix_assembler_compute | ( | cs_matrix_assembler_t * | ma | ) |
Compute internal structures required by a matrix assembler.
The associated vector halo is also computed at this stage.
[in,out] | ma | pointer to matrix assembler structure |
This function should be called by a single thread for a given assembler.
cs_matrix_assembler_t* cs_matrix_assembler_create | ( | const cs_gnum_t | l_range[2], |
bool | separate_diag | ||
) |
Create a matrix assembler structure.
The associated matrix structure data will initially be empty, though the range of rows associated with the current rank must be defined immediately.
[in] | l_range | global id range [min, max[ for local rank |
[in] | separate_diag | if true, diagonal terms are handled separately |
cs_matrix_assembler_t* cs_matrix_assembler_create_from_shared | ( | cs_lnum_t | n_rows, |
bool | separate_diag, | ||
const cs_lnum_t | row_idx[], | ||
const cs_lnum_t | col_id[], | ||
const cs_halo_t * | halo | ||
) |
Create a matrix assembler structure based on a given connectivity and associated halo structure.
The assembler may not be later modified when built this way.
The connectivity arrays and halo will be shared by the caller, so their life cycle must be at least as long as the matrix assembler structure.
[in] | n_rows | number fo local rows |
[in] | separate_diag | if true, diagonal terms are handled separately |
[in] | row_idx | matrix row index |
[in] | col_id | matrix column indexes |
[in] | halo | associated halo structure |
void cs_matrix_assembler_destroy | ( | cs_matrix_assembler_t ** | ma | ) |
Destroy a matrix assembler structure.
[in,out] | ma | pointer to matrix assembler structure pointer |
const cs_lnum_t* cs_matrix_assembler_get_col_ids | ( | const cs_matrix_assembler_t * | ma | ) |
Return a column ids associated with a matrix assembler.
These ids relative to all columns of successive rows, with columns ordered by local id, so local columns appear first, distant columns after. Depending on the separate_diag
option used when creating the matrix assembler, the columns may include the diagonal or not. The matching index can be obtained using cs_matrix_assembler_get_row_index.
[in] | ma | pointer to matrix assembler structure |
const cs_halo_t* cs_matrix_assembler_get_halo | ( | const cs_matrix_assembler_t * | ma | ) |
Return a pointer to the halo structure associated with a matrix assembler.
[in] | ma | pointer to matrix assembler structure |
const cs_gnum_t* cs_matrix_assembler_get_l_range | ( | const cs_matrix_assembler_t * | ma | ) |
Return a pointer to local global row range associated with a matrix assembler.
[in] | ma | pointer to matrix assembler structure |
cs_lnum_t cs_matrix_assembler_get_n_columns | ( | const cs_matrix_assembler_t * | ma | ) |
Return the number of columns associated with a matrix assembler.
[in] | ma | pointer to matrix assembler structure |
cs_lnum_t cs_matrix_assembler_get_n_rows | ( | const cs_matrix_assembler_t * | ma | ) |
Return the number of rows associated with a matrix assembler.
[in] | ma | pointer to matrix assembler structure |
int cs_matrix_assembler_get_options | ( | const cs_matrix_assembler_t * | ma | ) |
Return the option flags for a given matrix assembler structure.
Flags are defined as a sum (bitwise or) of constants, described in cs_matrix_assembler_set_options.
[in] | ma | pointer to matrix assembler structure |
void cs_matrix_assembler_get_rank_counts | ( | const cs_matrix_assembler_t * | ma, |
int | rc[4] | ||
) |
Return info on the number of neighbor ranks a matrix assembler may communicate with.
[in] | ma | pointer to matrix assembler structure |
[out] | rc | rank counts; the 4 values are:
|
const cs_lnum_t* cs_matrix_assembler_get_row_index | ( | const cs_matrix_assembler_t * | ma | ) |
Return a row index associated with a matrix assembler.
This index is a CSR type index relative to all columns, including or excluding the diagonal depending on the separate_diag
option used when creating the matrix assembler. The matching column ids can be obtained using cs_matrix_assembler_get_col_ids.
[in] | ma | pointer to matrix assembler structure |
bool cs_matrix_assembler_get_separate_diag | ( | const cs_matrix_assembler_t * | ma | ) |
Indicate if the matrix assembler is based on a separate diagonal.
[in] | ma | pointer to matrix assembler structure |
void cs_matrix_assembler_log_rank_counts | ( | const cs_matrix_assembler_t * | ma, |
cs_log_t | log_id, | ||
const char * | name | ||
) |
Log rank counts for a given matrix assembler.
[in] | ma | pointer to matrix assembler structure |
[in] | log_id | log type |
[in] | name | name of this assembler |
void cs_matrix_assembler_set_options | ( | cs_matrix_assembler_t * | ma, |
int | flags | ||
) |
Set option flags for a given matrix assembler structure.
When used, this function should be called before defining entries (in case of future option additions) and in any case before computing the final structure.
Flags are defined as a sum (bitwise or) of constants, described below:
[in,out] | ma | pointer to matrix assembler structure |
[in] | flags | sum of matrix assembler flag constants (bitwise or) |
void cs_matrix_assembler_values_add | ( | cs_matrix_assembler_values_t * | mav, |
cs_lnum_t | n, | ||
const cs_lnum_t | row_id[], | ||
const cs_lnum_t | col_id[], | ||
const cs_real_t | val[] | ||
) |
Add values to a matrix assembler values structure using local row and column ids.
If the matching matrix coefficients use a block structure, the values passed to this function should use the same block size.
Note also that if the matrix has different diagonal and extradiagonal block sizes, separate calls to this function should be used for both types of coefficients; in addition, in this case, diagonal coefficients should only be provided by the owning rank (this also impacts how the associated matrix assembler structure is defined).
This function may be called by different threads, as long those threads do not add contributions to the same rows (assuming caution is taken in the case of external libraries so that their builder functions have tht same property).
[in,out] | mav | pointer to matrix assembler values structure |
[in] | n | number of entries |
[in] | col_id | local column ids associated with entries |
[in] | row_id | local row ids associated with entries |
[in] | val | values associated with entries |
void cs_matrix_assembler_values_add_g | ( | cs_matrix_assembler_values_t * | mav, |
cs_lnum_t | n, | ||
const cs_gnum_t | g_row_id[], | ||
const cs_gnum_t | g_col_id[], | ||
const cs_real_t | val[] | ||
) |
Add values to a matrix assembler values structure using global row and column ids.
If the matching matrix coefficients use a block structure, the values passed to this function should use the same block size.
Note also that if the matrix has different diagonal and extradiagonal block sizes, separate calls to this function should be used for both types of coefficients; in addition, in this case, diagonal coefficients should only be provided by the owning rank (this also impacts how the associated matrix assembler structure is defined).
This function may be called by different threads, as long those threads do not add contributions to the same rows (assuming caution is taken in the case of external libraries so that their builder functions have tht same property).
[in,out] | mav | pointer to matrix assembler values structure |
[in] | n | number of entries |
[in] | g_col_id | global column ids associated with entries |
[in] | g_row_id | global row ids associated with entries |
[in] | val | values associated with entries |
cs_matrix_assembler_values_t* cs_matrix_assembler_values_create | ( | const cs_matrix_assembler_t * | ma, |
bool | sep_diag, | ||
const cs_lnum_t * | db_size, | ||
const cs_lnum_t * | eb_size, | ||
void * | matrix, | ||
cs_matrix_assembler_values_init_t * | init, | ||
cs_matrix_assembler_values_add_t * | add, | ||
cs_matrix_assembler_values_add_g_t * | add_g, | ||
cs_matrix_assembler_values_begin_t * | begin, | ||
cs_matrix_assembler_values_end_t * | end | ||
) |
Create and initialize a matrix assembler values structure.
The associated values will initially be set to zero.
Block sizes are defined by an optional array of 4 values: 0: useful block size, 1: vector block extents, 2: matrix line extents, 3: matrix line*column extents
This is a low-level function, which should be called by a simpler function (cs_matrix_assembler_values_init) which provides the necessary function pointers.
[in] | ma | associated matrix assembly structure |
[in] | sep_diag | true if diagonal terms are stored separately |
[in] | db_size | optional diagonal block sizes |
[in] | eb_size | optional extra-diagonal block sizes |
[in,out] | matrix | untyped pointer to matrix description structure |
[in] | init | pointer to matrix coefficients initialization function |
[in] | add | pointer to matrix coefficients addition from local ids function |
[in] | add_g | pointer to matrix coefficients addition from global ids function |
[in] | begin | pointer to matrix coefficients assembly start function (optional) |
[in] | end | pointer to matrix coefficients assembly end function (optional) |
void cs_matrix_assembler_values_done | ( | cs_matrix_assembler_values_t * | mav | ) |
Start assembly of matrix values structure.
The call to this function is always optional, and indicates that assembly may begin. Calling it before cs_matrix_assembler_values_finalize may be useful when the underlying libraries can overlap communication (or other operations such as matrix trasformation) and computation.
[in,out] | mav | pointer to matrix assembler data structure |
void cs_matrix_assembler_values_finalize | ( | cs_matrix_assembler_values_t ** | mav | ) |
Finalize matrix assembler values structure.
When this function returns, the assembler values structure has been destroyed, and the associated matrix is fully assembled (i.e. ready to use).
[in,out] | mav | pointer to matrix assembler values structure pointer |