graph
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
coo.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "pangolin/types.hpp"
4 #include "pangolin/edge_list.hpp"
6 
7 #ifdef __CUDACC__
8 #define HOST __host__
9 #define DEVICE __device__
10 #else
11 #define HOST
12 #define DEVICE
13 #endif
14 
16 
17 template<typename Index>
18 class COO;
19 
24 template<typename Index>
25 class COOView {
26  friend class COO<Index>;
27 private:
28  uint64_t nnz_;
29  uint64_t num_rows_;
30 
31 public:
32  const Index *rowPtr_;
33  const Index *rowInd_;
34  const Index *colInd_;
35 
36  HOST DEVICE uint64_t nnz() const {return nnz_; }
37  HOST DEVICE uint64_t num_rows() const {return num_rows_; }
38 
39  const Index *row_ptr() const { return rowPtr_; }
40  const Index *col_ind() const { return colInd_; }
41  const Index *row_ind() const { return rowInd_; } //<! row index array
42 
43 };
44 
50 template<typename Index>
51 class COO {
52 private:
53  Index maxCol_;
54  public:
55  COO();
56  Vector<Index> rowPtr_;
57  Vector<Index> colInd_;
58  Vector<Index> rowInd_;
59  HOST DEVICE uint64_t nnz() const {
60  assert(colInd_.size() == rowInd_.size());
61  return colInd_.size();
62  }
63  uint64_t num_nodes() const;
64  HOST DEVICE uint64_t num_rows() const;
65 
70  static COO<Index> from_edgelist(const EdgeList &es, bool (*edgeFilter)(const Edge &) = nullptr);
71  COOView<Index> view() const;
72 
73  const Index *row_ptr() { return rowPtr_.data(); }
74  const Index *col_ind() { return colInd_.data(); }
75  const Index *row_ind() { return rowInd_.data(); } //<! row index array
76 };
77 
78 
79 
81 
82 
83 #undef HOST
84 #undef DEVICE
85 
86 
87 #include "coo-impl.hpp"
const Index * row_ind()
Definition: coo.hpp:75
uint64_t num_nodes() const
number of unique row/col indices
Definition: coo-impl.hpp:32
HOST DEVICE uint64_t num_rows() const
number of matrix rows
Definition: coo-impl.hpp:23
a read-only view of a COO suitable for passing to a GPU kernel by value.
Definition: coo.hpp:25
COO()
empty CSR
Definition: coo-impl.hpp:19
const Index * row_ptr() const
row offset array
Definition: coo.hpp:39
COOView< Index > view() const
create a COOView for this COO
Definition: coo-impl.hpp:93
Vector< Index > rowInd_
non-zero row indices
Definition: coo.hpp:58
PANGOLIN_BEGIN_NAMESPACE()
std::vector< Edge > EdgeList
Definition: edge_list.hpp:9
const Index * colInd_
non-zero column indices
Definition: coo.hpp:34
A COO matrix backed by CUDA Unified Memory, with a CSR rowPtr.
Definition: coo.hpp:18
const Index * row_ptr()
row offset array
Definition: coo.hpp:73
Vector< Index > rowPtr_
offset in col_ that each row starts at
Definition: coo.hpp:56
Vector< Index > colInd_
non-zero column indices
Definition: coo.hpp:57
uint64_t nnz_
number of non-zeros
Definition: coo.hpp:28
#define HOST
Definition: coo.hpp:11
const Index * col_ind()
column index array
Definition: coo.hpp:74
HOST DEVICE uint64_t num_rows() const
Definition: coo.hpp:37
const Index * rowInd_
non-zero row indices
Definition: coo.hpp:33
static COO< Index > from_edgelist(const EdgeList &es, bool(*edgeFilter)(const Edge &)=nullptr)
Definition: coo-impl.hpp:50
const Index * row_ind() const
Definition: coo.hpp:41
uint64_t num_rows_
length of rowOffset - 1
Definition: coo.hpp:29
const Index * rowPtr_
offset in col_ that each row starts at
Definition: coo.hpp:32
#define DEVICE
Definition: coo.hpp:12
#define PANGOLIN_END_NAMESPACE()
HOST DEVICE uint64_t nnz() const
number of non-zeros
Definition: coo.hpp:59
HOST DEVICE uint64_t nnz() const
Definition: coo.hpp:36
const Index * col_ind() const
column index array
Definition: coo.hpp:40
std::pair< Uint, Uint > Edge
Definition: edge.hpp:14
Index maxCol_
Definition: coo.hpp:53