Skip to content

Commit

Permalink
MG Louvain C++ test R-mat usecase parameters (#2061)
Browse files Browse the repository at this point in the history
R-mat usecase parameters weren't set for multi-GPU tests. Fixed in this PR.

Authors:
  - Seunghwa Kang (https://github.com/seunghwak)

Approvers:
  - Chuck Hastings (https://github.com/ChuckHastings)
  - Kumar Aatish (https://github.com/kaatish)

URL: #2061
  • Loading branch information
seunghwak authored Feb 8, 2022
1 parent 1e99895 commit 37b7310
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
6 changes: 5 additions & 1 deletion cpp/src/community/louvain.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -478,6 +478,10 @@ class Louvain {
thrust::make_zip_iterator(thrust::make_tuple(
old_cluster_sum_v.begin(), cluster_subtract_v.begin())),
src_old_cluster_sum_subtract_pairs);
old_cluster_sum_v.resize(0, handle_.get_stream());
old_cluster_sum_v.shrink_to_fit(handle_.get_stream());
cluster_subtract_v.resize(0, handle_.get_stream());
cluster_subtract_v.shrink_to_fit(handle_.get_stream());
}

auto output_buffer = allocate_dataframe_buffer<thrust::tuple<vertex_t, weight_t>>(
Expand Down
45 changes: 36 additions & 9 deletions cpp/tests/community/mg_louvain_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <utilities/base_fixture.hpp>
#include <utilities/device_comm_wrapper.hpp>
#include <utilities/high_res_clock.h>
#include <utilities/test_utilities.hpp>

#include <cugraph/algorithms.hpp>
Expand Down Expand Up @@ -154,35 +155,59 @@ class Tests_MG_Louvain
{
auto [louvain_usecase, input_usecase] = param;

raft::handle_t handle;
raft::handle_t handle{};
HighResClock hr_clock{};

raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD);
const auto& comm = handle.get_comms();

const auto& comm = handle.get_comms();
auto const comm_size = comm.get_size();
auto const comm_rank = comm.get_rank();

auto row_comm_size = static_cast<int>(sqrt(static_cast<double>(comm_size)));
while (comm_size % row_comm_size != 0) {
--row_comm_size;
}

cugraph::partition_2d::subcomm_factory_t<cugraph::partition_2d::key_naming_t, vertex_t>
subcomm_factory(handle, row_comm_size);

cudaStream_t stream = handle.get_stream();
if (cugraph::test::g_perf) {
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
handle.get_comms().barrier();
hr_clock.start();
}

auto [mg_graph, d_renumber_map_labels] =
cugraph::test::construct_graph<vertex_t, edge_t, weight_t, false, true>(
handle, input_usecase, true, true);

if (cugraph::test::g_perf) {
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
handle.get_comms().barrier();
double elapsed_time{0.0};
hr_clock.stop(&elapsed_time);
std::cout << "MG construct_graph took " << elapsed_time * 1e-6 << " s.\n";
}

auto mg_graph_view = mg_graph.view();

std::unique_ptr<cugraph::Dendrogram<vertex_t>> dendrogram;
weight_t mg_modularity;
if (cugraph::test::g_perf) {
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
handle.get_comms().barrier();
hr_clock.start();
}

std::tie(dendrogram, mg_modularity) = cugraph::louvain(
auto [dendrogram, mg_modularity] = cugraph::louvain(
handle, mg_graph_view, louvain_usecase.max_level_, louvain_usecase.resolution_);

if (cugraph::test::g_perf) {
RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement
handle.get_comms().barrier();
double elapsed_time{0.0};
hr_clock.stop(&elapsed_time);
std::cout << "MG Louvain took " << elapsed_time * 1e-6 << " s.\n";
}

if (louvain_usecase.check_correctness_) {
SCOPED_TRACE("compare modularity input");

Expand Down Expand Up @@ -281,7 +306,8 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Combine(
// disable correctness checks for large graphs
::testing::Values(Louvain_Usecase{}),
::testing::Values(cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, true, false))));
::testing::Values(
cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, true, false, 0, true))));

INSTANTIATE_TEST_SUITE_P(
rmat64_benchmark_test, /* note that scale & edge factor can be overridden in benchmarking (with
Expand All @@ -293,6 +319,7 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Combine(
// disable correctness checks for large graphs
::testing::Values(Louvain_Usecase{}),
::testing::Values(cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, true, false))));
::testing::Values(
cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, true, false, 0, true))));

CUGRAPH_MG_TEST_PROGRAM_MAIN()

0 comments on commit 37b7310

Please sign in to comment.