COMBINATORIAL_BLAS  1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Friends
FullyDistSpVec< IT, NT > Class Template Reference

#include <FullyDistSpVec.h>

Inheritance diagram for FullyDistSpVec< IT, NT >:
FullyDist< IT, NT, CombBLAS::disable_if< CombBLAS::is_boolean< NT >::value, NT >::type >

List of all members.

Classes

class  ScalarReadSaveHandler

Public Member Functions

 FullyDistSpVec ()
 FullyDistSpVec (IT glen)
 FullyDistSpVec (shared_ptr< CommGrid > grid)
 FullyDistSpVec (shared_ptr< CommGrid > grid, IT glen)
 FullyDistSpVec (const FullyDistVec< IT, NT > &rhs)
void stealFrom (FullyDistSpVec< IT, NT > &victim)
FullyDistSpVec< IT, NT > & operator= (const FullyDistSpVec< IT, NT > &rhs)
FullyDistSpVec< IT, NT > & operator= (const FullyDistVec< IT, NT > &rhs)
FullyDistSpVec< IT, NT > & operator+= (const FullyDistSpVec< IT, NT > &rhs)
FullyDistSpVec< IT, NT > & operator-= (const FullyDistSpVec< IT, NT > &rhs)
template<class HANDLER >
ifstream & ReadDistribute (ifstream &infile, int master, HANDLER handler)
 Called on an existing object.
ifstream & ReadDistribute (ifstream &infile, int master)
template<class HANDLER >
void SaveGathered (ofstream &outfile, int master, HANDLER handler, bool printProcSplits=false)
void SaveGathered (ofstream &outfile, int master)
template<typename NNT >
 operator FullyDistSpVec< IT, NNT > () const
 < Type conversion operator
bool operator== (const FullyDistSpVec< IT, NT > &rhs) const
void PrintInfo (string vecname) const
void iota (IT globalsize, NT first)
FullyDistVec< IT, NT > operator() (const FullyDistVec< IT, IT > &ri) const
 SpRef (expects ri to be 0-based)
void SetElement (IT indx, NT numx)
 Indexing is performed 0-based.
void DelElement (IT indx)
NT operator[] (IT indx)
bool WasFound () const
FullyDistSpVec< IT, IT > sort ()
IT getlocnnz () const
IT getnnz () const
void setNumToInd ()
template<typename _Predicate >
IT Count (_Predicate pred) const
 Return the number of elements for which pred is true.
template<typename _UnaryOperation >
void Apply (_UnaryOperation __unary_op)
template<typename _BinaryOperation >
void ApplyInd (_BinaryOperation __binary_op)
template<typename _BinaryOperation >
NT Reduce (_BinaryOperation __binary_op, NT init)
template<typename OUT , typename _BinaryOperation , typename _UnaryOperation >
OUT Reduce (_BinaryOperation __binary_op, OUT default_val, _UnaryOperation __unary_op)
void DebugPrint ()
shared_ptr< CommGridgetcommgrid () const

Friends

class FullyDistSpVec
class FullyDistVec
class SpParMat
class SparseVectorLocalIterator
template<typename SR , typename IU , typename NUM , typename NUV , typename UDER >
FullyDistSpVec< IU, typename
promote_trait< NUM, NUV >
::T_promote > 
SpMV (const SpParMat< IU, NUM, UDER > &A, const FullyDistSpVec< IU, NUV > &x)
template<typename SR , typename IU , typename NUM , typename UDER >
FullyDistSpVec< IU, typename
promote_trait< NUM, IU >
::T_promote > 
SpMV (const SpParMat< IU, NUM, UDER > &A, const FullyDistSpVec< IU, IU > &x, bool indexisvalue)
template<typename VT , typename IU , typename UDER >
FullyDistSpVec< IU, VT > SpMV (const SpParMat< IU, bool, UDER > &A, const FullyDistSpVec< IU, VT > &x, OptBuf< int32_t, VT > &optbuf)
template<typename SR , typename IVT , typename OVT , typename IU , typename NUM , typename UDER >
void SpMV (const SpParMat< IU, NUM, UDER > &A, const FullyDistSpVec< IU, IVT > &x, FullyDistSpVec< IU, OVT > &y, bool indexisvalue, OptBuf< int32_t, OVT > &optbuf)
template<typename IU , typename NU1 , typename NU2 >
FullyDistSpVec< IU, typename
promote_trait< NU1, NU2 >
::T_promote > 
EWiseMult (const FullyDistSpVec< IU, NU1 > &V, const FullyDistVec< IU, NU2 > &W, bool exclude, NU2 zero)
template<typename RET , typename IU , typename NU1 , typename NU2 , typename _BinaryOperation , typename _BinaryPredicate >
FullyDistSpVec< IU, RET > EWiseApply (const FullyDistSpVec< IU, NU1 > &V, const FullyDistVec< IU, NU2 > &W, _BinaryOperation _binary_op, _BinaryPredicate _doOp, bool allowVNulls, NU1 Vzero, const bool useExtendedBinOp)
template<typename RET , typename IU , typename NU1 , typename NU2 , typename _BinaryOperation , typename _BinaryPredicate >
FullyDistSpVec< IU, RET > EWiseApply (const FullyDistSpVec< IU, NU1 > &V, const FullyDistSpVec< IU, NU2 > &W, _BinaryOperation _binary_op, _BinaryPredicate _doOp, bool allowVNulls, bool allowWNulls, NU1 Vzero, NU2 Wzero, const bool allowIntersect, const bool useExtendedBinOp)
template<typename IU >
void RandPerm (FullyDistSpVec< IU, IU > &V)
template<typename IU >
void RenameVertices (DistEdgeList< IU > &DEL)
template<typename SR , typename IU , typename OVT >
void MergeContributions (FullyDistSpVec< IU, OVT > &y, int *&recvcnt, int *&rdispls, int32_t *&recvindbuf, OVT *&recvnumbuf, int rowneighs)
 Helper functions for sparse matrix X sparse vector.
template<typename IU , typename VT >
void MergeContributions (FullyDistSpVec< IU, VT > &y, int *&recvcnt, int *&rdispls, int32_t *&recvindbuf, VT *&recvnumbuf, int rowneighs)
template<typename IU , typename NV >
void TransposeVector (MPI_Comm &World, const FullyDistSpVec< IU, NV > &x, int32_t &trxlocnz, IU &lenuntil, int32_t *&trxinds, NV *&trxnums, bool indexisvalue)

Detailed Description

template<class IT, class NT>
class FullyDistSpVec< IT, NT >

A sparse vector of length n (with nnz <= n of them being nonzeros) is distributed to "all the processors" in a way that "respects ordering" of the nonzero indices Example: x = [5,1,6,2,9] for nnz(x)=5 and length(x)=12 we use 4 processors P_00, P_01, P_10, P_11 Then P_00 owns 1,2, P_01 ow`ns 5, and so on. In the case of A(v,w) type sparse matrix indexing, this doesn't matter because n = nnz After all, A(v,w) will have dimensions length(v) x length (w) v and w will be of numerical type (NT) "int" and their indices (IT) will be consecutive integers It is possibly that nonzero counts are distributed unevenly Example: x=[1,2,3,4,5] and length(x) = 20, then P_00 would own all the nonzeros and the rest will hold empry vectors Just like in SpParMat case, indices are local to processors (they belong to range [0,...,length-1] on each processor)

Warning:
Always create vectors with the right length, setting elements won't increase its length (similar to operator[] on std::vector)

Definition at line 70 of file FullyDistSpVec.h.


Constructor & Destructor Documentation

template<class IT, class NT>
FullyDistSpVec< IT, NT >::FullyDistSpVec ( )
template<class IT , class NT >
FullyDistSpVec< IT, NT >::FullyDistSpVec ( IT  glen)

Definition at line 51 of file FullyDistSpVec.cpp.

template<class IT , class NT >
FullyDistSpVec< IT, NT >::FullyDistSpVec ( shared_ptr< CommGrid grid)

Definition at line 36 of file FullyDistSpVec.cpp.

template<class IT , class NT >
FullyDistSpVec< IT, NT >::FullyDistSpVec ( shared_ptr< CommGrid grid,
IT  glen 
)

Definition at line 41 of file FullyDistSpVec.cpp.

template<class IT , class NT >
FullyDistSpVec< IT, NT >::FullyDistSpVec ( const FullyDistVec< IT, NT > &  rhs)

Definition at line 69 of file FullyDistSpVec.cpp.


Member Function Documentation

template<class IT, class NT>
template<typename _UnaryOperation >
void FullyDistSpVec< IT, NT >::Apply ( _UnaryOperation  __unary_op)
inline

Definition at line 178 of file FullyDistSpVec.h.

template<class IT, class NT>
template<typename _BinaryOperation >
void FullyDistSpVec< IT, NT >::ApplyInd ( _BinaryOperation  __binary_op)
inline

Definition at line 184 of file FullyDistSpVec.h.

template<class IT , class NT >
template<typename _Predicate >
IT FullyDistSpVec< IT, NT >::Count ( _Predicate  pred) const

Return the number of elements for which pred is true.

Definition at line 681 of file FullyDistSpVec.cpp.

template<class IT , class NT >
void FullyDistSpVec< IT, NT >::DebugPrint ( )

Definition at line 736 of file FullyDistSpVec.cpp.

template<class IT , class NT >
void FullyDistSpVec< IT, NT >::DelElement ( IT  indx)

Definition at line 156 of file FullyDistSpVec.cpp.

template<class IT, class NT>
shared_ptr<CommGrid> FullyDistSpVec< IT, NT >::getcommgrid ( ) const
inline

Definition at line 202 of file FullyDistSpVec.h.

template<class IT, class NT>
IT FullyDistSpVec< IT, NT >::getlocnnz ( ) const
inline

Definition at line 145 of file FullyDistSpVec.h.

template<class IT, class NT>
IT FullyDistSpVec< IT, NT >::getnnz ( ) const
inline

Definition at line 149 of file FullyDistSpVec.h.

template<class IT , class NT >
void FullyDistSpVec< IT, NT >::iota ( IT  globalsize,
NT  first 
)

Definition at line 291 of file FullyDistSpVec.cpp.

template<class IT, class NT>
template<typename NNT >
FullyDistSpVec< IT, NT >::operator FullyDistSpVec< IT, NNT > ( ) const
inline

< Type conversion operator

Definition at line 117 of file FullyDistSpVec.h.

template<class IT , class NT >
FullyDistVec< IT, NT > FullyDistSpVec< IT, NT >::operator() ( const FullyDistVec< IT, IT > &  ri) const

SpRef (expects ri to be 0-based)

The distribution and length are inherited from ri Its zero is inherited from *this (because ri is of type IT) Example: This is [{1,n1},{4,n4},{7,n7},{8,n8},{9,n9}] with P_00 owning {1,4} and P_11 rest Assume ri = [4,1,5,7] is distributed as two elements per processor Then result has length 4, distrubuted two element per processor, even though 5 and 7 doesn't exist This is because we are returning a "dense" output, so the absent elements will be padded with 0

Definition at line 180 of file FullyDistSpVec.cpp.

template<class IT , class NT >
FullyDistSpVec< IT, NT > & FullyDistSpVec< IT, NT >::operator+= ( const FullyDistSpVec< IT, NT > &  rhs)

Definition at line 342 of file FullyDistSpVec.cpp.

template<class IT , class NT >
FullyDistSpVec< IT, NT > & FullyDistSpVec< IT, NT >::operator-= ( const FullyDistSpVec< IT, NT > &  rhs)

Definition at line 401 of file FullyDistSpVec.cpp.

template<class IT , class NT >
FullyDistSpVec< IT, NT > & FullyDistSpVec< IT, NT >::operator= ( const FullyDistSpVec< IT, NT > &  rhs)

Definition at line 57 of file FullyDistSpVec.cpp.

template<class IT , class NT >
FullyDistSpVec< IT, NT > & FullyDistSpVec< IT, NT >::operator= ( const FullyDistVec< IT, NT > &  rhs)

Definition at line 75 of file FullyDistSpVec.cpp.

template<class IT, class NT>
bool FullyDistSpVec< IT, NT >::operator== ( const FullyDistSpVec< IT, NT > &  rhs) const
inline

Definition at line 126 of file FullyDistSpVec.h.

template<class IT , class NT >
NT FullyDistSpVec< IT, NT >::operator[] ( IT  indx)

Definition at line 98 of file FullyDistSpVec.cpp.

template<class IT , class NT >
void FullyDistSpVec< IT, NT >::PrintInfo ( string  vecname) const

Definition at line 728 of file FullyDistSpVec.cpp.

template<class IT , class NT >
template<class HANDLER >
ifstream & FullyDistSpVec< IT, NT >::ReadDistribute ( ifstream &  infile,
int  master,
HANDLER  handler 
)

Called on an existing object.

Definition at line 461 of file FullyDistSpVec.cpp.

template<class IT, class NT>
ifstream& FullyDistSpVec< IT, NT >::ReadDistribute ( ifstream &  infile,
int  master 
)
inline

Definition at line 110 of file FullyDistSpVec.h.

template<class IT , class NT >
template<typename _BinaryOperation >
NT FullyDistSpVec< IT, NT >::Reduce ( _BinaryOperation  __binary_op,
NT  init 
)

Definition at line 692 of file FullyDistSpVec.cpp.

template<class IT , class NT >
template<typename OUT , typename _BinaryOperation , typename _UnaryOperation >
OUT FullyDistSpVec< IT, NT >::Reduce ( _BinaryOperation  __binary_op,
OUT  default_val,
_UnaryOperation  __unary_op 
)

Definition at line 705 of file FullyDistSpVec.cpp.

template<class IT , class NT >
template<class HANDLER >
void FullyDistSpVec< IT, NT >::SaveGathered ( ofstream &  outfile,
int  master,
HANDLER  handler,
bool  printProcSplits = false 
)

Definition at line 595 of file FullyDistSpVec.cpp.

template<class IT, class NT>
void FullyDistSpVec< IT, NT >::SaveGathered ( ofstream &  outfile,
int  master 
)
inline

Definition at line 114 of file FullyDistSpVec.h.

template<class IT , class NT >
void FullyDistSpVec< IT, NT >::SetElement ( IT  indx,
NT  numx 
)

Indexing is performed 0-based.

Definition at line 126 of file FullyDistSpVec.cpp.

template<class IT, class NT>
void FullyDistSpVec< IT, NT >::setNumToInd ( )
inline

Definition at line 163 of file FullyDistSpVec.h.

template<class IT , class NT >
FullyDistSpVec< IT, IT > FullyDistSpVec< IT, NT >::sort ( )

Definition at line 302 of file FullyDistSpVec.cpp.

template<class IT , class NT >
void FullyDistSpVec< IT, NT >::stealFrom ( FullyDistSpVec< IT, NT > &  victim)

like operator=, but instead of making a deep copy it just steals the contents. Useful for places where the "victim" will be distroyed immediately after the call.

Definition at line 90 of file FullyDistSpVec.cpp.

template<class IT, class NT>
bool FullyDistSpVec< IT, NT >::WasFound ( ) const
inline

Definition at line 139 of file FullyDistSpVec.h.


Friends And Related Function Documentation

template<class IT, class NT>
template<typename RET , typename IU , typename NU1 , typename NU2 , typename _BinaryOperation , typename _BinaryPredicate >
FullyDistSpVec<IU,RET> EWiseApply ( const FullyDistSpVec< IU, NU1 > &  V,
const FullyDistVec< IU, NU2 > &  W,
_BinaryOperation  _binary_op,
_BinaryPredicate  _doOp,
bool  allowVNulls,
NU1  Vzero,
const bool  useExtendedBinOp 
)
friend

Performs an arbitrary binary operation _binary_op on the corresponding elements of two vectors with the result stored in a return vector ret. The binary operatiation is only performed if the binary predicate _doOp returns true for those elements. Otherwise the binary operation is not performed and ret does not contain an element at that position. More formally the operation is defined as: if (_doOp(V[i], W[i])) ret[i] = _binary_op(V[i], W[i]) else // ret[i] is not set Hence _doOp can be used to implement a filter on either of the vectors.

The above is only defined if both V[i] and W[i] exist (i.e. an intersection). To allow a union operation (ex. when V[i] doesn't exist but W[i] does) the allowVNulls flag is set to true and the Vzero argument is used as the missing V[i] value.

The type of each element of ret must not necessarily be related to the types of V or W, so the return type must be explicitly specified as a template parameter: FullyDistSpVec<int, double> r = EWiseApply<double>(V, W, plus, retTrue, false, 0)

Definition at line 1285 of file ParFriends.h.

template<class IT, class NT>
template<typename RET , typename IU , typename NU1 , typename NU2 , typename _BinaryOperation , typename _BinaryPredicate >
FullyDistSpVec<IU,RET> EWiseApply ( const FullyDistSpVec< IU, NU1 > &  V,
const FullyDistSpVec< IU, NU2 > &  W,
_BinaryOperation  _binary_op,
_BinaryPredicate  _doOp,
bool  allowVNulls,
bool  allowWNulls,
NU1  Vzero,
NU2  Wzero,
const bool  allowIntersect,
const bool  useExtendedBinOp 
)
friend

Performs an arbitrary binary operation _binary_op on the corresponding elements of two vectors with the result stored in a return vector ret. The binary operatiation is only performed if the binary predicate _doOp returns true for those elements. Otherwise the binary operation is not performed and ret does not contain an element at that position. More formally the operation is defined as: if (_doOp(V[i], W[i])) ret[i] = _binary_op(V[i], W[i]) else // ret[i] is not set Hence _doOp can be used to implement a filter on either of the vectors.

The above is only defined if both V[i] and W[i] exist (i.e. an intersection). To allow a union operation (ex. when V[i] doesn't exist but W[i] does) the allowVNulls flag is set to true and the Vzero argument is used as the missing V[i] value. !allowVNulls && !allowWNulls => intersection !allowVNulls && allowWNulls => operate on all elements of V allowVNulls && !allowWNulls => operate on all elements of W allowVNulls && allowWNulls => union

The type of each element of ret must not necessarily be related to the types of V or W, so the return type must be explicitly specified as a template parameter: FullyDistSpVec<int, double> r = EWiseApply<double>(V, W, plus, retTrue, false, 0, false, 0)

Definition at line 1375 of file ParFriends.h.

template<class IT, class NT>
template<typename IU , typename NU1 , typename NU2 >
FullyDistSpVec<IU,typename promote_trait<NU1,NU2>::T_promote> EWiseMult ( const FullyDistSpVec< IU, NU1 > &  V,
const FullyDistVec< IU, NU2 > &  W,
bool  exclude,
NU2  zero 
)
friend

if exclude is true, then we prune all entries W[i] != zero from V if exclude is false, then we perform a proper elementwise multiplication

Definition at line 1182 of file ParFriends.h.

template<class IT, class NT>
FullyDistSpVec< IT, NT >::FullyDistSpVec
friend

Definition at line 214 of file FullyDistSpVec.h.

template<class IT, class NT>
friend class FullyDistVec
friend

Definition at line 217 of file FullyDistSpVec.h.

template<class IT, class NT>
template<typename SR , typename IU , typename OVT >
void MergeContributions ( FullyDistSpVec< IU, OVT > &  y,
int *&  recvcnt,
int *&  rdispls,
int32_t *&  recvindbuf,
OVT *&  recvnumbuf,
int  rowneighs 
)
friend

Helper functions for sparse matrix X sparse vector.

Definition at line 631 of file ParFriends.h.

template<class IT, class NT>
template<typename IU , typename VT >
void MergeContributions ( FullyDistSpVec< IU, VT > &  y,
int *&  recvcnt,
int *&  rdispls,
int32_t *&  recvindbuf,
VT *&  recvnumbuf,
int  rowneighs 
)
friend

Definition at line 191 of file BFSFriends.h.

template<class IT, class NT>
template<typename IU >
void RandPerm ( FullyDistSpVec< IU, IU > &  V)
friend
template<class IT, class NT>
template<typename IU >
void RenameVertices ( DistEdgeList< IU > &  DEL)
friend

Rename vertices globally. You first need to do create a random permutation distributed on all processors. Then the p round robin algorithm will do the renaming: For all processors P(i,i) Broadcast local_p to all p processors For j= i*N/p to min((i+1)*N/p, N) Rename the all j's with local_p(j) inside the edgelist (and mark them "renamed" so that yeach vertex id is renamed only once)

Definition at line 348 of file DistEdgeList.cpp.

template<class IT, class NT>
friend class SparseVectorLocalIterator
friend

Definition at line 223 of file FullyDistSpVec.h.

template<class IT, class NT>
template<typename SR , typename IU , typename NUM , typename NUV , typename UDER >
FullyDistSpVec<IU,typename promote_trait<NUM,NUV>::T_promote> SpMV ( const SpParMat< IU, NUM, UDER > &  A,
const FullyDistSpVec< IU, NUV > &  x 
)
friend

Old version that is no longer considered optimal Kept for legacy purposes To be removed when other functionals are fully tested.

Definition at line 913 of file ParFriends.h.

template<class IT, class NT>
template<typename SR , typename IU , typename NUM , typename UDER >
FullyDistSpVec<IU,typename promote_trait<NUM,IU>::T_promote> SpMV ( const SpParMat< IU, NUM, UDER > &  A,
const FullyDistSpVec< IU, IU > &  x,
bool  indexisvalue 
)
friend

Definition at line 462 of file ParFriends.h.

template<class IT, class NT>
template<typename VT , typename IU , typename UDER >
FullyDistSpVec<IU,VT> SpMV ( const SpParMat< IU, bool, UDER > &  A,
const FullyDistSpVec< IU, VT > &  x,
OptBuf< int32_t, VT > &  optbuf 
)
friend
template<class IT, class NT>
template<typename SR , typename IVT , typename OVT , typename IU , typename NUM , typename UDER >
void SpMV ( const SpParMat< IU, NUM, UDER > &  A,
const FullyDistSpVec< IU, IVT > &  x,
FullyDistSpVec< IU, OVT > &  y,
bool  indexisvalue,
OptBuf< int32_t, OVT > &  optbuf 
)
friend

This version is the most flexible sparse matrix X sparse vector [Used in KDT] It accepts different types for the matrix (NUM), the input vector (IVT) and the output vector (OVT) without relying on automatic type promotion Input (x) and output (y) vectors can be ALIASED because y is not written until the algorithm is done with x.

Definition at line 728 of file ParFriends.h.

template<class IT, class NT>
friend class SpParMat
friend

Definition at line 220 of file FullyDistSpVec.h.

template<class IT, class NT>
template<typename IU , typename NV >
void TransposeVector ( MPI_Comm &  World,
const FullyDistSpVec< IU, NV > &  x,
int32_t &  trxlocnz,
IU &  lenuntil,
int32_t *&  trxinds,
NV *&  trxnums,
bool  indexisvalue 
)
friend

Step 1 of the sparse SpMV algorithm

Parameters:
[in,out]trxlocnz,lenuntil,trxinds,trxnums{ set or allocated }
[in]indexisvalue

Definition at line 475 of file ParFriends.h.


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