Skip to content

Commit

Permalink
Merge pull request rapidsai#840 from afender/opg_degree
Browse files Browse the repository at this point in the history
[REVIEW] OPG degree
  • Loading branch information
BradReesWork authored May 6, 2020
2 parents 5879040 + 07feb33 commit 3f78243
Show file tree
Hide file tree
Showing 9 changed files with 554 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## New Features
- PR #822 Added new functions in python graph class, similar to networkx
- PR #840 OPG degree

## Improvements
- PR #764 Updated sssp and bfs with GraphCSR, removed gdf_column, added nullptr weights test for sssp
Expand Down
5 changes: 5 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ link_directories(
"${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}")

add_library(cugraph SHARED
src/comms/mpi/comms_mpi.cpp
src/ktruss/ktruss.cu
src/db/db_object.cu
src/db/db_parser_integration_test.cu
Expand Down Expand Up @@ -352,6 +353,10 @@ add_library(cugraph SHARED
#
add_dependencies(cugraph cugunrock)

if (BUILD_MPI)
add_compile_definitions(ENABLE_OPG=1)
endif (BUILD_MPI)

###################################################################################################
# - include paths ---------------------------------------------------------------------------------
target_include_directories(cugraph
Expand Down
74 changes: 74 additions & 0 deletions cpp/include/comms_mpi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#if ENABLE_OPG
#include <mpi.h>
#include <nccl.h>
#endif
#include <cstddef>
namespace cugraph {
namespace experimental {

enum class ReduceOp { SUM, MAX, MIN };

// basic info about the snmg env setup
class Comm {
private:
int _p{0};
int _rank{0};
bool _finalize_mpi{false};
bool _finalize_nccl{false};

int _device_id{0};
int _device_count{0};

int _sm_count_per_device{0};
int _max_grid_dim_1D{0};
int _max_block_dim_1D{0};
int _l2_cache_size{0};
int _shared_memory_size_per_sm{0};

#if ENABLE_OPG
MPI_Comm _mpi_comm{};
ncclComm_t _nccl_comm{};
#endif

public:
Comm(){};
Comm(int p);
#if ENABLE_OPG
Comm(ncclComm_t comm, int size, int rank);
#endif
~Comm();
int get_rank() const { return _rank; }
int get_p() const { return _p; }
int get_dev() const { return _device_id; }
int get_dev_count() const { return _device_count; }
int get_sm_count() const { return _sm_count_per_device; }
bool is_master() const { return (_rank == 0) ? true : false; }

void barrier();

template <typename value_t>
void allgather(size_t size, value_t *sendbuff, value_t *recvbuff) const;

template <typename value_t>
void allreduce(size_t size, value_t *sendbuff, value_t *recvbuff, ReduceOp reduce_op) const;
};

} // namespace experimental
} // namespace cugraph
33 changes: 20 additions & 13 deletions cpp/include/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
#pragma once

#include <comms_mpi.hpp>
namespace cugraph {
namespace experimental {

Expand Down Expand Up @@ -47,6 +47,7 @@ enum class DegreeDirection {
template <typename VT, typename ET, typename WT>
class GraphBase {
public:
Comm comm;
WT *edge_data; ///< edge weight

GraphProperties prop;
Expand All @@ -57,12 +58,16 @@ class GraphBase {
/**
* @brief Fill the identifiers array with the vertex identifiers.
*
* @param[out] identifier Pointer to device memory to store the vertex identifiers
* @param[out] identifier Pointer to device memory to store the vertex
* identifiers
*/
void get_vertex_identifiers(VT *identifiers) const;

void set_communicator(Comm &comm_) { comm = comm_; }

GraphBase(WT *edge_data_, VT number_of_vertices_, ET number_of_edges_)
: edge_data(edge_data_),
comm(),
prop(),
number_of_vertices(number_of_vertices_),
number_of_edges(number_of_edges_)
Expand Down Expand Up @@ -102,8 +107,8 @@ class GraphCOO : public GraphBase<VT, ET, WT> {
/**
* @brief Wrap existing arrays representing an edge list in a Graph.
*
* GraphCOO does not own the memory used to represent this graph. This
* function does not allocate memory.
* GraphCOO does not own the memory used to represent this graph.
* This function does not allocate memory.
*
* @param source_indices This array of size E (number of edges) contains the index of the
* source for each edge. Indices must be in the range [0, V-1].
Expand Down Expand Up @@ -138,9 +143,11 @@ class GraphCompressedSparseBase : public GraphBase<VT, ET, WT> {
VT *indices{nullptr}; ///< CSR indices

/**
* @brief Fill the identifiers in the array with the source vertex identifiers
* @brief Fill the identifiers in the array with the source vertex
* identifiers
*
* @param[out] src_indices Pointer to device memory to store the source vertex identifiers
* @param[out] src_indices Pointer to device memory to store the
* source vertex identifiers
*/
void get_source_indices(VT *src_indices) const;

Expand All @@ -160,8 +167,8 @@ class GraphCompressedSparseBase : public GraphBase<VT, ET, WT> {

/**
* @brief Wrap existing arrays representing adjacency lists in a Graph.
* GraphCSR does not own the memory used to represent this graph. This
* function does not allocate memory.
* GraphCSR does not own the memory used to represent this graph.
* This function does not allocate memory.
*
* @param offsets This array of size V+1 (V is number of vertices) contains the
* offset of adjacency lists of every vertex. Offsets must be in the range [0, E] (number of
Expand Down Expand Up @@ -199,8 +206,8 @@ class GraphCSR : public GraphCompressedSparseBase<VT, ET, WT> {

/**
* @brief Wrap existing arrays representing adjacency lists in a Graph.
* GraphCSR does not own the memory used to represent this graph. This
* function does not allocate memory.
* GraphCSR does not own the memory used to represent this graph.
* This function does not allocate memory.
*
* @param offsets This array of size V+1 (V is number of vertices) contains the
* offset of adjacency lists of every vertex. Offsets must be in the range [0, E] (number of
Expand Down Expand Up @@ -235,9 +242,9 @@ class GraphCSC : public GraphCompressedSparseBase<VT, ET, WT> {
GraphCSC() : GraphCompressedSparseBase<VT, ET, WT>(nullptr, nullptr, nullptr, 0, 0) {}

/**
* @brief Wrap existing arrays representing transposed adjacency lists in a Graph.
* GraphCSC does not own the memory used to represent this graph. This
* function does not allocate memory.
* @brief Wrap existing arrays representing transposed adjacency lists in
* a Graph. GraphCSC does not own the memory used to represent this graph.
* This function does not allocate memory.
*
* @param offsets This array of size V+1 (V is number of vertices) contains the
* offset of adjacency lists of every vertex. Offsets must be in the range [0, E] (number of
Expand Down
Loading

0 comments on commit 3f78243

Please sign in to comment.