COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
SpImpl.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 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 */
28
29
30#ifndef _SP_IMPL_H_
31#define _SP_IMPL_H_
32
33#include <iostream>
34#include <vector>
35#include "PreAllocatedSPA.h"
36#include "Deleter.h"
37
38namespace combblas {
39
40template <class IT, class NT>
41class Dcsc;
42
43template <class IT, class NT>
44class Csc;
45
46template <class SR, class IT, class NUM, class IVT, class OVT>
47struct SpImpl;
48
50template <class SR, class IT, class NUM, class IVT, class OVT>
51void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
52 std::vector<int32_t> & indy, std::vector< OVT > & numy, PreAllocatedSPA<OVT> & SPA)
53{
54 // ignoring SPA for now. However, a branching similar to the CSC case can be implemented
55 SpImpl<SR,IT,NUM,IVT,OVT>::SpMXSpV(Adcsc, mA, indx, numx, veclen, indy, numy); // don't touch this
56};
57
58
60template <class SR, class IT, class NUM, class IVT, class OVT>
61void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
62 int32_t * indy, OVT * numy, int * cnts, int * dspls, int p_c)
63{
64 SpImpl<SR,IT,NUM,IVT,OVT>::SpMXSpV(Adcsc, mA, indx, numx, veclen, indy, numy, cnts, dspls,p_c); // don't touch this
65};
66
67
69template <class SR, class IT, class NUM, class IVT, class OVT>
70void SpMXSpV_ForThreading(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
71 std::vector<int32_t> & indy, std::vector< OVT > & numy, int32_t offset)
72{
73 SpImpl<SR,IT,NUM,IVT,OVT>::SpMXSpV_ForThreading(Adcsc, mA, indx, numx, veclen, indy, numy, offset); // don't touch this
74};
75
77template <class SR, class IT, class NUM, class IVT, class OVT>
78void SpMXSpV_ForThreading(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
79 std::vector<int32_t> & indy, std::vector< OVT > & numy, int32_t offset, std::vector<OVT> & localy, BitMap & isthere, std::vector<uint32_t> & nzinds)
80{
81 SpImpl<SR,IT,NUM,IVT,OVT>::SpMXSpV_ForThreading(Adcsc, mA, indx, numx, veclen, indy, numy, offset, localy, isthere, nzinds);
82};
83
84
85
86
87
88
89
90
91
92/*
93 The following two functions are base CSC implementation. All overloaded function calls will be routed to these functions.
94 */
95// all CSC will fall to this
96template <typename SR, typename IT, typename NUM, typename IVT, typename OVT>
97void SpMXSpV_HeapSort(const Csc<IT,NUM> & Acsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen, std::vector<int32_t> & indy, std::vector<OVT> & numy, int32_t offset);
98
99// all PreAllocatedSPA will fall to this
100template <class SR, class IT, class NUM, class IVT, class OVT>
101void SpMXSpV_Bucket(const Csc<IT,NUM> & Acsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,std::vector<int32_t> & indy, std::vector< OVT > & numy, PreAllocatedSPA<OVT> & SPA);
102
103
104
106template <class SR, class IT, class NUM, class IVT, class OVT>
107void SpMXSpV(const Csc<IT,NUM> & Acsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
108 int32_t * indy, OVT * numy, int * cnts, int * dspls, int p_c)
109{
110 std::cout << "Optbuf enabled version is not yet supported with CSC matrices" << std::endl;
111};
112
113
115template <class SR, class IT, class NUM, class IVT, class OVT>
116void SpMXSpV(const Csc<IT,NUM> & Acsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
117 std::vector<int32_t> & indy, std::vector< OVT > & numy, PreAllocatedSPA<OVT> & SPA)
118{
119 if(SPA.initialized)
120 SpMXSpV_Bucket<SR>(Acsc, mA, indx, numx, veclen, indy, numy, SPA);
121 else
122 SpMXSpV_HeapSort<SR>(Acsc, mA, indx, numx, veclen, indy, numy, 0);
123
124};
125
127template <class SR, class IT, class NUM, class IVT, class OVT>
128void SpMXSpV_ForThreading(const Csc<IT,NUM> & Acsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
129 std::vector<int32_t> & indy, std::vector< OVT > & numy, int32_t offset)
130{
131 SpMXSpV_HeapSort<SR>(Acsc, mA, indx, numx, veclen, indy, numy, offset);
132};
133
135template <class SR, class IT, class NUM, class IVT, class OVT>
136void SpMXSpV_ForThreading(const Csc<IT,NUM> & Acsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
137 std::vector<int32_t> & indy, std::vector< OVT > & numy, int32_t offset, std::vector<OVT> & localy, BitMap & isthere, std::vector<uint32_t> & nzinds)
138{
139
140 SpMXSpV_HeapSort<SR>(Acsc, mA, indx, numx, veclen, indy, numy, offset);
141 // We can eventually call SpMXSpV_HeapMerge or SpMXSpV_SPA (not implemented for CSC yet)
142};
143
144
145
146
147
155template <class SR, class IT, class NUM, class IVT, class OVT>
156struct SpImpl
157{
158 static void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
159 std::vector<int32_t> & indy, std::vector< OVT > & numy); // specialize this
160
161 static void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
162 int32_t * indy, OVT * numy, int * cnts, int * dspls, int p_c)
163 {
164 std::cout << "Optbuf enabled version is not yet supported with general (non-boolean) matrices" << std::endl;
165 };
166
167
168 static void SpMXSpV_ForThreading(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
169 std::vector<int32_t> & indy, std::vector<OVT> & numy, int32_t offset)
170 {
171 std::cout << "Threaded version is not yet supported with general (non-boolean) matrices" << std::endl;
172 };
173 static void SpMXSpV_ForThreading(const Dcsc<IT,NUM> & Acsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
174 std::vector<int32_t> & indy, std::vector<OVT> & numy, int32_t offset, std::vector<OVT> & localy, BitMap & isthere, std::vector<uint32_t> & nzinds)
175 {
176 std::cout << "Threaded version is not yet supported with general (non-boolean) matrices" << std::endl;
177 };
178};
179
180
181
182
183template <class SR, class IT, class IVT, class OVT>
184struct SpImpl<SR,IT,bool, IVT, OVT> // specialization
185{
186 static void SpMXSpV(const Dcsc<IT,bool> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
187 std::vector<int32_t> & indy, std::vector< OVT > & numy);
188
189 static void SpMXSpV(const Dcsc<IT,bool> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
190 int32_t * indy, OVT * numy, int * cnts, int * dspls, int p_c);
191
193 static void SpMXSpV_ForThreading(const Dcsc<IT,bool> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
194 std::vector<int32_t> & indy, std::vector<OVT> & numy, int32_t offset);
196 static void SpMXSpV_ForThreading(const Dcsc<IT,bool> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
197 std::vector<int32_t> & indy, std::vector<OVT> & numy, int32_t offset, std::vector<OVT> & localy, BitMap & isthere, std::vector<uint32_t> & nzinds);
198};
199
200}
201
202#include "SpImpl.cpp"
203
204#endif
int64_t IT
SelectMaxSRing< bool, int64_t > SR
Definition SpMMError.cpp:18
void SpMXSpV_Bucket(const Csc< IT, NT > &Acsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, PreAllocatedSPA< OVT > &SPA)
Definition SpImpl.cpp:390
void SpMXSpV_ForThreading(const Dcsc< IT, NUM > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, int32_t offset)
Overload #3: DCSC.
Definition SpImpl.h:70
void SpMXSpV(const Dcsc< IT, NUM > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, PreAllocatedSPA< OVT > &SPA)
Overload #1: DCSC.
Definition SpImpl.h:51
void SpMXSpV_HeapSort(const Csc< IT, NT > &Acsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, int32_t offset)
Definition SpImpl.cpp:345
signed int int32_t
Definition stdint.h:77
static void SpMXSpV(const Dcsc< IT, bool > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy)
static void SpMXSpV(const Dcsc< IT, bool > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, int32_t *indy, OVT *numy, int *cnts, int *dspls, int p_c)
static void SpMXSpV_ForThreading(const Dcsc< IT, bool > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, int32_t offset)
Dcsc and vector index types do not need to match.
static void SpMXSpV_ForThreading(const Dcsc< IT, bool > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, int32_t offset, std::vector< OVT > &localy, BitMap &isthere, std::vector< uint32_t > &nzinds)
Dcsc and vector index types do not need to match.
static void SpMXSpV(const Dcsc< IT, NUM > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy)
Definition SpImpl.cpp:57
static void SpMXSpV(const Dcsc< IT, NUM > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy)
static void SpMXSpV(const Dcsc< IT, NUM > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, int32_t *indy, OVT *numy, int *cnts, int *dspls, int p_c)
Definition SpImpl.h:161
static void SpMXSpV_ForThreading(const Dcsc< IT, NUM > &Acsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, int32_t offset, std::vector< OVT > &localy, BitMap &isthere, std::vector< uint32_t > &nzinds)
Definition SpImpl.h:173
static void SpMXSpV_ForThreading(const Dcsc< IT, NUM > &Adcsc, int32_t mA, const int32_t *indx, const IVT *numx, int32_t veclen, std::vector< int32_t > &indy, std::vector< OVT > &numy, int32_t offset)
Definition SpImpl.h:168