... | ... |
@@ -1,49 +1,38 @@ |
1 | 1 |
#ifndef __COGAPS_HYBRID_VECTOR_H__ |
2 | 2 |
#define __COGAPS_HYBRID_VECTOR_H__ |
3 | 3 |
|
4 |
-#include "../utils/Archive.h" |
|
5 |
- |
|
6 |
-#include "boost/align/aligned_allocator.hpp" |
|
7 | 4 |
#include <vector> |
5 |
+#include <stdint.h> |
|
6 |
+#pragma GCC diagnostic push |
|
7 |
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
|
8 |
+#include <boost/align/aligned_allocator.hpp> |
|
9 |
+#pragma GCC diagnostic pop |
|
8 | 10 |
|
9 | 11 |
// need to align data for SIMD |
10 | 12 |
namespace bal = boost::alignment; |
11 | 13 |
typedef std::vector<float, bal::aligned_allocator<float,32> > aligned_vector; |
12 | 14 |
|
13 |
-class SparseIteratorTwo; |
|
14 |
-class SparseIteratorThree; |
|
15 |
+class Archive; |
|
15 | 16 |
|
16 | 17 |
// stored as a dense vector (efficient setting of values) but maintains |
17 | 18 |
// index bit flags of non-zeros so it can be used with SparseIterator |
18 | 19 |
class HybridVector |
19 | 20 |
{ |
20 | 21 |
public: |
21 |
- |
|
22 |
- friend class SparseIteratorTwo; |
|
23 |
- friend class SparseIteratorThree; |
|
24 |
- |
|
25 |
- template <unsigned N> |
|
26 |
- friend class SparseIterator; |
|
27 |
- |
|
28 | 22 |
explicit HybridVector(unsigned sz); |
29 | 23 |
explicit HybridVector(const std::vector<float> &v); |
30 |
- |
|
31 |
- bool empty() const; |
|
32 |
- unsigned size() const; |
|
33 |
- |
|
34 | 24 |
bool add(unsigned i, float v); // true if zeros out data |
35 | 25 |
bool set(unsigned i, float v); // true if zeros out data |
36 |
- float operator[](unsigned i) const; |
|
37 |
- |
|
26 |
+ bool empty() const; |
|
27 |
+ unsigned size() const; |
|
38 | 28 |
const float* ptr() const; |
39 |
- |
|
29 |
+ float operator[](unsigned i) const; |
|
40 | 30 |
const std::vector<uint64_t>& getBitFlags() const { return mIndexBitFlags; } |
41 |
- |
|
42 | 31 |
friend Archive& operator<<(Archive &ar, const HybridVector &vec); |
43 | 32 |
friend Archive& operator>>(Archive &ar, HybridVector &vec); |
44 |
- |
|
45 | 33 |
private: |
46 |
- |
|
34 |
+ template <unsigned N> |
|
35 |
+ friend class SparseIterator; |
|
47 | 36 |
std::vector<uint64_t> mIndexBitFlags; |
48 | 37 |
aligned_vector mData; |
49 | 38 |
unsigned mSize; |
... | ... |
@@ -42,9 +42,7 @@ public: |
42 | 42 |
friend Archive& operator<<(Archive &ar, const HybridVector &vec); |
43 | 43 |
friend Archive& operator>>(Archive &ar, HybridVector &vec); |
44 | 44 |
|
45 |
-#ifndef GAPS_INTERNAL_TESTS |
|
46 | 45 |
private: |
47 |
-#endif |
|
48 | 46 |
|
49 | 47 |
std::vector<uint64_t> mIndexBitFlags; |
50 | 48 |
aligned_vector mData; |
... | ... |
@@ -34,7 +34,7 @@ public: |
34 | 34 |
bool add(unsigned i, float v); // true if zeros out data |
35 | 35 |
float operator[](unsigned i) const; |
36 | 36 |
|
37 |
- const float* densePtr() const; |
|
37 |
+ const float* ptr() const; |
|
38 | 38 |
|
39 | 39 |
const std::vector<uint64_t>& getBitFlags() const { return mIndexBitFlags; } |
40 | 40 |
|
... | ... |
@@ -36,6 +36,8 @@ public: |
36 | 36 |
|
37 | 37 |
const float* densePtr() const; |
38 | 38 |
|
39 |
+ const std::vector<uint64_t>& getBitFlags() const { return mIndexBitFlags; } |
|
40 |
+ |
|
39 | 41 |
friend Archive& operator<<(Archive &ar, const HybridVector &vec); |
40 | 42 |
friend Archive& operator>>(Archive &ar, HybridVector &vec); |
41 | 43 |
|
... | ... |
@@ -39,7 +39,9 @@ public: |
39 | 39 |
friend Archive& operator<<(Archive &ar, const HybridVector &vec); |
40 | 40 |
friend Archive& operator>>(Archive &ar, HybridVector &vec); |
41 | 41 |
|
42 |
+#ifndef GAPS_INTERNAL_TESTS |
|
42 | 43 |
private: |
44 |
+#endif |
|
43 | 45 |
|
44 | 46 |
std::vector<uint64_t> mIndexBitFlags; |
45 | 47 |
aligned_vector mData; |
... | ... |
@@ -36,7 +36,7 @@ public: |
36 | 36 |
|
37 | 37 |
const float* densePtr() const; |
38 | 38 |
|
39 |
- friend Archive& operator<<(Archive &ar, HybridVector &vec); |
|
39 |
+ friend Archive& operator<<(Archive &ar, const HybridVector &vec); |
|
40 | 40 |
friend Archive& operator>>(Archive &ar, HybridVector &vec); |
41 | 41 |
|
42 | 42 |
private: |
... | ... |
@@ -21,6 +21,9 @@ public: |
21 | 21 |
|
22 | 22 |
friend class SparseIteratorTwo; |
23 | 23 |
friend class SparseIteratorThree; |
24 |
+ |
|
25 |
+ template <unsigned N> |
|
26 |
+ friend class TemplatedSparseIterator; |
|
24 | 27 |
|
25 | 28 |
explicit HybridVector(unsigned size); |
26 | 29 |
explicit HybridVector(const std::vector<float> &v); |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,45 @@ |
1 |
+#ifndef __COGAPS_HYBRID_VECTOR_H__ |
|
2 |
+#define __COGAPS_HYBRID_VECTOR_H__ |
|
3 |
+ |
|
4 |
+#include "../utils/Archive.h" |
|
5 |
+ |
|
6 |
+#include <boost/align/aligned_allocator.hpp> |
|
7 |
+#include <vector> |
|
8 |
+ |
|
9 |
+// need to align data for SIMD |
|
10 |
+namespace bal = boost::alignment; |
|
11 |
+typedef std::vector<float, bal::aligned_allocator<float,32> > aligned_vector; |
|
12 |
+ |
|
13 |
+class SparseIteratorTwo; |
|
14 |
+class SparseIteratorThree; |
|
15 |
+ |
|
16 |
+// stored as a dense vector (efficient setting of values) but maintains |
|
17 |
+// index bit flags of non-zeros so it can be used with SparseIterator |
|
18 |
+class HybridVector |
|
19 |
+{ |
|
20 |
+public: |
|
21 |
+ |
|
22 |
+ friend class SparseIteratorTwo; |
|
23 |
+ friend class SparseIteratorThree; |
|
24 |
+ |
|
25 |
+ explicit HybridVector(unsigned size); |
|
26 |
+ explicit HybridVector(const std::vector<float> &v); |
|
27 |
+ |
|
28 |
+ bool empty() const; |
|
29 |
+ unsigned size() const; |
|
30 |
+ |
|
31 |
+ bool add(unsigned i, float v); // true if zeros out data |
|
32 |
+ float operator[](unsigned i) const; |
|
33 |
+ |
|
34 |
+ const float* densePtr() const; |
|
35 |
+ |
|
36 |
+ friend Archive& operator<<(Archive &ar, HybridVector &vec); |
|
37 |
+ friend Archive& operator>>(Archive &ar, HybridVector &vec); |
|
38 |
+ |
|
39 |
+private: |
|
40 |
+ |
|
41 |
+ std::vector<uint64_t> mIndexBitFlags; |
|
42 |
+ aligned_vector mData; |
|
43 |
+}; |
|
44 |
+ |
|
45 |
+#endif // __COGAPS_HYBRID_VECTOR_H__ |
|
0 | 46 |
\ No newline at end of file |