9 #define PANGOLIN_CUDA_MEMBER __host__ __device__ 11 #define PANGOLIN_CUDA_MEMBER 16 template<typename Index>
20 template<
typename Index>
22 if (rowOffset_.size() == 0) {
25 return rowOffset_.size() - 1;
29 template<
typename Index>
31 std::set<Index> nodes;
33 for (Index ci = 0; ci < col_.size(); ++ci) {
34 nodes.insert(col_[ci]);
37 for (Index i = 0; i < rowOffset_.size() - 1; ++i) {
38 Index row_start = rowOffset_[i];
39 Index row_end = rowOffset_[i+1];
40 if (row_start != row_end) {
47 template<
typename Index>
53 LOG(warn,
"constructing from empty edge list");
58 for (
const auto &edge : es) {
60 const Index src =
static_cast<Index
>(edge.first);
61 const Index dst =
static_cast<Index
>(edge.second);
65 while (csr.
rowOffset_.size() != size_t(src + 1))
75 if (
nullptr != edgeFilter && edgeFilter(edge)) {
78 csr.
col_.push_back(dst);
89 template<
typename Index>
95 view.
col_ = col_.data();
102 #undef PANGOLIN_CUDA_MEMBER A CSR matrix backed by CUDA Unified Memory.
Definition: gpu_csr.hpp:16
static GPUCSR< Index > from_edgelist(const EdgeList &es, bool(*edgeFilter)(const Edge &)=nullptr)
Definition: gpu_csr-impl.hpp:48
a read-only view of a GPUCSRm suitable for passing to a GPU kernel by value.
Definition: gpu_csr.hpp:23
Vector< Index > col_
non-zero column indices
Definition: gpu_csr.hpp:55
PANGOLIN_CUDA_MEMBER uint64_t num_rows() const
number of matrix rows
Definition: gpu_csr-impl.hpp:21
PANGOLIN_BEGIN_NAMESPACE()
std::vector< Edge > EdgeList
Definition: edge_list.hpp:9
#define LOG(level,...)
Definition: logger.hpp:25
Vector< Index > rowOffset_
offset in col_ that each row starts at
Definition: gpu_csr.hpp:54
GPUCSRView< Index > view() const
create a GPUCSRView for this GPUCSR
Definition: gpu_csr-impl.hpp:90
Index maxCol_
Definition: gpu_csr.hpp:51
uint64_t nnz_
number of non-zeros
Definition: gpu_csr.hpp:26
uint64_t num_rows_
length of rowOffset - 1
Definition: gpu_csr.hpp:27
const Index * rowOffset_
offset in col_ that each row starts at
Definition: gpu_csr.hpp:31
const Index * col_
non-zero column indices
Definition: gpu_csr.hpp:32
uint64_t num_nodes() const
number of unique row/col indices
Definition: gpu_csr-impl.hpp:30
#define PANGOLIN_CUDA_MEMBER
Definition: gpu_csr-impl.hpp:11
#define PANGOLIN_END_NAMESPACE()
std::pair< Uint, Uint > Edge
Definition: edge.hpp:14