Skip to content

Commit

Permalink
Merge pull request #239 from seunghwak/bug_ext_two_graphs
Browse files Browse the repository at this point in the history
[REVIEW] Bug ext two graphs
  • Loading branch information
afender authored Apr 24, 2019
2 parents d458760 + ca49a31 commit 40caa93
Show file tree
Hide file tree
Showing 20 changed files with 385 additions and 293 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
- PR #220 Fixed bugs in Nvgraph triangle counting
- PR #232 Fixed memory leaks in managing cudf columns.
- PR #236 Fixed issue with v0.7 nightly yml environment file. Also updated the README to remove pip
- PR #239 Added a check to prevent a cugraph object to store two different graphs.


# cuGraph 0.6.0 (22 Mar 2019)

Expand Down
10 changes: 5 additions & 5 deletions cpp/include/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @Param[in] graph cuGRAPH graph descriptor, should contain the connectivity information as an edge list (edge weights are not used for this algorithm).
* The transposed adjacency list will be computed if not already present.
* @Param[in] alpha The damping factor alpha represents the probability to follow an outgoing edge, standard value is 0.85.
Thus, 1.0-alpha is the probability to “teleport” to a random node. Alpha should be greater than 0.0 and strictly lower than 1.0.
Thus, 1.0-alpha is the probability to “teleport” to a random vertex. Alpha should be greater than 0.0 and strictly lower than 1.0.
* @Param[in] has_guess This parameter is used to notify cuGRAPH if it should use a user-provided initial guess. False means the user doesn't have a guess, in this case cuGRAPH will use a uniform vector set to 1/V.
* If the value is True, cuGRAPH will read the pagerank parameter and use this as an initial guess.
* The initial guess must not be the vector of 0s. Any value other than 1 or 0 is treated as an invalid value.
Expand Down Expand Up @@ -85,15 +85,15 @@ gdf_error gdf_grmat_gen(const char* argv,
gdf_column* val);

/**
* @Synopsis Performs a breadth first search traversal of a graph starting from a node.
* @Synopsis Performs a breadth first search traversal of a graph starting from a vertex.
*
* @Param[in] *graph cuGRAPH graph descriptor with a valid edgeList or adjList
*
* @Param[out] *distances If set to a valid column, this is populated by distance of every vertex in the graph from the starting node
* @Param[out] *distances If set to a valid column, this is populated by distance of every vertex in the graph from the starting vertex
*
* @Param[out] *predecessors If set to a valid column, this is populated by bfs traversal predecessor of every vertex
*
* @Param[in] start_node The starting node for breadth first search traversal
* @Param[in] start_vertex The starting vertex for breadth first search traversal
*
* @Param[in] directed Treat the input graph as directed
*
Expand All @@ -103,7 +103,7 @@ gdf_error gdf_grmat_gen(const char* argv,
gdf_error gdf_bfs(gdf_graph *graph,
gdf_column *distances,
gdf_column *predecessors,
int start_node,
int start_vertex,
bool directed);

/**
Expand Down
65 changes: 34 additions & 31 deletions cpp/include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,52 +134,55 @@ gdf_error gdf_delete_edge_list(gdf_graph *graph);
gdf_error gdf_delete_transposed_adj_list(gdf_graph *graph);

/**
* @Synopsis Find pairs of vertices in the input graph such that each pair is connected by
* a path that is two hops in length.
* @param graph The input graph
* @param first An uninitialized gdf_column which will be initialized to contain the
* first entry of each result pair.
* @param second An uninitialized gdf_column which will be initialized to contain the
* second entry of each result pair.
* @return GDF_SUCCESS upon successful completion.
* @Synopsis Find pairs of vertices in the input graph such that each pair is connected by
* a path that is two hops in length.
*
* @param[in] *graph in : graph descriptor with graph->adjList pointing to a gdf_adj_list structure
*
* @param[out] first out : An uninitialized gdf_column which will be initialized to contain the
* first entry of each result pair.
* @param[out] second out : An uninitialized gdf_column which will be initialized to contain the
* second entry of each result pair.
*
* @return GDF_SUCCESS upon successful completion.
*/
/* ----------------------------------------------------------------------------*/
gdf_error gdf_get_two_hop_neighbors(gdf_graph* graph, gdf_column* first, gdf_column* second);

/**
* @Synopsis Single node Multi GPU CSR sparse matrix multiply, x=Ax.
Should be called in an omp parallel section with one thread per device.
Each device is expected to have a part of the matrix and a copy of the vector
This function is designed for 1D decomposition. Each partition should have local offsets.
*
* @Param[in] *part_offsets Vertex offsets for each partition. This information should be available on all threads/devices
part_off[device_id] contains the global ID of the first vertex of the partion owned by device_id.
part_off[num_devices] contains the global number of vertices
* @Param[in] off Local adjacency list offsets. Starting at 0. The last element contains the local number of edges owned by the partition.
* @Param[in] ind Local adjacency list indices. Indices are between 0 and the global number of edges.
* @Param[in] val Local adjacency list values. Type should be float or double.
* @Param[in][out] **x_col x[device_id] contains the input vector of the spmv for a device_id. The input should be duplicated on all devices.
Overwritten on output by the result of x = A*x, on all devices.
*
* @Returns GDF_SUCCESS upon successful completion.
* Should be called in an omp parallel section with one thread per device.
* Each device is expected to have a part of the matrix and a copy of the vector
* This function is designed for 1D decomposition. Each partition should have local offsets.
*
* @Param[in] *part_offsets in : Vertex offsets for each partition. This information should be available on all threads/devices
* part_offsets[device_id] contains the global ID of the first vertex of the partion owned by device_id.
* part_offsets[num_devices] contains the global number of vertices
* @Param[in] off in : Local adjacency list offsets. Starting at 0. The last element contains the local number of edges owned by the partition.
* @Param[in] ind in : Local adjacency list indices. Indices are between 0 and the global number of edges.
* @Param[in] val in : Local adjacency list values. Type should be float or double.
*
* @Param[in, out] **x_col in : x[device_id] contains the input vector of the spmv for a device_id. The input should be duplicated on all devices.
* out : Overwritten on output by the result of x = A*x, on all devices.
*
* @Returns GDF_SUCCESS upon successful completion.
*/
/* ----------------------------------------------------------------------------*/
gdf_error gdf_snmg_csrmv (size_t * part_offsets, gdf_column * off, gdf_column * ind, gdf_column * val, gdf_column ** x_col);

/**
* @Synopsis Computes degree(in, out, in+out) of all the nodes of a gdf_graph
*
* @Param[in] *graph graph descriptor with graph->transposedAdjList or graph->adjList present
* @Param[in] x integer value indicating type of degree calculation
* 0 : in+out degree
* 1 : in-degree
* 2 : out-degree
* @Param[out] *degree gdf_column of size V (V is number of vertices) initialized to zeros.
* Contains the computed degree of every vertex.
* @Param[in] *graph in : graph descriptor with graph->transposedAdjList or graph->adjList present
* @Param[in] x in : integer value indicating type of degree calculation
* 0 : in+out degree
* 1 : in-degree
* 2 : out-degree
*
* @Param[out] *degree out : gdf_column of size V (V is number of vertices) initialized to zeros.
* Contains the computed degree of every vertex.
*
* @Returns GDF_SUCCESS upon successful completion.
*/
/* ----------------------------------------------------------------------------*/
gdf_error gdf_degree(gdf_graph *graph, gdf_column *degree, int x);

16 changes: 11 additions & 5 deletions cpp/src/cugraph.cu
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ void cpy_column_view(const gdf_column *in, gdf_column *out) {

gdf_error gdf_adj_list_view(gdf_graph *graph, const gdf_column *offsets,
const gdf_column *indices, const gdf_column *edge_data) {
//This function returns an error if this graph object has at least one graph
//representation to prevent a single object storing two different graphs.
GDF_REQUIRE( ((graph->edgeList == nullptr) && (graph->adjList == nullptr) &&
(graph->transposedAdjList == nullptr)), GDF_INVALID_API_CALL);
GDF_REQUIRE( offsets->null_count == 0 , GDF_VALIDITY_UNSUPPORTED );
GDF_REQUIRE( indices->null_count == 0 , GDF_VALIDITY_UNSUPPORTED );
GDF_REQUIRE( (offsets->dtype == indices->dtype), GDF_UNSUPPORTED_DTYPE );
GDF_REQUIRE( ((offsets->dtype == GDF_INT32) || (offsets->dtype == GDF_INT64)), GDF_UNSUPPORTED_DTYPE );
GDF_REQUIRE( (offsets->size > 0), GDF_DATASET_EMPTY );
GDF_REQUIRE( (graph->adjList == nullptr) , GDF_INVALID_API_CALL);

graph->adjList = new gdf_adj_list;
graph->adjList->offsets = new gdf_column;
Expand Down Expand Up @@ -115,13 +118,16 @@ gdf_error gdf_adj_list::get_source_indices (gdf_column *src_indices) {

gdf_error gdf_edge_list_view(gdf_graph *graph, const gdf_column *src_indices,
const gdf_column *dest_indices, const gdf_column *edge_data) {
//This function returns an error if this graph object has at least one graph
//representation to prevent a single object storing two different graphs.
GDF_REQUIRE( ((graph->edgeList == nullptr) && (graph->adjList == nullptr) &&
(graph->transposedAdjList == nullptr)), GDF_INVALID_API_CALL);
GDF_REQUIRE( src_indices->size == dest_indices->size, GDF_COLUMN_SIZE_MISMATCH );
GDF_REQUIRE( src_indices->dtype == dest_indices->dtype, GDF_UNSUPPORTED_DTYPE );
GDF_REQUIRE( ((src_indices->dtype == GDF_INT32) || (src_indices->dtype == GDF_INT64)), GDF_UNSUPPORTED_DTYPE );
GDF_REQUIRE( src_indices->size > 0, GDF_DATASET_EMPTY );
GDF_REQUIRE( src_indices->null_count == 0 , GDF_VALIDITY_UNSUPPORTED );
GDF_REQUIRE( dest_indices->null_count == 0 , GDF_VALIDITY_UNSUPPORTED );
GDF_REQUIRE( graph->edgeList == nullptr , GDF_INVALID_API_CALL);

graph->edgeList = new gdf_edge_list;
graph->edgeList->src_indices = new gdf_column;
Expand Down Expand Up @@ -280,7 +286,7 @@ gdf_error gdf_degree_impl(int n, int e, gdf_column* col_ptr, gdf_column* degree,


gdf_error gdf_degree(gdf_graph *graph, gdf_column *degree, int x) {
// Calculates the degree of all nodes of the graph
// Calculates the degree of all vertices of the graph
// x = 0: in+out degree
// x = 1: in-degree
// x = 2: out-degree
Expand Down Expand Up @@ -436,7 +442,7 @@ gdf_error gdf_pagerank(gdf_graph *graph, gdf_column *pagerank, float alpha, floa
}
}

gdf_error gdf_bfs(gdf_graph *graph, gdf_column *distances, gdf_column *predecessors, int start_node, bool directed) {
gdf_error gdf_bfs(gdf_graph *graph, gdf_column *distances, gdf_column *predecessors, int start_vertex, bool directed) {
GDF_REQUIRE(graph->adjList != nullptr || graph->edgeList != nullptr, GDF_INVALID_API_CALL);
gdf_error err = gdf_add_adj_list(graph);
if (err != GDF_SUCCESS)
Expand All @@ -457,7 +463,7 @@ gdf_error gdf_bfs(gdf_graph *graph, gdf_column *distances, gdf_column *predecess

cugraph::Bfs<int> bfs(n, e, offsets_ptr, indices_ptr, directed, alpha, beta);
bfs.configure(distances_ptr, predecessors_ptr, nullptr);
bfs.traverse(start_node);
bfs.traverse(start_vertex);
return GDF_SUCCESS;
}

Expand Down
Loading

0 comments on commit 40caa93

Please sign in to comment.