BeBOP: pOSKI  v1.0.0
parallel Optimized Sparse Kernel Interface library
 All Files Functions Variables
Functions
poski_MatrixHandler.c File Reference

Handle the tunable sparse matrix object. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <poski/poski_threadcommon.h>
#include <poski/poski_thread.h>
#include <poski/poski_partitioncommon.h>
#include <poski/poski_partition.h>
#include <poski/poski_matrixcommon.h>
#include <poski/poski_matrixgetset.h>
#include <poski/poski_kernelcommon.h>
#include <poski/poski_malloc.h>
#include <poski/poski_print.h>

Functions

poski_mat_t poski_CreateMatCSR (poski_index_t *ptr, poski_index_t *ind, poski_value_t *val, poski_index_t nrows, poski_index_t ncols, poski_index_t nnz, poski_copymode_t mode, poski_threadarg_t *threadargs, poski_partitionarg_t *partitionargs, int k,...)
 Create a tunable matrix object in CSR format.
poski_mat_t poski_CreateMatCSRFile (poski_sparse_matrix_t *SpA, poski_copymode_t mode, poski_threadarg_t *threadargs, poski_partitionarg_t *partitionargs, int k,...)
 Create a tunable matrix object in CSR format.
int poski_DestroyMat (poski_mat_t A_tunable)
 Destroy the tunable matrix object.
int poski_SetMatEntry (poski_mat_t A_tunable, poski_int_t row, poski_int_t col, poski_value_t val)
 Change the value of the specified matrix element.
poski_value_t poski_GetMatEntry (poski_mat_t A_tunable, poski_int_t row, poski_int_t col)
 Returns the value of the specified matrix element in A(row,col).
int poski_SetMatSubset (poski_mat_t A_tunable, const int numRows, const int numCols, const int rowStride, const int colStride, const poski_int_t *rows, const poski_int_t *cols, const poski_value_t *vals, poski_subsettype_t subsettype)
 Set a subset of non-zero values, specified as a clique or indexed list.
int poski_GetMatSubset (poski_mat_t A_tunable, const int numRows, const int numCols, const int rowStride, const int colStride, const poski_int_t *rows, const poski_int_t *cols, poski_value_t *vals, poski_subsettype_t subsettype)
 Get a subset of values, specified as a subset or indexed list.
int poski_report_tunable_matrix (poski_mat_t mat)
 Report information of a tunable matrix object.

Detailed Description

Handle the tunable sparse matrix object.

This module implements the routines to handle the tunable sparse matrix object.

Attention:
Currently, only support a sparse matrix in CSR format.

Also, refer poski_Matrix_common.c, poski_Matrix_getset.c


Function Documentation

poski_mat_t poski_CreateMatCSR ( poski_index_t *  ptr,
poski_index_t *  ind,
poski_value_t *  val,
poski_index_t  nrows,
poski_index_t  ncols,
poski_index_t  nnz,
poski_copymode_t  mode,
poski_threadarg_t *  threadargs,
poski_partitionarg_t *  partitionargs,
int  k,
  ... 
)

Create a tunable matrix object in CSR format.

Parameters:
[in]ptrCSR row pointers.
[in]indCSR column indices.
[in]valCSR non-zero values.
[in]nrowsNumber of rows.
[in]ncolsNumber of columns.
[in]nnzNumber of non-zeros.
[in]modeCopy mode in {SHARE_INPUTMAT, COPY_INPUTMAT} for matrix creation routines.
[in]threadargsThreading model information.
[in]partitionargsPartitioning model information.
[in]kNumber of explicitly specified semantic properties of a sparse matrix (ptr, ind, val).
[in]...Specified semantic properties $<property_1>, ..., <property_k>$. See poski_inmatprop_t.
Returns:
A valid, tunable matrix object if success, or an error message otherwise.

This routine performs as follows:

(1) error-check for the input parameters.

(2) collect the specified semantic properies.

(3) allocate the space for a new tunable matrix object, and initailize it.

(4) create the partitioned submatrices.

(5) clean-up the temporary stroage and return the tunable matrix object.

poski_mat_t poski_CreateMatCSRFile ( poski_sparse_matrix_t *  SpA,
poski_copymode_t  mode,
poski_threadarg_t *  threadargs,
poski_partitionarg_t *  partitionargs,
int  k,
  ... 
)

Create a tunable matrix object in CSR format.

Parameters:
[in]SpASparse matrix in CSR format.
[in]modeCopy mode in {SHARE_INPUTMAT, COPY_INPUTMAT} for matrix creation routines.
[in]threadargsThreading model information.
[in]partitionargsPartitioning model information.
[in]kNumber of explicitly specified semantic properties of a sparse matrix (ptr, ind, val).
[in]...Specified semantic properties $<property_1>, ..., <property_k>$. See poski_inmatprop_t.
Returns:
A valid, tunable matrix object if success, or an error message otherwise.

This routine performs as follows:

(1) error-check for the input parameters.

(2) collect the specified semantic properies.

(3) allocate the space for a new tunable matrix object, and initailize it.

(4) create the partitioned submatrices.

(5) clean-up the temporary stroage and return the tunable matrix object.

int poski_DestroyMat ( poski_mat_t  A_tunable)

Destroy the tunable matrix object.

Parameters:
[in]A_tunableA tunable matrix object.
Returns:
0 if success, or an error message otherwise.
int poski_SetMatEntry ( poski_mat_t  A_tunable,
poski_int_t  row,
poski_int_t  col,
poski_value_t  val 
)

Change the value of the specified matrix element.

Parameters:
[in,out]A_tunableThe tunable matrix object.
[in]rowThe specified row of the element whose value is to be modified.
[in]colThe specified column of the element whose value is to be modified.
[in]valThe specified value to modify.
Returns:
0 if success, or an error message otherwise.
poski_value_t poski_GetMatEntry ( poski_mat_t  A_tunable,
poski_int_t  row,
poski_int_t  col 
)

Returns the value of the specified matrix element in A(row,col).

Parameters:
[in]A_tunableThe tunable matrix object.
[in]rowThe specified row of the elemenit whose value is to be returned.
[in]colThe specified column of the element whose value is to be returned.
Returns:
the value of A(row,col) if success, or an error message otherwise.
int poski_SetMatSubset ( poski_mat_t  A_tunable,
const int  numRows,
const int  numCols,
const int  rowStride,
const int  colStride,
const poski_int_t *  rows,
const poski_int_t *  cols,
const poski_value_t *  vals,
poski_subsettype_t  subsettype 
)

Set a subset of non-zero values, specified as a clique or indexed list.

This imitates the USCR_INSERT_CLIQUE Sparse BLAS standard interface. See p. 128 (Chapter 3) of the BLAS standard. A clique is typically how one defines an element for matrix assembly in the finite element method.

If insertion of any entry of the subset does not succeed, the entry is not changed.

Parameters:
A_tunable[in/out] The tunable matrix object.
numRows[in] Number of rows in the subset.
numCols[in] Number of columns in the subset.
rowStride[in] Stride between rows of vals.
colStride[in] Stride between columns of vals.
rows[in] Row indices of the subset.
cols[in] Column indices of the subset.
vals[in] Dense matrix storing the subset entries.
subsettype[in] The type of subset in {POSKI_BLOCKENTRIES, POSKI_ARRAYENTRIES}
Returns:
0 if success, or an error message otherwise.
int poski_GetMatSubset ( poski_mat_t  A_tunable,
const int  numRows,
const int  numCols,
const int  rowStride,
const int  colStride,
const poski_int_t *  rows,
const poski_int_t *  cols,
poski_value_t *  vals,
poski_subsettype_t  subsettype 
)

Get a subset of values, specified as a subset or indexed list.

Parameters:
A_tunable[in] The tunable matrix object.
numRows[in] Number of rows in the subset.
numCols[in] Number of columns in the subset.
rowStride[in] Stride between rows of vals.
colStride[in] Stride between columns of vals.
rows[in] Row indices of the subset.
cols[in] Column indices of the subset.
vals[in/out] Dense matrix storing the subset entries.
subsettype[in] The type of subset in {POSKI_BLOCKENTRIES, POSKI_ARRAYENTRIES}
Returns:
0 if success, or an error message otherwise.
int poski_report_tunable_matrix ( poski_mat_t  mat)

Report information of a tunable matrix object.

Parameters:
[in]matA tuanble matrix object.
Returns:
0 if success, or an error message otherwise.