Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
csr.h
Go to the documentation of this file.
1 #ifndef __CSR_H__
2 #define __CSR_H__
3 
4 #include "../tensor/algstrct.h"
5 #include "coo.h"
6 
7 namespace CTF_int {
8 
9  class bivar_function;
10 
17  int64_t get_csr_size(int64_t nnz, int nrow, int val_size);
18 
22  class CSR_Matrix{
23  public:
25  char * all_data;
26 
28  CSR_Matrix(int64_t nnz, int nrow, int ncol, accumulatable const * sr);
29 
31  CSR_Matrix(char * all_data);
32 
33  CSR_Matrix(){ all_data=NULL; }
34 
35  CSR_Matrix(CSR_Matrix const & other){ all_data=other.all_data; }
36 
38  CSR_Matrix(COO_Matrix const & coom, int nrow, int ncol, algstrct const * sr, char * data=NULL, bool init_data=true);
39 
41  int64_t nnz() const;
42 
44  int64_t size() const;
45 
47  int nrow() const;
48 
50  int ncol() const;
51 
53  int val_size() const;
54 
56  char * vals() const;
57 
59  int * IA() const;
60 
62  int * JA() const;
63 
67  void partition(int s, char ** parts_buffer, CSR_Matrix ** parts);
68 
72  CSR_Matrix(char * const * smnds, int s);
73 
78  void print(algstrct const * sr);
79 
83  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);
84 
88  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);
89 
93  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);
94 
95  static void compute_has_col(
96 
97  int const * JA,
98  int const * IA,
99  int const * JB,
100  int const * IB,
101  int i,
102  int * has_col);
103 
104  static char * csr_add(char * cA, char * cB, accumulatable const * adder);
105  };
106 }
107 
108 #endif
int * IA() const
retrieves prefix sum of number of nonzeros for each row (of size nrow()+1) out of all_data ...
Definition: csr.cxx:107
static char * csr_add(char *cA, char *cB, accumulatable const *adder)
Definition: csr.cxx:332
int bivar_function(int n, World &dw)
untyped internal class for triply-typed bivariate function
Definition: ctr_comm.h:16
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 ...
Definition: csr.cxx:188
static void compute_has_col(int const *JA, int const *IA, int const *JB, int const *IB, int i, int *has_col)
Definition: csr.cxx:316
int ncol() const
retrieves number of columns out of all_data
Definition: csr.cxx:97
void print(algstrct const *sr)
outputs matrix data to stdout, intended for debugging
Definition: csr.cxx:299
int * JA() const
retrieves column indices of each value in vals stored in sorted form by row
Definition: csr.cxx:119
int64_t nnz() const
retrieves number of nonzeros out of all_data
Definition: csr.cxx:80
serialized matrix in coordinate format, meaning three arrays of dimension nnz are stored...
Definition: coo.h:14
abstract class that knows how to add
Definition: algstrct.h:13
abstraction for a serialized sparse matrix stored in column-sparse-row (CSR) layout ...
Definition: csr.h:22
int nrow() const
retrieves number of rows out of all_data
Definition: csr.cxx:93
char * all_data
serialized buffer containing all info, index, and values related to matrix
Definition: csr.h:25
char * vals() const
retrieves array of values out of all_data
Definition: csr.cxx:101
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 ...
Definition: csr.cxx:134
algstrct (algebraic structure) defines the elementwise operations computed in each tensor contraction...
Definition: algstrct.h:34
CSR_Matrix(CSR_Matrix const &other)
Definition: csr.h:35
int64_t get_csr_size(int64_t nnz, int nrow_, int val_size)
computes the size of a serialized CSR matrix
Definition: csr.cxx:8
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...
Definition: csr.cxx:219
int val_size() const
retrieves matrix entry size out of all_data
Definition: csr.cxx:84
int64_t size() const
retrieves buffer size out of all_data
Definition: csr.cxx:89
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 ...
Definition: csr.cxx:158