BeBOP Optimized Sparse Kernel Interface Library
1.0.1h
|
BCSR fill ratio estimator. More...
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <oski/common.h>
#include <oski/heur/estfill.h>
Defines | |
#define | GET_BC(A, c, J) (A)[((c)-1)*n + (J)] |
#define | INC_BC(A, c, J) (A)[((c)-1)*n + (J)]++ |
#define | ZERO_BC(A, c, J) (A)[((c)-1)*n + (J)] = 0 |
Functions | |
static int | EstimateBlockCounts (const oski_index_t *ptr, const oski_index_t *ind, oski_index_t base, oski_index_t m, oski_index_t n, oski_index_t r, oski_index_t max_c, double prob_examine, oski_index_t *p_nnz_est, oski_index_t *p_nb_est) |
Given an ![]() ![]() ![]() | |
static int | CheckArgs (const oski_matspecific_t *A, const oski_matcommon_t *props, size_t max_r, size_t max_c, double prob_examine, const char *caller) |
Check input arguments to a function with a signature like oski_EstimateFillBCSR(). | |
static int | EstimateFillFromCSR (const oski_matCSR_t *A, const oski_matcommon_t *props, size_t max_r, size_t max_c, double prob_examine, oski_fillprofile_BCSR_t *fill) |
This routine is a wrapper around EstimateBlockCounts(). | |
static int | EstimateFillFromCSC (const oski_matCSC_t *A, const oski_matcommon_t *props, size_t max_r, size_t max_c, double prob_examine, oski_fillprofile_BCSR_t *fill) |
Estimate the fill ratio for a matrix initially in CSC format. | |
oski_fillprofile_BCSR_t * | oski_EstimateFillBCSR (const oski_matspecific_t *mat, const oski_matcommon_t *props, size_t max_r, size_t max_c, double prob_examine) |
Estimate the fill ratio at a variety of block sizes for BCSR storage. | |
void | oski_DestroyBCSRFillProfile (oski_fillprofile_BCSR_t *fill) |
Free the memory associated with a fill profile. |
BCSR fill ratio estimator.
static int EstimateBlockCounts | ( | const oski_index_t * | ptr, |
const oski_index_t * | ind, | ||
oski_index_t | base, | ||
oski_index_t | m, | ||
oski_index_t | n, | ||
oski_index_t | r, | ||
oski_index_t | max_c, | ||
double | prob_examine, | ||
oski_index_t * | p_nnz_est, | ||
oski_index_t * | p_nb_est | ||
) | [static] |
Given an CSR matrix
, estimates the fill ratio if the matrix were converted into
BCSR format.
The caller supplies this routine with a maximum column block size , and this routine returns the estimated fill ratios for all
.
If the converted matrix has blocks, this implementation executes in
time, but requires
auxiliary storage space to store a dense copies of the block rows.
This routine assumes the CSR matrix uses full storage, but otherwise is flexible with regard to the following variations:
[in] | ptr | CSR row pointers. |
[in] | ind | CSR column indices. |
[in] | base | Index base (0-based or 1-based) |
[in] | m | Logical number of matrix rows |
[in] | n | Logical number of matrix columns |
[in] | r | Desired row block size |
[in] | max_c | Maximum desired column block size ( ![]() |
[in] | prob_examine | The desired probability of examining each block row. |
[in,out] | p_nnz_est | Used to return the number of non-zeros actually examined. Must be non-NULL. |
[in,out] | p_nb_est | Used to return the number of ![]() ![]() |
Get the block count for block column size c, block column J.
Increment the block count for block column size c, block column J.
Set the block count for block column size c, block column J, to zero.
References ERR_OUT_OF_MEMORY, oski_Free, oski_Malloc, and oski_ZeroMem().
Referenced by EstimateFillFromCSC(), and EstimateFillFromCSR().
static int EstimateFillFromCSC | ( | const oski_matCSC_t * | A, |
const oski_matcommon_t * | props, | ||
size_t | max_r, | ||
size_t | max_c, | ||
double | prob_examine, | ||
oski_fillprofile_BCSR_t * | fill | ||
) | [static] |
Estimate the fill ratio for a matrix initially in CSC format.
This implementation exploits the fact that the CSC representation is based on the transpose of the CSR implementation.
References oski_matCSR_t::base_index, ERR_OUT_OF_MEMORY, EstimateBlockCounts(), oski_matCSR_t::ind, oski_matCSC_t::mat_trans, oski_matcommon_t::num_cols, oski_matcommon_t::num_rows, oski_Free, oski_Malloc, oski_ZeroMem(), PROF_FILLBCSR_SET, and oski_matCSR_t::ptr.
Referenced by oski_EstimateFillBCSR().
static int EstimateFillFromCSR | ( | const oski_matCSR_t * | A, |
const oski_matcommon_t * | props, | ||
size_t | max_r, | ||
size_t | max_c, | ||
double | prob_examine, | ||
oski_fillprofile_BCSR_t * | fill | ||
) | [static] |
This routine is a wrapper around EstimateBlockCounts().
[in] | A | Matrix in CSR format. |
[in] | props | Properties of A. |
[in] | max_r | Maximum row block size to consider. |
[in] | max_c | Maximum column block size to consider. |
[in] | prob_examine | Probability of examining a given block row. |
[in,out] | fill | Structure in which to store the fill ratio profile for A. |
References oski_matCSR_t::base_index, ERR_OUT_OF_MEMORY, EstimateBlockCounts(), oski_matCSR_t::ind, oski_matcommon_t::num_cols, oski_matcommon_t::num_rows, oski_Free, oski_Malloc, oski_ZeroMem(), PROF_FILLBCSR_SET, and oski_matCSR_t::ptr.
Referenced by oski_EstimateFillBCSR().
void oski_DestroyBCSRFillProfile | ( | oski_fillprofile_BCSR_t * | fill | ) |
Free the memory associated with a fill profile.
References oski_Free, and oski_fillprofile_BCSR_t::ratio.
oski_fillprofile_BCSR_t* oski_EstimateFillBCSR | ( | const oski_matspecific_t * | mat, |
const oski_matcommon_t * | props, | ||
size_t | max_r, | ||
size_t | max_c, | ||
double | prob_examine | ||
) |
Estimate the fill ratio at a variety of block sizes for BCSR storage.
References CheckArgs(), ERR_BAD_MAT, EstimateFillFromCSC(), EstimateFillFromCSR(), MACRO_TO_STRING, oski_fillprofile_BCSR_t::max_c, oski_fillprofile_BCSR_t::max_r, oski_Free, OSKI_IND_ID, oski_LookupMatTypeId(), oski_Malloc, OSKI_VAL_ID, oski_fillprofile_BCSR_t::ratio, oski_matspecific_t::repr, and oski_matspecific_t::type_id.