COMBINATORIAL_BLAS  1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SpImpl.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* Parallel Combinatorial BLAS Library (for Graph Computations) */
3 /* version 1.2 -------------------------------------------------*/
4 /* date: 10/06/2011 --------------------------------------------*/
5 /* authors: Aydin Buluc (abuluc@lbl.gov), Adam Lugowski --------*/
6 /****************************************************************/
7 /*
8  Copyright (c) 2011, Aydin Buluc
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 #ifndef _SP_IMPL_H_
30 #define _SP_IMPL_H_
31 
32 #include <iostream>
33 #include <vector>
34 using namespace std;
35 
36 template <class IT, class NT>
37 class Dcsc;
38 
39 template <class SR, class IT, class NUM, class IVT, class OVT>
40 struct SpImpl;
41 
42 template <class SR, class IT, class NUM, class IVT, class OVT>
43 void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
44  vector<int32_t> & indy, vector< OVT > & numy)
45 {
46  SpImpl<SR,IT,NUM,IVT,OVT>::SpMXSpV(Adcsc, mA, indx, numx, veclen, indy, numy); // don't touch this
47 };
48 
49 template <class SR, class IT, class NUM, class IVT, class OVT>
50 void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
51  int32_t * indy, OVT * numy, int * cnts, int * dspls, int p_c)
52 {
53  SpImpl<SR,IT,NUM,IVT,OVT>::SpMXSpV(Adcsc, mA, indx, numx, veclen, indy, numy, cnts, dspls,p_c); // don't touch this
54 };
55 
56 template <class SR, class IT, class NUM, class IVT, class OVT>
57 void SpMXSpV_ForThreading(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
58  vector<int32_t> & indy, vector< OVT > & numy, int32_t offset)
59 {
60  SpImpl<SR,IT,NUM,IVT,OVT>::SpMXSpV_ForThreading(Adcsc, mA, indx, numx, veclen, indy, numy, offset); // don't touch this
61 };
62 
69 template <class SR, class IT, class NUM, class IVT, class OVT>
70 struct SpImpl
71 {
72  static void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
73  vector<int32_t> & indy, vector< OVT > & numy); // specialize this
74 
75  static void SpMXSpV(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
76  int32_t * indy, OVT * numy, int * cnts, int * dspls, int p_c)
77  {
78  cout << "Optbuf enabled version is not yet supported with general (non-boolean) matrices" << endl;
79  };
80 
81  static void SpMXSpV_ForThreading(const Dcsc<IT,NUM> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
82  vector<int32_t> & indy, vector<OVT> & numy, int32_t offset)
83  {
84  cout << "Threaded version is not yet supported with general (non-boolean) matrices" << endl;
85  };
86 };
87 
88 
89 
90 template <class SR, class IT, class IVT, class OVT>
91 struct SpImpl<SR,IT,bool, IVT, OVT> // specialization
92 {
93  static void SpMXSpV(const Dcsc<IT,bool> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
94  vector<int32_t> & indy, vector< OVT > & numy);
95 
96  static void SpMXSpV(const Dcsc<IT,bool> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
97  int32_t * indy, OVT * numy, int * cnts, int * dspls, int p_c);
98 
100  static void SpMXSpV_ForThreading(const Dcsc<IT,bool> & Adcsc, int32_t mA, const int32_t * indx, const IVT * numx, int32_t veclen,
101  vector<int32_t> & indy, vector<OVT> & numy, int32_t offset);
102 };
103 
104 #include "SpImpl.cpp"
105 #endif