GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
sparsemat.c File Reference
#include "ghost/config.h"
#include "ghost/types.h"
#include "ghost/sparsemat.h"
#include "ghost/context.h"
#include "ghost/util.h"
#include "ghost/locality.h"
#include "ghost/log.h"
#include "ghost/machine.h"
#include "ghost/bincrs.h"
#include "ghost/matrixmarket.h"
#include "ghost/instr.h"
#include "ghost/constants.h"
#include "ghost/kacz_hybrid_split.h"
#include "ghost/rcm_dissection.h"
#include <libgen.h>
#include <math.h>
#include <limits.h>
Include dependency graph for sparsemat.c:

Functions

static const char * ghost_sparsemat_formatName (ghost_sparsemat *mat)
 
static ghost_error ghost_sparsemat_split (ghost_sparsemat *mat)
 
static ghost_error ghost_set_kacz_ratio (ghost_context *ctx, ghost_sparsemat *mat)
 
ghost_error ghost_sparsemat_create (ghost_sparsemat **mat, ghost_context *context, ghost_sparsemat_traits *traits, int nTraits)
 Create a sparse matrix. More...
 
static ghost_error ghost_sparsemat_sortrow (ghost_gidx *col, char *val, size_t valSize, ghost_lidx rowlen, ghost_lidx stride, ghost_lidx row, bool diagfirst)
 Sort the entries in a given row physically to have increasing column indices. More...
 
static ghost_error ghost_calculate_bw (ghost_context *ctx, ghost_sparsemat *mat)
 
ghost_error ghost_sparsemat_perm_global_cols (ghost_gidx *col, ghost_lidx ncols, ghost_context *context)
 
ghost_error ghost_sparsemat_nrows (ghost_gidx *nrows, ghost_sparsemat *mat)
 Obtain the global number of rows of a sparse matrix. More...
 
ghost_error ghost_sparsemat_nnz (ghost_gidx *nnz, ghost_sparsemat *mat)
 Obtain the global number of nonzero elements of a sparse matrix. More...
 
ghost_error ghost_sparsemat_info_string (char **str, ghost_sparsemat *mat)
 Create a string holding information about the sparsemat. More...
 
ghost_error ghost_sparsematofile_header (ghost_sparsemat *mat, char *path)
 Write the sparse matrix header to a binary CRS file. More...
 
bool ghost_sparsemat_symmetry_valid (ghost_sparsemat_symmetry symmetry)
 Check if the symmetry information of a sparse matrix is valid. More...
 
const char * ghost_sparsemat_symmetry_string (ghost_sparsemat_symmetry symmetry)
 Convert the matrix' symmetry information to a string. More...
 
void ghost_sparsemat_destroy (ghost_sparsemat *mat)
 Destroy a sparsemat and free all memory. More...
 
ghost_error ghost_sparsemat_init_bin (ghost_sparsemat *mat, char *path, ghost_mpi_comm mpicomm, double weight)
 Initializes a sparsemat from a binary CRS file. More...
 
ghost_error ghost_sparsemat_init_mm (ghost_sparsemat *mat, char *path, ghost_mpi_comm mpicomm, double weight)
 Initializes a sparsemat from a Matrix Market file. More...
 
int ghost_sparsemat_rowfunc_crs (ghost_gidx row, ghost_lidx *rowlen, ghost_gidx *col, void *val, void *arg)
 
ghost_error ghost_sparsemat_init_crs (ghost_sparsemat *mat, ghost_gidx offs, ghost_lidx n, ghost_gidx *col, void *val, ghost_lidx *rpt, ghost_mpi_comm mpicomm, double weight)
 Initializes a sparsemat from local CRS data. More...
 
size_t ghost_sparsemat_bytesize (ghost_sparsemat *mat)
 Get the entire memory footprint of the matrix. More...
 
static ghost_error initHaloAvg (ghost_sparsemat *mat)
 
ghost_error ghost_sparsemat_init_rowfunc (ghost_sparsemat *mat, ghost_sparsemat_src_rowfunc *src, ghost_mpi_comm mpicomm, double weight)
 Initializes a sparsemat from a row-based callback function. More...
 
ghost_error ghost_sparsemat_to_bin (ghost_sparsemat *mat, char *matrixPath)
 Write a matrix to a binary CRS file. More...
 

Variables

const ghost_sparsemat_src_rowfunc GHOST_SPARSEMAT_SRC_ROWFUNC_INITIALIZER
 
const ghost_sparsemat_traits GHOST_SPARSEMAT_TRAITS_INITIALIZER
 Initialize sparse matrix traits with default values. More...
 
const ghost_spmv_opts GHOST_SPMV_OPTS_INITIALIZER
 

Function Documentation

static ghost_error ghost_calculate_bw ( ghost_context ctx,
ghost_sparsemat mat 
)
static

Here is the call graph for this function:

static ghost_error ghost_set_kacz_ratio ( ghost_context ctx,
ghost_sparsemat mat 
)
static

Here is the call graph for this function:

size_t ghost_sparsemat_bytesize ( ghost_sparsemat mat)

Get the entire memory footprint of the matrix.

Parameters
matThe matrix.
Returns
The memory footprint of the matrix in bytes or zero if the matrix is not valid.
static const char * ghost_sparsemat_formatName ( ghost_sparsemat mat)
static
ghost_error ghost_sparsemat_nnz ( ghost_gidx nnz,
ghost_sparsemat mat 
)

Obtain the global number of nonzero elements of a sparse matrix.

Parameters
[out]nnzWhere to store the result.
[in]matThe sparse matrix.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_sparsemat_nrows ( ghost_gidx nrows,
ghost_sparsemat mat 
)

Obtain the global number of rows of a sparse matrix.

Parameters
[out]nrowsWhere to store the result.
[in]matThe sparse matrix.
Returns
GHOST_SUCCESS on success or an error indicator.
ghost_error ghost_sparsemat_perm_global_cols ( ghost_gidx col,
ghost_lidx  ncols,
ghost_context context 
)

Here is the call graph for this function:

int ghost_sparsemat_rowfunc_crs ( ghost_gidx  row,
ghost_lidx rowlen,
ghost_gidx col,
void *  val,
void *  arg 
)
inline
static ghost_error ghost_sparsemat_sortrow ( ghost_gidx col,
char *  val,
size_t  valSize,
ghost_lidx  rowlen,
ghost_lidx  stride,
ghost_lidx  row,
bool  diagfirst 
)
static

Sort the entries in a given row physically to have increasing column indices.

Parameters
[in,out]colThe column indices of the row.
[in,out]valThe values of the row.
[in]valSizeThe size of one entry.
[in]rowlenThe length of the row.
[in]strideThe stride between successive elements in the row (1 for CRS, C for SELL-C).
Returns
GHOST_SUCCESS on success or an error indicator.
static ghost_error ghost_sparsemat_split ( ghost_sparsemat mat)
static

Here is the call graph for this function:

bool ghost_sparsemat_symmetry_valid ( ghost_sparsemat_symmetry  symmetry)

Check if the symmetry information of a sparse matrix is valid.

Parameters
[in]symmetryThe symmetry information.
Returns
True if it is valid, false otherwise.
ghost_error ghost_sparsemat_to_bin ( ghost_sparsemat mat,
char *  path 
)

Write a matrix to a binary CRS file.

Parameters
matThe matrix.
pathPath of the file.
static ghost_error initHaloAvg ( ghost_sparsemat mat)
static

Here is the call graph for this function:

Variable Documentation

const ghost_sparsemat_src_rowfunc GHOST_SPARSEMAT_SRC_ROWFUNC_INITIALIZER
Initial value:
= {
.func = NULL,
.maxrowlen = 0,
.base = 0,
.arg = NULL,
.gnrows = 0,
.gncols = 0,
.funcinit = NULL
}
Default behaviour.
Definition: sparsemat_src.h:30
const ghost_sparsemat_traits GHOST_SPARSEMAT_TRAITS_INITIALIZER
Initial value:
= {
.T = 1,
.C = 32,
.scotchStrat = (char*)GHOST_SCOTCH_STRAT_DEFAULT,
.sortScope = 1,
.datatype = GHOST_DT_NONE,
.opt_blockvec_width = 0
}
#define GHOST_DT_NONE
Definition: types.h:268
A default sparse matrix.
Definition: sparsemat.h:312
Non-symmetric (general) matrix.
Definition: sparsemat.h:43
#define GHOST_SCOTCH_STRAT_DEFAULT
Definition: sparsemat.h:459

Initialize sparse matrix traits with default values.

const ghost_spmv_opts GHOST_SPMV_OPTS_INITIALIZER
Initial value:
= {
.alpha = NULL,
.beta = NULL,
.gamma = NULL,
.delta = NULL,
.eta = NULL,
.dot = NULL,
.z = NULL,
.blocksz = GHOST_LIDX_MAX
}
Definition: spmv.h:16
#define GHOST_LIDX_MAX
Definition: types.h:517