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

Fix MG Louvain test compile errors #1797

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 8 additions & 10 deletions cpp/tests/community/mg_louvain_helper.cu
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ compressed_sparse_to_edgelist(edge_t const* compressed_sparse_offsets,
// FIXME: this is highly inefficient for very high-degree vertices, for better performance, we can
// fill high-degree vertices using one CUDA block per vertex, mid-degree vertices using one CUDA
// warp per vertex, and low-degree vertices using one CUDA thread per block
auto execution_policy = handle.get_thrust_policy();
thrust::for_each(execution_policy,
thrust::for_each(rmm::exec_policy(stream),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this was missed because CI doesn't compile MG analytics.

Would it be better to change the function signature to pass in handle? That would make it more consistent with the rest of the code base.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaatish addressed this in #1798 by changing the function signature. We should decide which is better and be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to change the function signature to pass in handle? That would make it more consistent with the rest of the code base.

Ideally, this code should be deleted as this file is pretty much copy-and-paste (plus little modification) of https://github.com/rapidsai/cugraph/blob/branch-21.10/cpp/src/structure/coarsen_graph.cu

The reason this function is designed to take stream instead of handle is to facilitate multi-stream execution. Different matrix partitions can be concurrently executed in multiple CUDA streams and such functions take stream instead of handle (another approach might be passing handle + stream index if we see multiple cases using other handle features).

thrust::make_counting_iterator(major_first),
thrust::make_counting_iterator(major_last),
[compressed_sparse_offsets,
Expand All @@ -96,12 +95,12 @@ compressed_sparse_to_edgelist(edge_t const* compressed_sparse_offsets,
auto last = compressed_sparse_offsets[v - major_first + 1];
thrust::fill(thrust::seq, p_majors + first, p_majors + last, v);
});
thrust::copy(execution_policy,
thrust::copy(rmm::exec_policy(stream),
compressed_sparse_indices,
compressed_sparse_indices + number_of_edges,
edgelist_minor_vertices.begin());
if (compressed_sparse_weights) {
thrust::copy(execution_policy,
thrust::copy(rmm::exec_policy(stream),
(*compressed_sparse_weights),
(*compressed_sparse_weights) + number_of_edges,
(*edgelist_weights).data());
Expand All @@ -124,9 +123,8 @@ void sort_and_coarsen_edgelist(

size_t number_of_edges{0};

auto execution_policy = handle.get_thrust_policy();
if (edgelist_weights) {
thrust::sort_by_key(execution_policy,
thrust::sort_by_key(rmm::exec_policy(stream),
pair_first,
pair_first + edgelist_major_vertices.size(),
(*edgelist_weights).begin());
Expand All @@ -137,7 +135,7 @@ void sort_and_coarsen_edgelist(
stream);
rmm::device_uvector<weight_t> tmp_edgelist_weights(tmp_edgelist_major_vertices.size(), stream);
auto it = thrust::reduce_by_key(
execution_policy,
rmm::exec_policy(stream),
pair_first,
pair_first + edgelist_major_vertices.size(),
(*edgelist_weights).begin(),
Expand All @@ -150,9 +148,9 @@ void sort_and_coarsen_edgelist(
edgelist_minor_vertices = std::move(tmp_edgelist_minor_vertices);
(*edgelist_weights) = std::move(tmp_edgelist_weights);
} else {
thrust::sort(execution_policy, pair_first, pair_first + edgelist_major_vertices.size());
auto it =
thrust::unique(execution_policy, pair_first, pair_first + edgelist_major_vertices.size());
thrust::sort(rmm::exec_policy(stream), pair_first, pair_first + edgelist_major_vertices.size());
auto it = thrust::unique(
rmm::exec_policy(stream), pair_first, pair_first + edgelist_major_vertices.size());
number_of_edges = thrust::distance(pair_first, it);
}

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 @@ -29,6 +29,7 @@
#include <raft/comms/mpi_comms.hpp>
#include <raft/handle.hpp>

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

#include <gtest/gtest.h>
Expand Down