Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] Reorganized cugraph source directory #286

Merged
merged 19 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


## Improvements
- PR #286 Reorganized cugraph source directory


## Bug Fixes
Expand Down
22 changes: 14 additions & 8 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,20 @@ link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT
###################################################################################################
# - library targets -------------------------------------------------------------------------------
add_library(cugraph SHARED
src/grmat.cu
src/cugraph.cu
src/pagerank.cu
src/bfs.cu
src/jaccard.cu
src/overlap.cu
src/nvgraph_gdf.cu
src/two_hop_neighbors.cu
src/traversal/bfs.cu
src/traversal/nvgraph_sssp.cu
src/traversal/two_hop_neighbors.cu
src/link_analysis/pagerank.cu
src/link_prediction/jaccard.cu
src/link_prediction/overlap.cu
src/structure/cugraph.cu
src/snmg/blas/snmg_csrmv.cu
src/community/louvain.cu
src/community/nvgraph_community.cu
src/converters/nvgraph.cu
src/converters/renumber.cu
src/utilities/degree.cu
src/utilities/grmat.cu
${CMAKE_CURRENT_BINARY_DIR}/gunrock/gunrock/util/test_utils.cu
${CMAKE_CURRENT_BINARY_DIR}/gunrock/gunrock/util/error_utils.cu
${CMAKE_CURRENT_BINARY_DIR}/gunrock/gunrock/util/misc_utils.cu
Expand Down
14 changes: 0 additions & 14 deletions cpp/include/nvgraph_gdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,8 @@

#pragma once

//#include <nvgraph/nvgraph.h>
#include <cugraph.h>

/**
* Takes a GDF graph and wraps its data with an Nvgraph graph object.
* @param nvg_handle The Nvgraph handle
* @param gdf_G Pointer to GDF graph object
* @param nvgraph_G Pointer to the Nvgraph graph descriptor
* @param use_transposed True if we are transposing the input graph while wrapping
* @return Error code
*/
//gdf_error gdf_createGraph_nvgraph(nvgraphHandle_t nvg_handle,
// gdf_graph* gdf_G,
// nvgraphGraphDescr_t * nvgraph_G,
// bool use_transposed = false);

/**
* Wrapper function for Nvgraph SSSP algorithm
* @param gdf_G Pointer to GDF graph object
Expand Down
65 changes: 65 additions & 0 deletions cpp/src/community/louvain.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*
*/

#include <cugraph.h>
#include <nvgraph/nvgraph.h>
#include "utilities/error_utils.h"
#include <rmm_utils.h>

template<typename T>
using Vector = thrust::device_vector<T, rmm_allocator<T>>;

gdf_error gdf_louvain(gdf_graph *graph, void *final_modularity, void *num_level, gdf_column *louvain_parts) {
GDF_REQUIRE(graph->adjList != nullptr || graph->edgeList != nullptr, GDF_INVALID_API_CALL);
gdf_error err = gdf_add_adj_list(graph);
if (err != GDF_SUCCESS)
return err;

size_t n = graph->adjList->offsets->size - 1;
size_t e = graph->adjList->indices->size;

void* offsets_ptr = graph->adjList->offsets->data;
void* indices_ptr = graph->adjList->indices->data;

void* value_ptr;
Vector<float> d_values;
if(graph->adjList->edge_data) {
value_ptr = graph->adjList->edge_data->data;
}
else {
cudaStream_t stream { nullptr };
rmm_temp_allocator allocator(stream);
d_values.resize(graph->adjList->indices->size);
thrust::fill(thrust::cuda::par(allocator).on(stream), d_values.begin(), d_values.end(), 1.0);
value_ptr = (void * ) thrust::raw_pointer_cast(d_values.data());
}

void* louvain_parts_ptr = louvain_parts->data;

auto gdf_to_cudadtype= [](gdf_column *col){
cudaDataType_t cuda_dtype;
switch(col->dtype){
case GDF_INT8: cuda_dtype = CUDA_R_8I; break;
case GDF_INT32: cuda_dtype = CUDA_R_32I; break;
case GDF_FLOAT32: cuda_dtype = CUDA_R_32F; break;
case GDF_FLOAT64: cuda_dtype = CUDA_R_64F; break;
default: throw new std::invalid_argument("Cannot convert data type");
}return cuda_dtype;
};

cudaDataType_t index_type = gdf_to_cudadtype(graph->adjList->indices);
cudaDataType_t val_type = graph->adjList->edge_data? gdf_to_cudadtype(graph->adjList->edge_data): CUDA_R_32F;

nvgraphLouvain(index_type, val_type, n, e, offsets_ptr, indices_ptr, value_ptr, 1, 0, NULL,
final_modularity, louvain_parts_ptr, num_level);
return GDF_SUCCESS;
}

Loading