COMBINATORIAL_BLAS 1.6
 
Loading...
Searching...
No Matches
OptBuf.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 _OPT_BUF_H
31#define _OPT_BUF_H
32#include "BitMap.h"
33
34namespace combblas {
35
42template <class IT, class NT>
43class OptBuf
44{
45public:
46 OptBuf(): isthere(NULL), p_c(0), totmax(0), localm(0) {};
47 void MarkEmpty()
48 {
49 if(totmax > 0)
50 {
51 isthere->reset();
52 }
53 }
54
55 void Set(const std::vector<int> & maxsizes, int mA)
56 {
57 p_c = maxsizes.size();
58 totmax = std::accumulate(maxsizes.begin(), maxsizes.end(), 0);
59 inds = new IT[totmax];
60 std::fill_n(inds, totmax, -1);
61 nums = new NT[totmax];
62 dspls = new int[p_c]();
63 std::partial_sum(maxsizes.begin(), maxsizes.end()-1, dspls+1);
64 localm = mA;
65
66 isthere = new BitMap(localm);
67 };
69 { if(localm > 0)
70 {
71 delete isthere;
72 }
73
74 if(totmax > 0)
75 {
76 delete [] inds;
77 delete [] nums;
78 }
79 if(p_c > 0)
80 delete [] dspls;
81 }
83 {
84 p_c = rhs.p_c;
85 totmax = rhs.totmax;
86 localm = rhs.localm;
87 inds = new IT[totmax];
88 nums = new NT[totmax];
89 dspls = new int[p_c]();
90 isthere = new BitMap(localm);
91 }
93 {
94 if(this != &rhs)
95 {
96 if(localm > 0)
97 {
98 delete isthere;
99 }
100 if(totmax > 0)
101 {
102 delete [] inds;
103 delete [] nums;
104 }
105 if(p_c > 0)
106 delete [] dspls;
107
108 p_c = rhs.p_c;
109 totmax = rhs.totmax;
110 localm = rhs.localm;
111 inds = new IT[totmax];
112 nums = new NT[totmax];
113 dspls = new int[p_c]();
114 isthere = new BitMap(*(rhs.isthere));
115 }
116 return *this;
117 }
118
121 int * dspls;
123 int p_c;
126};
127
128}
129
130#endif
131
int64_t IT
double NT
void reset()
Definition BitMap.h:79
BitMap * isthere
Definition OptBuf.h:122
OptBuf(const OptBuf< IT, NT > &rhs)
Definition OptBuf.h:82
void MarkEmpty()
Definition OptBuf.h:47
OptBuf< IT, NT > & operator=(const OptBuf< IT, NT > &rhs)
Definition OptBuf.h:92
void Set(const std::vector< int > &maxsizes, int mA)
Definition OptBuf.h:55