COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
dcsc.h
Go to the documentation of this file.
1/****************************************************************/
2/* Parallel Combinatorial BLAS Library (for Graph Computations) */
3/* version 1.6 -------------------------------------------------*/
4/* date: 6/15/2017 ---------------------------------------------*/
5/* authors: Ariful Azad, Aydin Buluc --------------------------*/
6/****************************************************************/
7/*
8 Copyright (c) 2010-2017, The Regents of the University of California
9
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 THE SOFTWARE.
28 */
29
30
31#ifndef _DCSC_H
32#define _DCSC_H
33
34#include <cstdlib>
35#include <vector>
36#include <limits>
37#include <cassert>
38#include "SpDefs.h"
39#include "SpHelper.h"
40#include "StackEntry.h"
41#include "MemoryPool.h"
42#include "promote.h"
43
44namespace combblas {
45
46template <class IT, class NT>
47class Dcsc
48{
49public:
50 typedef NT value_type;
51 typedef IT index_type;
52 Dcsc ();
53 Dcsc (IT nnz, IT nzcol);
54
55 Dcsc (IT nnz, const std::vector<IT> & indices, bool isRow);
56 Dcsc (StackEntry<NT, std::pair<IT,IT> > * multstack, IT mdim, IT ndim, IT nnz);
57
58 Dcsc (const Dcsc<IT,NT> & rhs); // copy constructor
59 Dcsc<IT,NT> & operator=(const Dcsc<IT,NT> & rhs); // assignment operator
60 Dcsc<IT,NT> & operator+=(const Dcsc<IT,NT> & rhs); // add and assign operator
61 ~Dcsc();
62
63 bool operator==(const Dcsc<IT,NT> & rhs);
64 template <typename NNT> operator Dcsc<IT,NNT>() const; //<! numeric type conversion
65 template <typename NIT, typename NNT> operator Dcsc<NIT,NNT>() const; //<! index+numeric type conversion
66
67 void EWiseMult(const Dcsc<IT,NT> & rhs, bool exclude);
68 void EWiseScale(NT ** scaler); //<! scale elements of "this" with the elements dense rhs matrix
69
70 template <typename IU, typename NU1, typename NU2>
71 friend Dcsc<IU, typename promote_trait<NU1,NU2>::T_promote> EWiseMult(const Dcsc<IU,NU1> & A, const Dcsc<IU,NU2> * B, bool exclude); // Note that the second parameter is a POINTER
72
73 template <typename _UnaryOperation>
75 {
76 //transform(numx, numx+nz, numx, __unary_op);
77#ifdef _OPENMP
78#pragma omp parallel for
79#endif
80 for(IT i=0; i < nz; ++i)
81 numx[i] = __unary_op(numx[i]);
82
83 }
84
85 template <typename _UnaryOperation, typename GlobalIT>
87 template <typename _UnaryOperation>
89 template <typename _BinaryOperation>
91 template <typename _BinaryOperation>
93
94
95 IT AuxIndex(const IT colind, bool & found, IT * aux, IT csize) const;
96
98 void ColSplit(std::vector< Dcsc<IT,NT>* > & parts, std::vector<IT> & cuts);
99 void ColConcatenate(std::vector< Dcsc<IT,NT>* > & parts, std::vector<IT> & offsets);
100
101 void Split(Dcsc<IT,NT> * & A, Dcsc<IT,NT> * & B, IT cut);
102 void Merge(const Dcsc<IT,NT> * Adcsc, const Dcsc<IT,NT> * B, IT cut);
103
104 IT ConstructAux(IT ndim, IT * & aux) const;
105 void Resize(IT nzcnew, IT nznew);
106
107 template<class VT>
108 void FillColInds(const VT * colnums, IT nind, std::vector< std::pair<IT,IT> > & colinds, IT * aux, IT csize) const;
109
110 Dcsc<IT,NT> & AddAndAssign (StackEntry<NT, std::pair<IT,IT> > * multstack, IT mdim, IT ndim, IT nnz);
111
112 template <typename _BinaryOperation>
113 void UpdateDense(NT ** array, _BinaryOperation __binary_op) const; // update dense 2D array's entries with __binary_op using elements of "this"
114
116 Dcsc (IT * _cp, IT * _jc, IT * _ir, NT * _numx, IT _nz, IT _nzc, bool _memowned = true)
117 : cp(_cp), jc(_jc), ir(_ir), numx(_numx), nz(_nz), nzc(_nzc), memowned(_memowned) {};
118
119 IT * cp;
120 IT * jc ;
121 IT * ir ;
123
127
128private:
129 void getindices (StackEntry<NT, std::pair<IT,IT> > * multstack, IT & rindex, IT & cindex, IT & j, IT nnz);
130};
131
132}
133
134#include "dcsc.cpp"
135
136#endif
void EWiseScale(NT **scaler)
Definition dcsc.cpp:874
NT value_type
Definition dcsc.h:50
Dcsc< IT, NT > * PruneI(_UnaryOperation __unary_op, bool inPlace, GlobalIT rowOffset, GlobalIT colOffset)
Definition dcsc.cpp:523
void ColConcatenate(std::vector< Dcsc< IT, NT > * > &parts, std::vector< IT > &offsets)
Definition dcsc.cpp:1168
void ColSplit(std::vector< Dcsc< IT, NT > * > &parts, std::vector< IT > &cuts)
Definition dcsc.cpp:1070
Dcsc< IT, NT > * PruneColumn(NT *pvals, _BinaryOperation __binary_op, bool inPlace)
Definition dcsc.cpp:686
Dcsc< IT, NT > & operator=(const Dcsc< IT, NT > &rhs)
Definition dcsc.cpp:328
IT AuxIndex(const IT colind, bool &found, IT *aux, IT csize) const
Definition dcsc.cpp:1013
IT * ir
row indices, size nz
Definition dcsc.h:121
bool operator==(const Dcsc< IT, NT > &rhs)
Definition dcsc.cpp:472
void Merge(const Dcsc< IT, NT > *Adcsc, const Dcsc< IT, NT > *B, IT cut)
Definition dcsc.cpp:1134
Dcsc< IT, NT > * Prune(_UnaryOperation __unary_op, bool inPlace)
Definition dcsc.cpp:604
void Apply(_UnaryOperation __unary_op)
Definition dcsc.h:74
Dcsc< IT, NT > & AddAndAssign(StackEntry< NT, std::pair< IT, IT > > *multstack, IT mdim, IT ndim, IT nnz)
Definition dcsc.cpp:71
Dcsc(IT *_cp, IT *_jc, IT *_ir, NT *_numx, IT _nz, IT _nzc, bool _memowned=true)
wrap object around pre-allocated arrays (possibly RDMA registered)
Definition dcsc.h:116
IT * cp
The master array, size nzc+1 (keeps column pointers)
Definition dcsc.h:119
void Resize(IT nzcnew, IT nznew)
Definition dcsc.cpp:946
IT nzc
number of columns with at least one non-zero in them
Definition dcsc.h:125
void Split(Dcsc< IT, NT > *&A, Dcsc< IT, NT > *&B, IT cut)
Definition dcsc.cpp:1030
IT ConstructAux(IT ndim, IT *&aux) const
Definition dcsc.cpp:912
NT * numx
generic values, size nz
Definition dcsc.h:122
Dcsc< IT, NT > & operator+=(const Dcsc< IT, NT > &rhs)
Definition dcsc.cpp:374
bool memowned
Definition dcsc.h:126
void FillColInds(const VT *colnums, IT nind, std::vector< std::pair< IT, IT > > &colinds, IT *aux, IT csize) const
Definition dcsc.cpp:1211
IT index_type
Definition dcsc.h:51
void UpdateDense(NT **array, _BinaryOperation __binary_op) const
Definition dcsc.cpp:893
IT * jc
col indices, size nzc
Definition dcsc.h:120
void RowSplit(int numsplits)
friend Dcsc< IU, typename promote_trait< NU1, NU2 >::T_promote > EWiseMult(const Dcsc< IU, NU1 > &A, const Dcsc< IU, NU2 > *B, bool exclude)
Definition Friends.h:694
double A
double B
Definition options.h:15