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

Transform Reduce E test #1798

Merged
merged 5 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 cpp/include/cugraph/prims/transform_reduce_e.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <cugraph/prims/property_op_utils.cuh>
#include <cugraph/utilities/error.hpp>
#include <cugraph/utilities/host_scalar_comm.cuh>
#include <cugraph/matrix_partition_view.hpp>

#include <raft/cudart_utils.h>
#include <raft/handle.hpp>
Expand Down
4 changes: 4 additions & 0 deletions cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ if(BUILD_CUGRAPH_MG_TESTS)
###########################################################################################
# - MG PRIMS TRANSFORM_REDUCE_V tests -----------------------------------------------------
ConfigureTestMG(MG_TRANSFORM_REDUCE_V_TEST prims/mg_transform_reduce_v.cu)

###########################################################################################
# - MG PRIMS TRANSFORM_REDUCE_E tests -----------------------------------------------------
ConfigureTestMG(MG_TRANSFORM_REDUCE_E_TEST prims/mg_transform_reduce_e.cu)
else()
message(FATAL_ERROR "OpenMPI NOT found, cannot build MG tests.")
endif()
Expand Down
29 changes: 16 additions & 13 deletions cpp/tests/community/mg_louvain_helper.cu
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ template <typename vertex_t, typename edge_t, typename weight_t>
std::tuple<rmm::device_uvector<vertex_t>,
rmm::device_uvector<vertex_t>,
std::optional<rmm::device_uvector<weight_t>>>
compressed_sparse_to_edgelist(edge_t const* compressed_sparse_offsets,
compressed_sparse_to_edgelist(raft::handle_t const& handle,
edge_t const* compressed_sparse_offsets,
kaatish marked this conversation as resolved.
Show resolved Hide resolved
vertex_t const* compressed_sparse_indices,
std::optional<weight_t const*> compressed_sparse_weights,
vertex_t major_first,
vertex_t major_last,
cudaStream_t stream)
vertex_t major_last)
{
cudaStream_t stream = handle.get_stream();
edge_t number_of_edges{0};
raft::update_host(
&number_of_edges, compressed_sparse_offsets + (major_last - major_first), 1, stream);
Expand Down Expand Up @@ -114,11 +115,12 @@ compressed_sparse_to_edgelist(edge_t const* compressed_sparse_offsets,

template <typename vertex_t, typename weight_t>
void sort_and_coarsen_edgelist(
raft::handle_t const& handle,
rmm::device_uvector<vertex_t>& edgelist_major_vertices /* [INOUT] */,
rmm::device_uvector<vertex_t>& edgelist_minor_vertices /* [INOUT] */,
std::optional<rmm::device_uvector<weight_t>>& edgelist_weights /* [INOUT] */,
cudaStream_t stream)
std::optional<rmm::device_uvector<weight_t>>& edgelist_weights /* [INOUT] */)
{
cudaStream_t stream = handle.get_stream();
auto pair_first = thrust::make_zip_iterator(
thrust::make_tuple(edgelist_major_vertices.begin(), edgelist_minor_vertices.begin()));

Expand Down Expand Up @@ -171,6 +173,7 @@ std::tuple<rmm::device_uvector<vertex_t>,
rmm::device_uvector<vertex_t>,
std::optional<rmm::device_uvector<weight_t>>>
compressed_sparse_to_relabeled_and_sorted_and_coarsened_edgelist(
raft::handle_t const& handle,
edge_t const* compressed_sparse_offsets,
vertex_t const* compressed_sparse_indices,
std::optional<weight_t const*> compressed_sparse_weights,
Expand All @@ -179,19 +182,19 @@ compressed_sparse_to_relabeled_and_sorted_and_coarsened_edgelist(
vertex_t major_first,
vertex_t major_last,
vertex_t minor_first,
vertex_t minor_last,
cudaStream_t stream)
vertex_t minor_last)
{
cudaStream_t stream = handle.get_stream();
// FIXME: it might be possible to directly create relabled & coarsened edgelist from the
// compressed sparse format to save memory

auto [edgelist_major_vertices, edgelist_minor_vertices, edgelist_weights] =
compressed_sparse_to_edgelist(compressed_sparse_offsets,
compressed_sparse_to_edgelist(handle,
compressed_sparse_offsets,
compressed_sparse_indices,
compressed_sparse_weights,
major_first,
major_last,
stream);
major_last);

auto pair_first = thrust::make_zip_iterator(
thrust::make_tuple(edgelist_major_vertices.begin(), edgelist_minor_vertices.begin()));
Expand All @@ -206,7 +209,7 @@ compressed_sparse_to_relabeled_and_sorted_and_coarsened_edgelist(
});

sort_and_coarsen_edgelist(
edgelist_major_vertices, edgelist_minor_vertices, edgelist_weights, stream);
handle, edgelist_major_vertices, edgelist_minor_vertices, edgelist_weights);

return std::make_tuple(std::move(edgelist_major_vertices),
std::move(edgelist_minor_vertices),
Expand All @@ -226,6 +229,7 @@ coarsen_graph(
coarsened_edgelist_minor_vertices,
coarsened_edgelist_weights] =
compressed_sparse_to_relabeled_and_sorted_and_coarsened_edgelist(
handle,
graph_view.get_matrix_partition_view().get_offsets(),
graph_view.get_matrix_partition_view().get_indices(),
graph_view.get_matrix_partition_view().get_weights(),
Expand All @@ -234,8 +238,7 @@ coarsen_graph(
vertex_t{0},
graph_view.get_number_of_vertices(),
vertex_t{0},
graph_view.get_number_of_vertices(),
handle.get_stream());
graph_view.get_number_of_vertices());

cugraph::edgelist_t<vertex_t, edge_t, weight_t> edgelist{};
edgelist.p_src_vertices = store_transposed ? coarsened_edgelist_minor_vertices.data()
Expand Down
1 change: 1 addition & 0 deletions cpp/tests/community/mg_louvain_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <raft/handle.hpp>

#include <thrust/sequence.h>
#include <thrust/execution_policy.h>

kaatish marked this conversation as resolved.
Show resolved Hide resolved
#include <gtest/gtest.h>

Expand Down
Loading