Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
CTF_int::CSR_Matrix Class Reference

abstraction for a serialized sparse matrix stored in column-sparse-row (CSR) layout More...

#include <csr.h>

Public Member Functions

 CSR_Matrix (int64_t nnz, int nrow, int ncol, accumulatable const *sr)
 constructor allocates all_data More...
 
 CSR_Matrix (char *all_data)
 constructor given serialized CSR matrix More...
 
 CSR_Matrix ()
 
 CSR_Matrix (CSR_Matrix const &other)
 
 CSR_Matrix (COO_Matrix const &coom, int nrow, int ncol, algstrct const *sr, char *data=NULL, bool init_data=true)
 constructor given coordinate format (COO) matrix More...
 
int64_t nnz () const
 retrieves number of nonzeros out of all_data More...
 
int64_t size () const
 retrieves buffer size out of all_data More...
 
int nrow () const
 retrieves number of rows out of all_data More...
 
int ncol () const
 retrieves number of columns out of all_data More...
 
int val_size () const
 retrieves matrix entry size out of all_data More...
 
char * vals () const
 retrieves array of values out of all_data More...
 
int * IA () const
 retrieves prefix sum of number of nonzeros for each row (of size nrow()+1) out of all_data More...
 
int * JA () const
 retrieves column indices of each value in vals stored in sorted form by row More...
 
void partition (int s, char **parts_buffer, CSR_Matrix **parts)
 splits CSR matrix into s submatrices (returned) corresponding to subsets of rows, all parts allocated in one contiguous buffer (passed back in parts_buffer) More...
 
 CSR_Matrix (char *const *smnds, int s)
 constructor merges parts into one CSR matrix, assuming they are split by partition() (Above) More...
 
void print (algstrct const *sr)
 outputs matrix data to stdout, intended for debugging More...
 

Static Public Member Functions

static void csrmm (char const *A, algstrct const *sr_A, int m, int n, int k, char const *alpha, char const *B, algstrct const *sr_B, char const *beta, char *C, algstrct const *sr_C, bivar_function const *func, bool do_offload)
 computes C = beta*C + func(alpha*A*B) where A is a CSR_Matrix, while B and C are dense More...
 
static void csrmultd (char const *A, algstrct const *sr_A, int m, int n, int k, char const *alpha, char const *B, algstrct const *sr_B, char const *beta, char *C, algstrct const *sr_C, bivar_function const *func, bool do_offload)
 computes C = beta*C + func(alpha*A*B) where A and B are CSR_Matrices, while C is dense More...
 
static void csrmultcsr (char const *A, algstrct const *sr_A, int m, int n, int k, char const *alpha, char const *B, algstrct const *sr_B, char const *beta, char *&C, algstrct const *sr_C, bivar_function const *func, bool do_offload)
 computes C = beta*C + func(alpha*A*B) where A, B, and C are CSR_Matrices, while C is dense More...
 
static void compute_has_col (int const *JA, int const *IA, int const *JB, int const *IB, int i, int *has_col)
 
static char * csr_add (char *cA, char *cB, accumulatable const *adder)
 

Data Fields

char * all_data
 serialized buffer containing all info, index, and values related to matrix More...
 

Detailed Description

abstraction for a serialized sparse matrix stored in column-sparse-row (CSR) layout

Definition at line 22 of file csr.h.

Constructor & Destructor Documentation

CTF_int::CSR_Matrix::CSR_Matrix ( int64_t  nnz,
int  nrow,
int  ncol,
accumulatable const *  sr 
)
CTF_int::CSR_Matrix::CSR_Matrix ( char *  all_data)

constructor given serialized CSR matrix

Definition at line 31 of file csr.cxx.

References ALIGN, all_data, and ASSERT.

CTF_int::CSR_Matrix::CSR_Matrix ( )
inline

Definition at line 33 of file csr.h.

Referenced by CSR_Matrix(), and partition().

CTF_int::CSR_Matrix::CSR_Matrix ( CSR_Matrix const &  other)
inline
CTF_int::CSR_Matrix::CSR_Matrix ( COO_Matrix const &  coom,
int  nrow,
int  ncol,
algstrct const *  sr,
char *  data = NULL,
bool  init_data = true 
)
CTF_int::CSR_Matrix::CSR_Matrix ( char *const *  smnds,
int  s 
)

constructor merges parts into one CSR matrix, assuming they are split by partition() (Above)

Definition at line 259 of file csr.cxx.

References all_data, CTF_int::alloc(), CSR_Matrix(), CTF_int::get_csr_size(), IA(), JA(), ncol(), nnz(), nrow(), val_size(), and vals().

Member Function Documentation

void CTF_int::CSR_Matrix::compute_has_col ( int const *  JA,
int const *  IA,
int const *  JB,
int const *  IB,
int  i,
int *  has_col 
)
static
void CTF_int::CSR_Matrix::csrmm ( char const *  A,
algstrct const *  sr_A,
int  m,
int  n,
int  k,
char const *  alpha,
char const *  B,
algstrct const *  sr_B,
char const *  beta,
char *  C,
algstrct const *  sr_C,
bivar_function const *  func,
bool  do_offload 
)
static
void CTF_int::CSR_Matrix::csrmultcsr ( char const *  A,
algstrct const *  sr_A,
int  m,
int  n,
int  k,
char const *  alpha,
char const *  B,
algstrct const *  sr_B,
char const *  beta,
char *&  C,
algstrct const *  sr_C,
bivar_function const *  func,
bool  do_offload 
)
static

computes C = beta*C + func(alpha*A*B) where A, B, and C are CSR_Matrices, while C is dense

Definition at line 188 of file csr.cxx.

References ASSERT, CTF_int::bivar_function::ccsrmultcsr(), CTF_int::algstrct::csrmultcsr(), CTF_int::accumulatable::el_size, CTF_int::bivar_function::has_off_gemm, IA(), CTF_int::algstrct::isequal(), JA(), CTF_int::algstrct::mulid(), nnz(), and vals().

Referenced by CSR_Matrix(), and CTF_int::seq_tsr_spctr::run().

void CTF_int::CSR_Matrix::csrmultd ( char const *  A,
algstrct const *  sr_A,
int  m,
int  n,
int  k,
char const *  alpha,
char const *  B,
algstrct const *  sr_B,
char const *  beta,
char *  C,
algstrct const *  sr_C,
bivar_function const *  func,
bool  do_offload 
)
static

computes C = beta*C + func(alpha*A*B) where A and B are CSR_Matrices, while C is dense

Definition at line 158 of file csr.cxx.

References ASSERT, CTF_int::bivar_function::ccsrmultd(), CTF_int::algstrct::csrmultd(), CTF_int::accumulatable::el_size, CTF_int::bivar_function::has_off_gemm, IA(), CTF_int::algstrct::isequal(), JA(), CTF_int::algstrct::mulid(), nnz(), and vals().

Referenced by CSR_Matrix(), and CTF_int::seq_tsr_spctr::run().

int CTF_int::CSR_Matrix::ncol ( ) const

retrieves number of columns out of all_data

Definition at line 97 of file csr.cxx.

References all_data.

Referenced by CTF::Monoid< dtype, is_ord >::csr_add(), csr_add(), CSR_Matrix(), partition(), and print().

int CTF_int::CSR_Matrix::nrow ( ) const

retrieves number of rows out of all_data

Definition at line 93 of file csr.cxx.

References all_data.

Referenced by CTF_int::COO_Matrix::COO_Matrix(), CTF::Monoid< dtype, is_ord >::csr_add(), csr_add(), CSR_Matrix(), JA(), partition(), print(), and size().

void CTF_int::CSR_Matrix::partition ( int  s,
char **  parts_buffer,
CSR_Matrix **  parts 
)

splits CSR matrix into s submatrices (returned) corresponding to subsets of rows, all parts allocated in one contiguous buffer (passed back in parts_buffer)

Definition at line 219 of file csr.cxx.

References CTF_int::alloc_ptr(), CSR_Matrix(), CTF_int::get_csr_size(), IA(), JA(), ncol(), nrow(), val_size(), and vals().

Referenced by CSR_Matrix(), and CTF_int::algstrct::csr_reduce().

void CTF_int::CSR_Matrix::print ( algstrct const *  sr)

outputs matrix data to stdout, intended for debugging

Parameters
[in]sralgebraic structure allowing print

Definition at line 299 of file csr.cxx.

References IA(), JA(), ncol(), nnz(), nrow(), CTF_int::algstrct::print(), val_size(), and vals().

Referenced by CSR_Matrix().

int64_t CTF_int::CSR_Matrix::size ( ) const

retrieves buffer size out of all_data

Definition at line 89 of file csr.cxx.

References CTF_int::get_csr_size(), nnz(), nrow(), and val_size().

Referenced by CSR_Matrix(), and CTF_int::algstrct::csr_reduce().

int CTF_int::CSR_Matrix::val_size ( ) const

retrieves matrix entry size out of all_data

Definition at line 84 of file csr.cxx.

References all_data.

Referenced by CTF_int::COO_Matrix::COO_Matrix(), csr_add(), CSR_Matrix(), IA(), JA(), partition(), print(), and size().

Field Documentation


The documentation for this class was generated from the following files: