Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
CTF::Ring< dtype, is_ord > Class Template Reference

Ring class defined by a datatype and addition and multiplicaton functions addition must have an identity, inverse, and be associative, does not need to be commutative multiplications must have an identity and be distributive. More...

#include <ring.h>

Inheritance diagram for CTF::Ring< dtype, is_ord >:
Collaboration diagram for CTF::Ring< dtype, is_ord >:

Public Member Functions

 Ring (Ring const &other)
 
 Ring ()
 default constructor valid for only certain types: bool, int, unsigned int, int64_t, uint64_t, float, double, std::complex<float>, std::complex<double> More...
 
virtual CTF_int::algstrctclone () const
 ''copy constructor'' More...
 
 Ring (dtype addid_, dtype(*fadd_)(dtype a, dtype b), MPI_Op addmop_, dtype mulid_, dtype(*fmul_)(dtype a, dtype b), void(*gemm_)(char, char, int, int, int, dtype, dtype const *, dtype const *, dtype, dtype *)=NULL, void(*axpy_)(int, dtype, dtype const *, int, dtype *, int)=NULL, void(*scal_)(int, dtype, dtype *, int)=NULL)
 constructor for algstrct equipped with * and + More...
 
void safeaddinv (char const *a, char *&b) const
 b = -a, with checks for NULL and alloc as necessary More...
 
void addinv (char const *a, char *b) const
 b = -a More...
 
- Public Member Functions inherited from CTF::Semiring< dtype, is_ord >
 Semiring (Semiring const &other)
 
 Semiring (dtype addid_, dtype(*fadd_)(dtype a, dtype b), MPI_Op addmop_, dtype mulid_, dtype(*fmul_)(dtype a, dtype b), void(*gemm_)(char, char, int, int, int, dtype, dtype const *, dtype const *, dtype, dtype *)=NULL, void(*axpy_)(int, dtype, dtype const *, int, dtype *, int)=NULL, void(*scal_)(int, dtype, dtype *, int)=NULL, void(*coomm_)(int, int, int, dtype, dtype const *, int const *, int const *, int, dtype const *, dtype, dtype *)=NULL, void(*fgemm_batch_)(char, char, int, int, int, int, dtype, dtype const *, dtype const *, dtype, dtype *)=NULL)
 constructor for algstrct equipped with * and + More...
 
 Semiring ()
 constructor for algstrct equipped with + only More...
 
void mul (char const *a, char const *b, char *c) const
 c = a*b More...
 
void safemul (char const *a, char const *b, char *&c) const
 c = a*b, with NULL treated as mulid More...
 
char const * mulid () const
 identity element for multiplication i.e. 1 More...
 
bool has_mul () const
 
void scal (int n, char const *alpha, char *X, int incX) const
 X["i"]=alpha*X["i"];. More...
 
void axpy (int n, char const *alpha, char const *X, int incX, char *Y, int incY) const
 Y["i"]+=alpha*X["i"];. More...
 
void gemm (char tA, char tB, int m, int n, int k, char const *alpha, char const *A, char const *B, char const *beta, char *C) const
 beta*C["ij"]=alpha*A^tA["ik"]*B^tB["kj"]; More...
 
void gemm_batch (char tA, char tB, int l, int m, int n, int k, char const *alpha, char const *A, char const *B, char const *beta, char *C) const
 beta*C["ijl"]=alpha*A^tA["ikl"]*B^tB["kjl"]; More...
 
void offload_gemm (char tA, char tB, int m, int n, int k, char const *alpha, char const *A, char const *B, char const *beta, char *C) const
 
bool is_offloadable () const
 
void coomm (int m, int n, int k, char const *alpha, char const *A, int const *rows_A, int const *cols_A, int64_t nnz_A, char const *B, char const *beta, char *C, CTF_int::bivar_function const *func) const
 sparse version of gemm using coordinate format for A More...
 
void default_csrmm (int m, int n, int k, dtype alpha, dtype const *A, int const *JA, int const *IA, int nnz_A, dtype const *B, dtype beta, dtype *C) const
 
void csrmm (int m, int n, int k, char const *alpha, char const *A, int const *JA, int const *IA, int64_t nnz_A, char const *B, char const *beta, char *C, CTF_int::bivar_function const *func) const
 sparse version of gemm using CSR format for A More...
 
void default_csrmultd (int m, int n, int k, dtype alpha, dtype const *A, int const *JA, int const *IA, int nnz_A, dtype const *B, int const *JB, int const *IB, int nnz_B, dtype beta, dtype *C) const
 
void gen_csrmultcsr (int m, int n, int k, dtype alpha, dtype const *A, int const *JA, int const *IA, int nnz_A, dtype const *B, int const *JB, int const *IB, int nnz_B, dtype beta, char *&C_CSR) const
 
void default_csrmultcsr (int m, int n, int k, dtype alpha, dtype const *A, int const *JA, int const *IA, int nnz_A, dtype const *B, int const *JB, int const *IB, int nnz_B, dtype beta, char *&C_CSR) const
 
void csrmultd (int m, int n, int k, char const *alpha, char const *A, int const *JA, int const *IA, int64_t nnz_A, char const *B, int const *JB, int const *IB, int64_t nnz_B, char const *beta, char *C) const
 sparse version of gemm using CSR format for A and B More...
 
void csrmultcsr (int m, int n, int k, char const *alpha, char const *A, int const *JA, int const *IA, int64_t nnz_A, char const *B, int const *JB, int const *IB, int64_t nnz_B, char const *beta, char *&C_CSR) const
 
template<>
void default_csrmm (int m, int n, int k, float alpha, float const *A, int const *JA, int const *IA, int nnz_A, float const *B, float beta, float *C) const
 
template<>
void default_csrmm (int m, int n, int k, double alpha, double const *A, int const *JA, int const *IA, int nnz_A, double const *B, double beta, double *C) const
 
template<>
void default_csrmm (int m, int n, int k, std::complex< float > alpha, std::complex< float > const *A, int const *JA, int const *IA, int nnz_A, std::complex< float > const *B, std::complex< float > beta, std::complex< float > *C) const
 
template<>
void default_csrmm (int m, int n, int k, std::complex< double > alpha, std::complex< double > const *A, int const *JA, int const *IA, int nnz_A, std::complex< double > const *B, std::complex< double > beta, std::complex< double > *C) const
 
template<>
bool is_offloadable () const
 
template<>
bool is_offloadable () const
 
template<>
bool is_offloadable () const
 
template<>
bool is_offloadable () const
 
template<>
void offload_gemm (char tA, char tB, int m, int n, int k, char const *alpha, char const *A, char const *B, char const *beta, char *C) const
 
template<>
void offload_gemm (char tA, char tB, int m, int n, int k, char const *alpha, char const *A, char const *B, char const *beta, char *C) const
 
template<>
void offload_gemm (char tA, char tB, int m, int n, int k, char const *alpha, char const *A, char const *B, char const *beta, char *C) const
 
template<>
void offload_gemm (char tA, char tB, int m, int n, int k, char const *alpha, char const *A, char const *B, char const *beta, char *C) const
 
template<>
void default_csrmm (int, int, int, float, float const *, int const *, int const *, int, float const *, float, float *) const
 
template<>
void default_csrmm (int, int, int, double, double const *, int const *, int const *, int, double const *, double, double *) const
 
template<>
void default_csrmm (int, int, int, std::complex< float >, std::complex< float > const *, int const *, int const *, int, std::complex< float > const *, std::complex< float >, std::complex< float > *) const
 
template<>
void default_csrmm (int, int, int, std::complex< double >, std::complex< double > const *, int const *, int const *, int, std::complex< double > const *, std::complex< double >, std::complex< double > *) const
 
template<>
void default_csrmultd (int, int, int, float, float const *, int const *, int const *, int, float const *, int const *, int const *, int, float, float *) const
 
template<>
void default_csrmultd (int, int, int, double, double const *, int const *, int const *, int, double const *, int const *, int const *, int, double, double *) const
 
template<>
void default_csrmultd (int, int, int, std::complex< float >, std::complex< float > const *, int const *, int const *, int, std::complex< float > const *, int const *, int const *, int, std::complex< float >, std::complex< float > *) const
 
template<>
void default_csrmultd (int, int, int, std::complex< double >, std::complex< double > const *, int const *, int const *, int, std::complex< double > const *, int const *, int const *, int, std::complex< double >, std::complex< double > *) const
 
template<>
void default_csrmultcsr (int, int, int, float, float const *, int const *, int const *, int, float const *, int const *, int const *, int, float, char *&) const
 
template<>
void default_csrmultcsr (int, int, int, double, double const *, int const *, int const *, int, double const *, int const *, int const *, int, double, char *&) const
 
template<>
void default_csrmultcsr (int, int, int, std::complex< float >, std::complex< float > const *, int const *, int const *, int, std::complex< float > const *, int const *, int const *, int, std::complex< float >, char *&) const
 
template<>
void default_csrmultcsr (int, int, int, std::complex< double >, std::complex< double > const *, int const *, int const *, int, std::complex< double > const *, int const *, int const *, int, std::complex< double >, char *&) const
 
template<>
bool is_offloadable () const
 
template<>
bool is_offloadable () const
 
template<>
bool is_offloadable () const
 
template<>
bool is_offloadable () const
 
template<>
void offload_gemm (char, char, int, int, int, char const *, char const *, char const *, char const *, char *) const
 
template<>
void offload_gemm (char, char, int, int, int, char const *, char const *, char const *, char const *, char *) const
 
template<>
void offload_gemm (char, char, int, int, int, char const *, char const *, char const *, char const *, char *) const
 
template<>
void offload_gemm (char, char, int, int, int, char const *, char const *, char const *, char const *, char *) const
 
- Public Member Functions inherited from CTF::Monoid< dtype, is_ord >
 Monoid (Monoid const &other)
 
 Monoid ()
 
 Monoid (dtype taddid_)
 
 Monoid (dtype taddid_, dtype(*fadd_)(dtype a, dtype b), MPI_Op addmop_)
 
void add (char const *a, char const *b, char *c) const
 c = a+b More...
 
char const * addid () const
 MPI datatype for pairs. More...
 
MPI_Op addmop () const
 MPI addition operation for reductions. More...
 
void init (int64_t n, char *arr) const
 initialize n objects to zero More...
 
char * csr_add (char *cA, char *cB) const
 adds CSR matrices A (stored in cA) and B (stored in cB) to create matric C (pointer to all_data returned), C data allocated internally More...
 
template<>
char * csr_add (char *cA, char *cB) const
 adds CSR matrices A (stored in cA) and B (stored in cB) to create matric C (pointer to all_data returned), C data allocated internally More...
 
template<>
char * csr_add (char *, char *) const
 adds CSR matrices A (stored in cA) and B (stored in cB) to create matric C (pointer to all_data returned), C data allocated internally More...
 
- Public Member Functions inherited from CTF::Set< dtype, is_ord >
 ~Set ()
 
 Set (Set const &other)
 
int pair_size () const
 gets pair size el_size plus the key size More...
 
int64_t get_key (char const *a) const
 gets key from pair More...
 
char * get_value (char *a) const
 gets pair to value from pair More...
 
char const * get_const_value (char const *a) const
 
bool is_ordered () const
 
 Set ()
 
void set_abs_to_default ()
 
MPI_Datatype mdtype () const
 MPI datatype. More...
 
void min (char const *a, char const *b, char *c) const
 c = min(a,b) More...
 
void max (char const *a, char const *b, char *c) const
 c = max(a,b) More...
 
void min (char *c) const
 c = minimum possible value More...
 
void max (char *c) const
 c = maximum possible value More...
 
void cast_double (double d, char *c) const
 c = &d More...
 
void cast_int (int64_t i, char *c) const
 c = &i More...
 
double cast_to_double (char const *c) const
 return (double)*c More...
 
int64_t cast_to_int (char const *c) const
 return (int64_t)*c More...
 
void print (char const *a, FILE *fp=stdout) const
 prints the value More...
 
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
void coo_to_csr (int64_t nz, int nrow, char *csr_vs, int *csr_ja, int *csr_ia, char const *coo_vs, int const *coo_rs, int const *coo_cs) const
 converts coordinate sparse matrix layout to CSR layout More...
 
void csr_to_coo (int64_t nz, int nrow, char const *csr_vs, int const *csr_ja, int const *csr_ia, char *coo_vs, int *coo_rs, int *coo_cs) const
 converts CSR sparse matrix layout to coordinate (COO) layout More...
 
char * pair_alloc (int64_t n) const
 allocate space for n (int64_t,dtype) pairs, necessary for object types More...
 
char * alloc (int64_t n) const
 allocate space for n items, necessary for object types More...
 
void dealloc (char *ptr) const
 deallocate given pointer containing contiguous array of values More...
 
void pair_dealloc (char *ptr) const
 deallocate given pointer containing contiguous array of pairs More...
 
void sort (int64_t n, char *pairs) const
 sorts n sets of pairs using std::sort More...
 
void copy (char *a, char const *b) const
 copies element b to element a More...
 
void copy (char *a, char const *b, int64_t n) const
 copies n elements from array b to array a More...
 
void copy_pair (char *a, char const *b) const
 copies pair b to element a More...
 
void copy_pairs (char *a, char const *b, int64_t n) const
 copies n pair from array b to array a More...
 
void set (char *a, char const *b, int64_t n) const
 sets n elements of array a to value b More...
 
void set_pair (char *a, int64_t key, char const *b) const
 sets 1 elements of pair a to value and key More...
 
void set_pairs (char *a, char const *b, int64_t n) const
 sets n elements of array of pairs a to value b More...
 
void copy (int64_t n, char const *a, int inc_a, char *b, int inc_b) const
 copies n elements TO array b with increment inc_a FROM array a with increment inc_b More...
 
void copy (int64_t m, int64_t n, char const *a, int64_t lda_a, char *b, int64_t lda_b) const
 copies m-by-n submatrix from a with lda_a to b with lda_b More...
 
void init (int64_t n, char *arr) const
 initialize n objects to zero More...
 
virtual void init_shell (int64_t n, char *arr) const
 initialize n objects to zero More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *p, FILE *fp) const
 prints the value More...
 
template<>
void copy (int64_t nn, char const *a, int inc_a, char *b, int inc_b) const
 copies n elements TO array b with increment inc_a FROM array a with increment inc_b More...
 
template<>
void copy (int64_t nn, char const *a, int inc_a, char *b, int inc_b) const
 copies n elements TO array b with increment inc_a FROM array a with increment inc_b More...
 
template<>
void copy (int64_t nn, char const *a, int inc_a, char *b, int inc_b) const
 copies n elements TO array b with increment inc_a FROM array a with increment inc_b More...
 
template<>
void copy (int64_t nn, char const *a, int inc_a, char *b, int inc_b) const
 copies n elements TO array b with increment inc_a FROM array a with increment inc_b More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_double (double d, char *c) const
 c = &d More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
void cast_int (int64_t d, char *c) const
 c = &i More...
 
template<>
double cast_to_double (char const *c) const
 return (double)*c More...
 
template<>
double cast_to_double (char const *c) const
 return (double)*c More...
 
template<>
double cast_to_double (char const *c) const
 return (double)*c More...
 
template<>
double cast_to_double (char const *c) const
 return (double)*c More...
 
template<>
double cast_to_double (char const *c) const
 return (double)*c More...
 
template<>
int64_t cast_to_int (char const *c) const
 return (int64_t)*c More...
 
template<>
int64_t cast_to_int (char const *c) const
 return (int64_t)*c More...
 
template<>
int64_t cast_to_int (char const *c) const
 return (int64_t)*c More...
 
template<>
int64_t cast_to_int (char const *c) const
 return (int64_t)*c More...
 
template<>
int64_t cast_to_int (char const *c) const
 return (int64_t)*c More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
void print (char const *a, FILE *fp) const
 prints the value More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
template<>
bool isequal (char const *a, char const *b) const
 returns true if algstrct elements a and b are equal More...
 
- Public Member Functions inherited from CTF_int::algstrct
 algstrct ()
 default constructor More...
 
 algstrct (int el_size)
 constructor creates algstrct with all parameters More...
 
virtual ~algstrct ()=0
 destructor More...
 
virtual void accum (char const *a, char *b) const
 b+=a More...
 
virtual char * csr_reduce (char *cA, int root, MPI_Comm cm) const
 reduces CSR matrices stored in cA on each processor in cm and returns result on processor root More...
 
double estimate_csr_red_time (int64_t msg_sz, CommData const *cdt) const
 
void acc (char *b, char const *beta, char const *a, char const *alpha) const
 compute b=beta*b + alpha*a More...
 
void accmul (char *c, char const *a, char const *b, char const *alpha) const
 compute c=c + alpha*a*b More...
 
void safecopy (char *&a, char const *b) const
 copies element b to element a, , with checks for NULL and alloc as necessary More...
 
virtual void copy (int64_t m, int64_t n, char const *a, int64_t lda_a, char const *alpha, char *b, int64_t lda_b, char const *beta) const
 copies m-by-n submatrix from a with lda_a and scaling alpha to b with lda_b and scaling by 1 More...
 

Additional Inherited Members

- Data Fields inherited from CTF::Semiring< dtype, is_ord >
bool is_def
 
dtype tmulid
 
void(* fscal )(int, dtype, dtype *, int)
 
void(* faxpy )(int, dtype, dtype const *, int, dtype *, int)
 
dtype(* fmul )(dtype a, dtype b)
 
void(* fgemm )(char, char, int, int, int, dtype, dtype const *, dtype const *, dtype, dtype *)
 
void(* fcoomm )(int, int, int, dtype, dtype const *, int const *, int const *, int, dtype const *, dtype, dtype *)
 
void(* fgemm_batch )(char, char, int, int, int, int, dtype, dtype const *, dtype const *, dtype, dtype *)
 
- Data Fields inherited from CTF::Monoid< dtype, is_ord >
dtype taddid
 
dtype(* fadd )(dtype a, dtype b)
 
MPI_Op taddmop
 
- Data Fields inherited from CTF::Set< dtype, is_ord >
int pair_sz
 
bool is_custom_mdtype
 
MPI_Datatype tmdtype
 
- Data Fields inherited from CTF_int::algstrct
bool has_coo_ker
 whether there was a custom COO CSRMM kernel provided for this algebraic structure More...
 
void(* abs )(char const *a, char *b)
 b = max(a,addinv(a)) More...
 
- Data Fields inherited from CTF_int::accumulatable
int el_size
 size of each element of algstrct in bytes More...
 

Detailed Description

template<typename dtype = double, bool is_ord = CTF_int::get_default_is_ord<dtype>()>
class CTF::Ring< dtype, is_ord >

Ring class defined by a datatype and addition and multiplicaton functions addition must have an identity, inverse, and be associative, does not need to be commutative multiplications must have an identity and be distributive.

Definition at line 18 of file ring.h.

Constructor & Destructor Documentation

template<typename dtype = double, bool is_ord = CTF_int::get_default_is_ord<dtype>()>
CTF::Ring< dtype, is_ord >::Ring ( Ring< dtype, is_ord > const &  other)
inline

Definition at line 20 of file ring.h.

References CTF_int::algstrct::abs.

template<typename dtype = double, bool is_ord = CTF_int::get_default_is_ord<dtype>()>
CTF::Ring< dtype, is_ord >::Ring ( )
inline

default constructor valid for only certain types: bool, int, unsigned int, int64_t, uint64_t, float, double, std::complex<float>, std::complex<double>

Definition at line 28 of file ring.h.

References CTF_int::algstrct::abs.

template<typename dtype = double, bool is_ord = CTF_int::get_default_is_ord<dtype>()>
CTF::Ring< dtype, is_ord >::Ring ( dtype  addid_,
dtype(*)(dtype a, dtype b)  fadd_,
MPI_Op  addmop_,
dtype  mulid_,
dtype(*)(dtype a, dtype b)  fmul_,
void(*)(char, char, int, int, int, dtype, dtype const *, dtype const *, dtype, dtype *)  gemm_ = NULL,
void(*)(int, dtype, dtype const *, int, dtype *, int)  axpy_ = NULL,
void(*)(int, dtype, dtype *, int)  scal_ = NULL 
)
inline

constructor for algstrct equipped with * and +

Parameters
[in]addid_additive identity
[in]fadd_binary addition function
[in]addmop_MPI_Op operation for addition
[in]mulid_multiplicative identity
[in]fmul_binary multiplication function
[in]gemm_block matrix multiplication function
[in]axpy_vector sum function
[in]scal_vector scale function

Definition at line 47 of file ring.h.

References CTF_int::algstrct::abs.

Member Function Documentation

template<typename dtype = double, bool is_ord = CTF_int::get_default_is_ord<dtype>()>
void CTF::Ring< dtype, is_ord >::addinv ( char const *  a,
char *  b 
) const
inlinevirtual

b = -a

Reimplemented from CTF_int::algstrct.

Definition at line 70 of file ring.h.

References ctf.core::dtype.

template<typename dtype = double, bool is_ord = CTF_int::get_default_is_ord<dtype>()>
virtual CTF_int::algstrct* CTF::Ring< dtype, is_ord >::clone ( ) const
inlinevirtual

''copy constructor''

Reimplemented from CTF::Semiring< dtype, is_ord >.

Definition at line 32 of file ring.h.

template<typename dtype = double, bool is_ord = CTF_int::get_default_is_ord<dtype>()>
void CTF::Ring< dtype, is_ord >::safeaddinv ( char const *  a,
char *&  b 
) const
inlinevirtual

b = -a, with checks for NULL and alloc as necessary

Reimplemented from CTF_int::algstrct.

Definition at line 60 of file ring.h.

References ctf.core::dtype, CTF_int::accumulatable::el_size, and CTF::Semiring< dtype, is_ord >::tmulid.


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