From 830d1139895ab6ce7c6077642f95a5abb8b64977 Mon Sep 17 00:00:00 2001 From: Seunghwa Kang <45857425+seunghwak@users.noreply.github.com> Date: Wed, 27 Jul 2022 08:04:58 -0700 Subject: [PATCH] Refactor MG C++ tests (handle initialization) (#2439) Update MG C++ tests to initialize a RAFT handle_t object in SetUpTestCase(). Previously, a handle_t object is initialized inside individual tests. If an exception is thrown inside a single test, a stack unwinding process starts, and this calls handle_t's destructor, and the destructor invokes ncclCommDestroy(). If only a subset of workers fail, some processes will still advance and can be blocked on a NCCL call, This bars ncclCommDestroy() from finishing, and the stack unwinding process will hang. The outcome is no output in the console and testers may have no clue that exceptions are thrown. With this restructuring, exceptions in individual tests will not destroy a handle_t object, so testers will see the exception messages. Authors: - Seunghwa Kang (https://github.com/seunghwak) Approvers: - Chuck Hastings (https://github.com/ChuckHastings) - Kumar Aatish (https://github.com/kaatish) - Joseph Nke (https://github.com/jnke2016) URL: https://github.com/rapidsai/cugraph/pull/2439 --- cpp/include/cugraph/partition_manager.hpp | 10 +- cpp/src/utilities/cython.cu | 4 +- cpp/tests/CMakeLists.txt | 4 +- cpp/tests/bcast/mg_graph_bcast.cpp | 40 ++-- cpp/tests/c_api/mg_test_utils.cpp | 4 +- .../eigenvector_centrality_test.cpp | 3 +- cpp/tests/centrality/katz_centrality_test.cpp | 3 +- .../legacy/betweenness_centrality_test.cu | 4 +- .../edge_betweenness_centrality_test.cu | 4 +- .../centrality/legacy/katz_centrality_test.cu | 4 +- .../mg_eigenvector_centrality_test.cpp | 80 ++++---- .../centrality/mg_katz_centrality_test.cpp | 84 ++++---- cpp/tests/community/egonet_test.cu | 3 +- cpp/tests/community/induced_subgraph_test.cpp | 3 +- cpp/tests/community/louvain_test.cpp | 3 +- cpp/tests/community/mg_louvain_test.cpp | 82 ++++---- .../community/mg_triangle_count_test.cpp | 97 ++++----- cpp/tests/community/triangle_count_test.cpp | 3 +- cpp/tests/components/con_comp_test.cu | 3 +- .../mg_weakly_connected_components_test.cpp | 81 ++++---- cpp/tests/components/scc_test.cu | 4 +- cpp/tests/components/wcc_test.cpp | 3 +- .../weakly_connected_components_test.cpp | 3 +- cpp/tests/cores/core_number_test.cpp | 3 +- cpp/tests/cores/mg_core_number_test.cpp | 80 ++++---- cpp/tests/generators/generate_rmat_test.cpp | 6 +- cpp/tests/layout/force_atlas2_test.cu | 3 +- cpp/tests/link_analysis/hits_test.cpp | 3 +- cpp/tests/link_analysis/mg_hits_test.cpp | 108 +++++----- cpp/tests/link_analysis/mg_pagerank_test.cpp | 116 +++++------ cpp/tests/link_analysis/pagerank_test.cpp | 3 +- cpp/tests/prims/mg_count_if_e.cu | 94 ++++----- cpp/tests/prims/mg_count_if_v.cu | 82 ++++---- cpp/tests/prims/mg_extract_if_e.cu | 150 +++++++------- ..._v_transform_reduce_incoming_outgoing_e.cu | 129 ++++++------ cpp/tests/prims/mg_reduce_v.cu | 103 +++++----- cpp/tests/prims/mg_transform_reduce_e.cu | 94 ++++----- cpp/tests/prims/mg_transform_reduce_v.cu | 90 ++++---- ...orm_reduce_v_frontier_outgoing_e_by_dst.cu | 193 +++++++++--------- .../sampling/detail/mg_gather_one_hop.cu | 92 ++++----- cpp/tests/sampling/detail/mg_gather_utils.cu | 95 ++++----- cpp/tests/sampling/detail/mg_nbr_sampling.cu | 83 ++++---- cpp/tests/sampling/mg_random_walks_test.cu | 52 +++-- .../sampling/mg_uniform_neighbor_sampling.cu | 123 ++++++----- cpp/tests/sampling/random_walks_test.cu | 3 +- .../sampling/sg_uniform_neighbor_sampling.cu | 3 +- cpp/tests/structure/coarsen_graph_test.cpp | 3 +- .../count_self_loops_and_multi_edges_test.cpp | 3 +- cpp/tests/structure/degree_test.cpp | 3 +- cpp/tests/structure/graph_test.cpp | 3 +- ..._count_self_loops_and_multi_edges_test.cpp | 67 +++--- cpp/tests/structure/mg_symmetrize_test.cpp | 88 ++++---- .../structure/mg_transpose_storage_test.cpp | 87 ++++---- cpp/tests/structure/mg_transpose_test.cpp | 88 ++++---- cpp/tests/structure/renumbering_test.cpp | 3 +- cpp/tests/structure/symmetrize_test.cpp | 3 +- .../structure/transpose_storage_test.cpp | 3 +- cpp/tests/structure/transpose_test.cpp | 3 +- cpp/tests/structure/weight_sum_test.cpp | 3 +- cpp/tests/traversal/bfs_test.cpp | 3 +- cpp/tests/traversal/extract_bfs_paths_test.cu | 3 +- cpp/tests/traversal/legacy/bfs_test.cu | 3 +- cpp/tests/traversal/legacy/sssp_test.cu | 4 +- cpp/tests/traversal/mg_bfs_test.cpp | 111 +++++----- .../traversal/mg_extract_bfs_paths_test.cu | 136 ++++++------ cpp/tests/traversal/mg_sssp_test.cpp | 107 +++++----- cpp/tests/traversal/ms_bfs_test.cu | 3 +- cpp/tests/traversal/sssp_test.cpp | 3 +- cpp/tests/tree/mst_test.cu | 4 +- cpp/tests/utilities/base_fixture.hpp | 14 +- cpp/tests/utilities/mg_utilities.cpp | 101 +++++++++ cpp/tests/utilities/mg_utilities.hpp | 39 ++++ cpp/tests/utilities/misc_utilities.cpp | 36 +--- cpp/tests/utilities/test_utilities.hpp | 4 - 74 files changed, 1575 insertions(+), 1590 deletions(-) create mode 100644 cpp/tests/utilities/mg_utilities.cpp create mode 100644 cpp/tests/utilities/mg_utilities.hpp diff --git a/cpp/include/cugraph/partition_manager.hpp b/cpp/include/cugraph/partition_manager.hpp index c7657d459b2..0673ab095d7 100644 --- a/cpp/include/cugraph/partition_manager.hpp +++ b/cpp/include/cugraph/partition_manager.hpp @@ -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. @@ -65,11 +65,10 @@ using pair_comms_t = // naming policy defaults to simplified naming: // one key per row subcomms, one per column subcomms; // -template +template class subcomm_factory_t { public: - subcomm_factory_t(raft::handle_t& handle, size_type row_size) - : handle_(handle), row_size_(row_size) + subcomm_factory_t(raft::handle_t& handle, int row_size) : handle_(handle), row_size_(row_size) { init_row_col_comms(); } @@ -101,8 +100,9 @@ class subcomm_factory_t { private: raft::handle_t& handle_; - size_type row_size_; + int row_size_; pair_comms_t row_col_subcomms_; }; + } // namespace partition_2d } // namespace cugraph diff --git a/cpp/src/utilities/cython.cu b/cpp/src/utilities/cython.cu index 161552374e0..fb6ef6cfb73 100644 --- a/cpp/src/utilities/cython.cu +++ b/cpp/src/utilities/cython.cu @@ -1065,8 +1065,8 @@ std::unique_ptr> call_renumber( // Helper for setting up subcommunicators void init_subcomms(raft::handle_t& handle, size_t row_comm_size) { - partition_2d::subcomm_factory_t subcomm_factory(handle, - row_comm_size); + partition_2d::subcomm_factory_t subcomm_factory(handle, + row_comm_size); } // Explicit instantiations diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index dc7a95e113b..24c20a11d18 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -49,7 +49,8 @@ target_link_libraries(cugraphtestutil add_library(cugraphmgtestutil STATIC - utilities/device_comm_wrapper.cu) + utilities/device_comm_wrapper.cu + utilities/mg_utilities.cpp) set_property(TARGET cugraphmgtestutil PROPERTY POSITION_INDEPENDENT_CODE ON) @@ -64,6 +65,7 @@ target_link_libraries(cugraphmgtestutil PUBLIC cugraph::cugraph NCCL::NCCL + MPI::MPI_CXX ) ################################################################################################### diff --git a/cpp/tests/bcast/mg_graph_bcast.cpp b/cpp/tests/bcast/mg_graph_bcast.cpp index 0eadedf808b..df4a27c97b1 100644 --- a/cpp/tests/bcast/mg_graph_bcast.cpp +++ b/cpp/tests/bcast/mg_graph_bcast.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -18,6 +18,7 @@ // #include #include +#include #include #include @@ -59,10 +60,11 @@ struct GraphBcast_Usecase { // test. In this case, each test is identical except for the inputs and // expected outputs, so the entire test is defined in the run_test() method. // -class GraphBcast_MG_Testfixture : public ::testing::TestWithParam { +class Tests_MGGraphBcast : public ::testing::TestWithParam { public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } // Run once for each test instance // @@ -76,42 +78,36 @@ class GraphBcast_MG_Testfixture : public ::testing::TestWithParam void run_test(const GraphBcast_Usecase& param) { - using namespace cugraph::broadcast; using sg_graph_t = cugraph::graph_t; - raft::handle_t handle; - - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - const auto& comm = handle.get_comms(); - - auto const comm_rank = comm.get_rank(); - auto [sg_graph, d_renumber_map_labels] = cugraph::test::read_graph_from_matrix_market_file( - handle, param.graph_file_full_path, true, /*renumber=*/false); + *handle_, param.graph_file_full_path, true, /*renumber=*/false); - if (comm_rank == 0) { - graph_broadcast(handle, &sg_graph); + if (handle_->get_comms().get_rank() == 0) { + cugraph::broadcast::graph_broadcast(*handle_, &sg_graph); } else { sg_graph_t* g_ignore{nullptr}; - auto graph_copy = graph_broadcast(handle, g_ignore); - auto [same, str_fail] = cugraph::test::compare_graphs(handle, sg_graph, graph_copy); + auto graph_copy = cugraph::broadcast::graph_broadcast(*handle_, g_ignore); + auto [same, str_fail] = cugraph::test::compare_graphs(*handle_, sg_graph, graph_copy); if (!same) std::cerr << "Graph comparison failed on " << str_fail << '\n'; ASSERT_TRUE(same); } } + + private: + static std::unique_ptr handle_; }; +std::unique_ptr Tests_MGGraphBcast::handle_ = nullptr; + //////////////////////////////////////////////////////////////////////////////// -TEST_P(GraphBcast_MG_Testfixture, CheckInt32Int32Float) -{ - run_test(GetParam()); -} +TEST_P(Tests_MGGraphBcast, CheckInt32Int32Float) { run_test(GetParam()); } INSTANTIATE_TEST_SUITE_P(simple_test, - GraphBcast_MG_Testfixture, + Tests_MGGraphBcast, ::testing::Values(GraphBcast_Usecase("test/datasets/karate.mtx") //,GraphBcast_Usecase("test/datasets/smallworld.mtx") )); diff --git a/cpp/tests/c_api/mg_test_utils.cpp b/cpp/tests/c_api/mg_test_utils.cpp index 98bea41f1b7..a55339cb990 100644 --- a/cpp/tests/c_api/mg_test_utils.cpp +++ b/cpp/tests/c_api/mg_test_utils.cpp @@ -80,8 +80,8 @@ extern "C" void* create_raft_handle(int prows) raft::handle_t* handle = new raft::handle_t{}; raft::comms::initialize_mpi_comms(handle, MPI_COMM_WORLD); - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(*handle, prows); + cugraph::partition_2d::subcomm_factory_t subcomm_factory( + *handle, prows); return handle; } diff --git a/cpp/tests/centrality/eigenvector_centrality_test.cpp b/cpp/tests/centrality/eigenvector_centrality_test.cpp index a212baf8e0f..336755269d6 100644 --- a/cpp/tests/centrality/eigenvector_centrality_test.cpp +++ b/cpp/tests/centrality/eigenvector_centrality_test.cpp @@ -106,7 +106,8 @@ class Tests_EigenvectorCentrality : public ::testing::TestWithParam> { public: Tests_EigenvectorCentrality() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/centrality/katz_centrality_test.cpp b/cpp/tests/centrality/katz_centrality_test.cpp index dc3a68269da..72e1801c10c 100644 --- a/cpp/tests/centrality/katz_centrality_test.cpp +++ b/cpp/tests/centrality/katz_centrality_test.cpp @@ -102,7 +102,8 @@ class Tests_KatzCentrality : public ::testing::TestWithParam> { public: Tests_KatzCentrality() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/centrality/legacy/betweenness_centrality_test.cu b/cpp/tests/centrality/legacy/betweenness_centrality_test.cu index 19b0d1386b8..9c0fcb41a9d 100644 --- a/cpp/tests/centrality/legacy/betweenness_centrality_test.cu +++ b/cpp/tests/centrality/legacy/betweenness_centrality_test.cu @@ -303,11 +303,13 @@ class Tests_BC : public ::testing::TestWithParam { public: Tests_BC() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} virtual void TearDown() {} + // vertex_t vertex identifier data type // edge_t edge identifier data type // weight_t edge weight data type diff --git a/cpp/tests/centrality/legacy/edge_betweenness_centrality_test.cu b/cpp/tests/centrality/legacy/edge_betweenness_centrality_test.cu index 668c2cec784..2564169ef8a 100644 --- a/cpp/tests/centrality/legacy/edge_betweenness_centrality_test.cu +++ b/cpp/tests/centrality/legacy/edge_betweenness_centrality_test.cu @@ -230,11 +230,13 @@ class Tests_EdgeBC : public ::testing::TestWithParam { public: Tests_EdgeBC() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} virtual void TearDown() {} + // FIXME: Should normalize be part of the configuration instead? // vertex_t vertex identifier data type // edge_t edge identifier data type diff --git a/cpp/tests/centrality/legacy/katz_centrality_test.cu b/cpp/tests/centrality/legacy/katz_centrality_test.cu index aadb99a1ad3..c2565d34fd0 100644 --- a/cpp/tests/centrality/legacy/katz_centrality_test.cu +++ b/cpp/tests/centrality/legacy/katz_centrality_test.cu @@ -105,8 +105,10 @@ typedef struct Katz_Usecase_t { class Tests_Katz : public ::testing::TestWithParam { public: Tests_Katz() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} + virtual void SetUp() {} virtual void TearDown() {} diff --git a/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp b/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp index 649120d2ebc..a06149b1dbd 100644 --- a/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp +++ b/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -45,8 +46,10 @@ class Tests_MGEigenvectorCentrality : public ::testing::TestWithParam> { public: Tests_MGEigenvectorCentrality() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -57,38 +60,23 @@ class Tests_MGEigenvectorCentrality void run_current_test(EigenvectorCentrality_Usecase const& eigenvector_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, eigenvector_usecase.test_weighted, true); + *handle_, input_usecase, eigenvector_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -96,21 +84,21 @@ class Tests_MGEigenvectorCentrality auto mg_graph_view = mg_graph.view(); - // 3. run MG Eigenvector Centrality + // 2. run MG Eigenvector Centrality weight_t constexpr epsilon{1e-6}; rmm::device_uvector d_mg_centralities( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } d_mg_centralities = cugraph::eigenvector_centrality( - handle, + *handle_, mg_graph_view, std::optional>{}, // std::make_optional(raft::device_spanget_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG Eigenvector Centrality took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. compare SG & MG results + // 3. compare SG & MG results if (eigenvector_usecase.check_correctness) { - // 4-1. aggregate MG results + // 3-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_centralities = - cugraph::test::device_gatherv(handle, d_mg_centralities.data(), d_mg_centralities.size()); + cugraph::test::device_gatherv(*handle_, d_mg_centralities.data(), d_mg_centralities.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 4-2. Sort MG results by original vertex id + if (handle_->get_comms().get_rank() == int{0}) { + // 3-2. Sort MG results by original vertex id std::tie(std::ignore, d_mg_aggregate_centralities) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_centralities); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_centralities); - // 4-3. create SG graph + // 3-3. create SG graph auto [sg_graph, d_sg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, eigenvector_usecase.test_weighted, true); + *handle_, input_usecase, eigenvector_usecase.test_weighted, true); auto sg_graph_view = sg_graph.view(); ASSERT_TRUE(mg_graph_view.number_of_vertices() == sg_graph_view.number_of_vertices()); - // 4-4. run SG Eigenvector Centrality + // 3-4. run SG Eigenvector Centrality rmm::device_uvector d_sg_centralities(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); d_sg_centralities = cugraph::eigenvector_centrality( - handle, + *handle_, sg_graph_view, std::optional>{}, // std::make_optional(raft::device_span{d_sg_centralities.data(), @@ -166,22 +154,22 @@ class Tests_MGEigenvectorCentrality false); std::tie(std::ignore, d_sg_centralities) = - cugraph::test::sort_by_key(handle, *d_sg_renumber_map_labels, d_sg_centralities); + cugraph::test::sort_by_key(*handle_, *d_sg_renumber_map_labels, d_sg_centralities); - // 4-5. compare + // 3-5. compare std::vector h_mg_aggregate_centralities(mg_graph_view.number_of_vertices()); raft::update_host(h_mg_aggregate_centralities.data(), d_mg_aggregate_centralities.data(), d_mg_aggregate_centralities.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_centralities(sg_graph_view.number_of_vertices()); raft::update_host(h_sg_centralities.data(), d_sg_centralities.data(), d_sg_centralities.size(), - handle.get_stream()); + handle_->get_stream()); - handle.sync_stream(); + handle_->sync_stream(); auto max_centrality = *std::max_element(h_mg_aggregate_centralities.begin(), h_mg_aggregate_centralities.end()); @@ -212,8 +200,14 @@ class Tests_MGEigenvectorCentrality } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGEigenvectorCentrality::handle_ = nullptr; + using Tests_MGEigenvectorCentrality_File = Tests_MGEigenvectorCentrality; using Tests_MGEigenvectorCentrality_Rmat = diff --git a/cpp/tests/centrality/mg_katz_centrality_test.cpp b/cpp/tests/centrality/mg_katz_centrality_test.cpp index 5826d852f16..2c7cf0aa053 100644 --- a/cpp/tests/centrality/mg_katz_centrality_test.cpp +++ b/cpp/tests/centrality/mg_katz_centrality_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -44,8 +45,10 @@ class Tests_MGKatzCentrality : public ::testing::TestWithParam> { public: Tests_MGKatzCentrality() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -55,38 +58,23 @@ class Tests_MGKatzCentrality void run_current_test(KatzCentrality_Usecase const& katz_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, katz_usecase.test_weighted, true); + *handle_, input_usecase, katz_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -94,26 +82,26 @@ class Tests_MGKatzCentrality auto mg_graph_view = mg_graph.view(); - // 3. compute max in-degree + // 2. compute max in-degree - auto max_in_degree = mg_graph_view.compute_max_in_degree(handle); + auto max_in_degree = mg_graph_view.compute_max_in_degree(*handle_); - // 4. run MG Katz Centrality + // 3. run MG Katz Centrality result_t const alpha = result_t{1.0} / static_cast(max_in_degree + 1); result_t constexpr beta{1.0}; result_t constexpr epsilon{1e-6}; rmm::device_uvector d_mg_katz_centralities( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - cugraph::katz_centrality(handle, + cugraph::katz_centrality(*handle_, mg_graph_view, static_cast(nullptr), d_mg_katz_centralities.data(), @@ -125,45 +113,45 @@ class Tests_MGKatzCentrality if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG Katz Centrality took " << elapsed_time * 1e-6 << " s.\n"; } - // 5. copmare SG & MG results + // 4. copmare SG & MG results if (katz_usecase.check_correctness) { - // 5-1. aggregate MG results + // 4-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_katz_centralities = cugraph::test::device_gatherv( - handle, d_mg_katz_centralities.data(), d_mg_katz_centralities.size()); + *handle_, d_mg_katz_centralities.data(), d_mg_katz_centralities.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 5-2. unrenumbr MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 4-2. unrenumbr MG results std::tie(std::ignore, d_mg_aggregate_katz_centralities) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_katz_centralities); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_katz_centralities); - // 5-3. create SG graph + // 4-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, katz_usecase.test_weighted, false); + *handle_, input_usecase, katz_usecase.test_weighted, false); auto sg_graph_view = sg_graph.view(); ASSERT_TRUE(mg_graph_view.number_of_vertices() == sg_graph_view.number_of_vertices()); - // 5-4. run SG Katz Centrality + // 4-4. run SG Katz Centrality rmm::device_uvector d_sg_katz_centralities(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); - cugraph::katz_centrality(handle, + cugraph::katz_centrality(*handle_, sg_graph_view, static_cast(nullptr), d_sg_katz_centralities.data(), @@ -173,21 +161,21 @@ class Tests_MGKatzCentrality std::numeric_limits::max(), // max_iterations false); - // 5-5. compare + // 4-5. compare std::vector h_mg_aggregate_katz_centralities(mg_graph_view.number_of_vertices()); raft::update_host(h_mg_aggregate_katz_centralities.data(), d_mg_aggregate_katz_centralities.data(), d_mg_aggregate_katz_centralities.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_katz_centralities(sg_graph_view.number_of_vertices()); raft::update_host(h_sg_katz_centralities.data(), d_sg_katz_centralities.data(), d_sg_katz_centralities.size(), - handle.get_stream()); + handle_->get_stream()); - handle.sync_stream(); + handle_->sync_stream(); auto threshold_ratio = 1e-3; auto threshold_magnitude = @@ -206,8 +194,14 @@ class Tests_MGKatzCentrality } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGKatzCentrality::handle_ = nullptr; + using Tests_MGKatzCentrality_File = Tests_MGKatzCentrality; using Tests_MGKatzCentrality_Rmat = Tests_MGKatzCentrality; diff --git a/cpp/tests/community/egonet_test.cu b/cpp/tests/community/egonet_test.cu index a302f57295b..4938cb729b7 100644 --- a/cpp/tests/community/egonet_test.cu +++ b/cpp/tests/community/egonet_test.cu @@ -60,7 +60,8 @@ typedef struct InducedEgo_Usecase_t { class Tests_InducedEgo : public ::testing::TestWithParam { public: Tests_InducedEgo() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/community/induced_subgraph_test.cpp b/cpp/tests/community/induced_subgraph_test.cpp index ed2a43e0317..d73ee803b06 100644 --- a/cpp/tests/community/induced_subgraph_test.cpp +++ b/cpp/tests/community/induced_subgraph_test.cpp @@ -106,7 +106,8 @@ typedef struct InducedSubgraph_Usecase_t { class Tests_InducedSubgraph : public ::testing::TestWithParam { public: Tests_InducedSubgraph() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/community/louvain_test.cpp b/cpp/tests/community/louvain_test.cpp index b8308c043fb..bfddc56a32f 100644 --- a/cpp/tests/community/louvain_test.cpp +++ b/cpp/tests/community/louvain_test.cpp @@ -42,7 +42,8 @@ class Tests_Louvain : public ::testing::TestWithParam> { public: Tests_Louvain() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/community/mg_louvain_test.cpp b/cpp/tests/community/mg_louvain_test.cpp index 1cecbac23ac..3a8ab7f9a3b 100644 --- a/cpp/tests/community/mg_louvain_test.cpp +++ b/cpp/tests/community/mg_louvain_test.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -63,11 +64,12 @@ struct Louvain_Usecase { // expected outputs, so the entire test is defined in the run_test() method. // template -class Tests_MG_Louvain +class Tests_MGLouvain : public ::testing::TestWithParam> { public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } // Run once for each test instance virtual void SetUp() {} @@ -87,7 +89,7 @@ class Tests_MG_Louvain { auto sg_graph = std::make_unique>(handle); - rmm::device_uvector d_clustering_v(0, handle.get_stream()); + rmm::device_uvector d_clustering_v(0, handle_->get_stream()); weight_t sg_modularity{-1.0}; if (rank == 0) { @@ -102,7 +104,7 @@ class Tests_MG_Louvain input_usecase.template construct_edgelist(handle, true); - d_clustering_v.resize(d_vertices.size(), handle.get_stream()); + d_clustering_v.resize(d_vertices.size(), handle_->get_stream()); // renumber using d_renumber_map_gathered_v cugraph::test::single_gpu_renumber_edgelist_given_number_map( @@ -130,7 +132,7 @@ class Tests_MG_Louvain if (rank == 0) { auto graph_view = sg_graph->view(); - d_clustering_v.resize(graph_view.number_of_vertices(), handle.get_stream()); + d_clustering_v.resize(graph_view.number_of_vertices(), handle_->get_stream()); std::tie(std::ignore, sg_modularity) = cugraph::louvain(handle, graph_view, d_clustering_v.data(), size_t{1}, resolution); @@ -156,37 +158,21 @@ class Tests_MG_Louvain { auto [louvain_usecase, input_usecase] = param; - auto constexpr pool_size = 64; // FIXME: tuning parameter - raft::handle_t handle(rmm::cuda_stream_per_thread, - std::make_shared(pool_size)); HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true); + *handle_, input_usecase, true, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -196,16 +182,16 @@ class Tests_MG_Louvain if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [dendrogram, mg_modularity] = cugraph::louvain( - handle, mg_graph_view, louvain_usecase.max_level_, louvain_usecase.resolution_); + *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(); + 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"; @@ -215,44 +201,50 @@ class Tests_MG_Louvain SCOPED_TRACE("compare modularity input"); auto d_renumber_map_gathered_v = cugraph::test::device_gatherv( - handle, (*d_renumber_map_labels).data(), (*d_renumber_map_labels).size()); + *handle_, (*d_renumber_map_labels).data(), (*d_renumber_map_labels).size()); - compare_sg_results(handle, + compare_sg_results(*handle_, input_usecase, d_renumber_map_gathered_v, *dendrogram, louvain_usecase.resolution_, - comm_rank, + handle_->get_comms().get_rank(), mg_modularity); } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGLouvain::handle_ = nullptr; + //////////////////////////////////////////////////////////////////////////////// -using Tests_MG_Louvain_File = Tests_MG_Louvain; -using Tests_MG_Louvain_File64 = Tests_MG_Louvain; -using Tests_MG_Louvain_Rmat = Tests_MG_Louvain; -using Tests_MG_Louvain_Rmat64 = Tests_MG_Louvain; +using Tests_MGLouvain_File = Tests_MGLouvain; +using Tests_MGLouvain_File64 = Tests_MGLouvain; +using Tests_MGLouvain_Rmat = Tests_MGLouvain; +using Tests_MGLouvain_Rmat64 = Tests_MGLouvain; -TEST_P(Tests_MG_Louvain_File, CheckInt32Int32Float) +TEST_P(Tests_MGLouvain_File, CheckInt32Int32Float) { run_current_test( override_File_Usecase_with_cmd_line_arguments(GetParam())); } -TEST_P(Tests_MG_Louvain_File64, CheckInt64Int64Float) +TEST_P(Tests_MGLouvain_File64, CheckInt64Int64Float) { run_current_test( override_File_Usecase_with_cmd_line_arguments(GetParam())); } -TEST_P(Tests_MG_Louvain_Rmat, CheckInt32Int32Float) +TEST_P(Tests_MGLouvain_Rmat, CheckInt32Int32Float) { run_current_test( override_Rmat_Usecase_with_cmd_line_arguments(GetParam())); } -TEST_P(Tests_MG_Louvain_Rmat64, CheckInt64Int64Float) +TEST_P(Tests_MGLouvain_Rmat64, CheckInt64Int64Float) { run_current_test( override_Rmat_Usecase_with_cmd_line_arguments(GetParam())); @@ -260,7 +252,7 @@ TEST_P(Tests_MG_Louvain_Rmat64, CheckInt64Int64Float) INSTANTIATE_TEST_SUITE_P( simple_file_test, - Tests_MG_Louvain_File, + Tests_MGLouvain_File, ::testing::Combine( // enable correctness checks for small graphs ::testing::Values(Louvain_Usecase{100, 1, true}), @@ -269,7 +261,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( simple_rmat_test, - Tests_MG_Louvain_Rmat, + Tests_MGLouvain_Rmat, ::testing::Combine( // enable correctness checks for small graphs ::testing::Values(Louvain_Usecase{}), @@ -281,7 +273,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one File_Usecase that differ only in filename (to avoid running same benchmarks more than once) */ - Tests_MG_Louvain_File, + Tests_MGLouvain_File, ::testing::Combine( // disable correctness checks for large graphs ::testing::Values(Louvain_Usecase{}), @@ -293,7 +285,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one File_Usecase that differ only in filename (to avoid running same benchmarks more than once) */ - Tests_MG_Louvain_File64, + Tests_MGLouvain_File64, ::testing::Combine( // disable correctness checks for large graphs ::testing::Values(Louvain_Usecase{}), @@ -305,7 +297,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_Louvain_Rmat, + Tests_MGLouvain_Rmat, ::testing::Combine( // disable correctness checks for large graphs ::testing::Values(Louvain_Usecase{}), @@ -318,7 +310,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_Louvain_Rmat64, + Tests_MGLouvain_Rmat64, ::testing::Combine( // disable correctness checks for large graphs ::testing::Values(Louvain_Usecase{}), diff --git a/cpp/tests/community/mg_triangle_count_test.cpp b/cpp/tests/community/mg_triangle_count_test.cpp index a01f9fedadc..1df9ca2c55a 100644 --- a/cpp/tests/community/mg_triangle_count_test.cpp +++ b/cpp/tests/community/mg_triangle_count_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -47,8 +48,10 @@ class Tests_MGTriangleCount : public ::testing::TestWithParam> { public: Tests_MGTriangleCount() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -60,41 +63,23 @@ class Tests_MGTriangleCount { using weight_t = float; - // 1. initialize handle - - auto constexpr pool_size = 64; // FIXME: tuning parameter - raft::handle_t handle(rmm::cuda_stream_per_thread, - std::make_shared(pool_size)); HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, false, true, false, true); + *handle_, input_usecase, false, true, false, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -102,12 +87,12 @@ class Tests_MGTriangleCount auto mg_graph_view = mg_graph.view(); - // 3. generate a vertex subset to compute triangle counts + // 2. generate a vertex subset to compute triangle counts std::optional> h_mg_vertices{std::nullopt}; if (triangle_count_usecase.vertex_subset_ratio < 1.0) { std::default_random_engine generator{ - static_cast(comm.get_rank()) /* seed */}; + static_cast(handle_->get_comms().get_rank()) /* seed */}; std::uniform_real_distribution distribution{0.0, 1.0}; h_mg_vertices = std::vector(mg_graph_view.local_vertex_partition_range_size()); std::iota((*h_mg_vertices).begin(), @@ -124,29 +109,29 @@ class Tests_MGTriangleCount } auto d_mg_vertices = h_mg_vertices ? std::make_optional>( - (*h_mg_vertices).size(), handle.get_stream()) + (*h_mg_vertices).size(), handle_->get_stream()) : std::nullopt; if (d_mg_vertices) { raft::update_device((*d_mg_vertices).data(), (*h_mg_vertices).data(), (*h_mg_vertices).size(), - handle.get_stream()); + handle_->get_stream()); } - // 4. run MG TriangleCount + // 3. run MG TriangleCount rmm::device_uvector d_mg_triangle_counts( d_mg_vertices ? (*d_mg_vertices).size() : mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } cugraph::triangle_count( - handle, + *handle_, mg_graph_view, d_mg_vertices ? std::make_optional>( (*d_mg_vertices).begin(), (*d_mg_vertices).end()) @@ -156,64 +141,64 @@ class Tests_MGTriangleCount if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG TriangleCount took " << elapsed_time * 1e-6 << " s.\n"; } - // 5. copmare SG & MG results + // 4. copmare SG & MG results if (triangle_count_usecase.check_correctness) { - // 5-1. aggregate MG results + // 4-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_vertices = d_mg_vertices ? std::optional>{cugraph::test::device_gatherv( - handle, (*d_mg_vertices).data(), (*d_mg_vertices).size())} + *handle_, (*d_mg_vertices).data(), (*d_mg_vertices).size())} : std::nullopt; auto d_mg_aggregate_triangle_counts = cugraph::test::device_gatherv( - handle, d_mg_triangle_counts.data(), d_mg_triangle_counts.size()); + *handle_, d_mg_triangle_counts.data(), d_mg_triangle_counts.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 5-2. unrenumbr MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 4-2. unrenumbr MG results if (d_mg_aggregate_vertices) { cugraph::unrenumber_int_vertices( - handle, + *handle_, (*d_mg_aggregate_vertices).data(), (*d_mg_aggregate_vertices).size(), d_mg_aggregate_renumber_map_labels.data(), std::vector{mg_graph_view.number_of_vertices()}); std::tie(d_mg_aggregate_vertices, d_mg_aggregate_triangle_counts) = cugraph::test::sort_by_key( - handle, *d_mg_aggregate_vertices, d_mg_aggregate_triangle_counts); + *handle_, *d_mg_aggregate_vertices, d_mg_aggregate_triangle_counts); } else { std::tie(std::ignore, d_mg_aggregate_triangle_counts) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_triangle_counts); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_triangle_counts); } - // 5-3. create SG graph + // 4-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, false, false, false, true); + *handle_, input_usecase, false, false, false, true); auto sg_graph_view = sg_graph.view(); ASSERT_EQ(mg_graph_view.number_of_vertices(), sg_graph_view.number_of_vertices()); - // 5-4. run SG TriangleCount + // 4-4. run SG TriangleCount rmm::device_uvector d_sg_triangle_counts(d_mg_aggregate_vertices ? (*d_mg_aggregate_vertices).size() : sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); cugraph::triangle_count( - handle, + *handle_, sg_graph_view, d_mg_aggregate_vertices ? std::make_optional>( @@ -222,21 +207,21 @@ class Tests_MGTriangleCount raft::device_span(d_sg_triangle_counts.begin(), d_sg_triangle_counts.end()), false); - // 5-4. compare + // 4-5. compare std::vector h_mg_aggregate_triangle_counts(d_mg_aggregate_triangle_counts.size()); raft::update_host(h_mg_aggregate_triangle_counts.data(), d_mg_aggregate_triangle_counts.data(), d_mg_aggregate_triangle_counts.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_triangle_counts(d_sg_triangle_counts.size()); raft::update_host(h_sg_triangle_counts.data(), d_sg_triangle_counts.data(), d_sg_triangle_counts.size(), - handle.get_stream()); + handle_->get_stream()); - handle.sync_stream(); + handle_->sync_stream(); ASSERT_TRUE(std::equal(h_mg_aggregate_triangle_counts.begin(), h_mg_aggregate_triangle_counts.end(), @@ -244,8 +229,14 @@ class Tests_MGTriangleCount } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGTriangleCount::handle_ = nullptr; + using Tests_MGTriangleCount_File = Tests_MGTriangleCount; using Tests_MGTriangleCount_Rmat = Tests_MGTriangleCount; diff --git a/cpp/tests/community/triangle_count_test.cpp b/cpp/tests/community/triangle_count_test.cpp index a57ddb7c424..214fea556a7 100644 --- a/cpp/tests/community/triangle_count_test.cpp +++ b/cpp/tests/community/triangle_count_test.cpp @@ -98,7 +98,8 @@ class Tests_TriangleCount : public ::testing::TestWithParam> { public: Tests_TriangleCount() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/components/con_comp_test.cu b/cpp/tests/components/con_comp_test.cu index e65ead2ca24..9031aaf6475 100644 --- a/cpp/tests/components/con_comp_test.cu +++ b/cpp/tests/components/con_comp_test.cu @@ -52,7 +52,8 @@ struct Usecase { struct Tests_Weakly_CC : ::testing::TestWithParam { Tests_Weakly_CC() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() { if (cugraph::test::g_perf) { diff --git a/cpp/tests/components/mg_weakly_connected_components_test.cpp b/cpp/tests/components/mg_weakly_connected_components_test.cpp index 4b675d31514..26758bcb0fb 100644 --- a/cpp/tests/components/mg_weakly_connected_components_test.cpp +++ b/cpp/tests/components/mg_weakly_connected_components_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -44,8 +45,10 @@ class Tests_MGWeaklyConnectedComponents std::tuple> { public: Tests_MGWeaklyConnectedComponents() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -59,38 +62,23 @@ class Tests_MGWeaklyConnectedComponents { using weight_t = float; - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, false, true); + *handle_, input_usecase, false, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -98,76 +86,76 @@ class Tests_MGWeaklyConnectedComponents auto mg_graph_view = mg_graph.view(); - // 3. run MG weakly connected components + // 2. run MG weakly connected components rmm::device_uvector d_mg_components(mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - cugraph::weakly_connected_components(handle, mg_graph_view, d_mg_components.data()); + cugraph::weakly_connected_components(*handle_, mg_graph_view, d_mg_components.data()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG weakly_connected_components took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. compare SG & MG results + // 3. compare SG & MG results if (weakly_connected_components_usecase.check_correctness) { - // 4-1. aggregate MG results + // 3-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_components = - cugraph::test::device_gatherv(handle, d_mg_components.data(), d_mg_components.size()); + cugraph::test::device_gatherv(*handle_, d_mg_components.data(), d_mg_components.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 4-2. unrenumbr MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 3-2. unrenumbr MG results std::tie(std::ignore, d_mg_aggregate_components) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_components); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_components); - // 4-3. create SG graph + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, false, false); + *handle_, input_usecase, false, false); auto sg_graph_view = sg_graph.view(); ASSERT_TRUE(mg_graph_view.number_of_vertices() == sg_graph_view.number_of_vertices()); - // 4-4. run SG weakly connected components + // 3-4. run SG weakly connected components rmm::device_uvector d_sg_components(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); - cugraph::weakly_connected_components(handle, sg_graph_view, d_sg_components.data()); + cugraph::weakly_connected_components(*handle_, sg_graph_view, d_sg_components.data()); - // 4-5. compare + // 3-5. compare std::vector h_mg_aggregate_components(mg_graph_view.number_of_vertices()); raft::update_host(h_mg_aggregate_components.data(), d_mg_aggregate_components.data(), d_mg_aggregate_components.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_components(sg_graph_view.number_of_vertices()); raft::update_host(h_sg_components.data(), d_sg_components.data(), d_sg_components.size(), - handle.get_stream()); + handle_->get_stream()); - handle.sync_stream(); + handle_->sync_stream(); std::unordered_map mg_to_sg_map{}; for (size_t i = 0; i < h_sg_components.size(); ++i) { @@ -184,8 +172,15 @@ class Tests_MGWeaklyConnectedComponents } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGWeaklyConnectedComponents::handle_ = + nullptr; + using Tests_MGWeaklyConnectedComponents_File = Tests_MGWeaklyConnectedComponents; using Tests_MGWeaklyConnectedComponents_Rmat = diff --git a/cpp/tests/components/scc_test.cu b/cpp/tests/components/scc_test.cu index 7418ecc6601..55277126e33 100644 --- a/cpp/tests/components/scc_test.cu +++ b/cpp/tests/components/scc_test.cu @@ -107,7 +107,8 @@ DVector byte_matrix_to_int(const DVector& d_adj_byte_matrix) struct Tests_Strongly_CC : ::testing::TestWithParam { Tests_Strongly_CC() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() { if (cugraph::test::g_perf) { @@ -120,6 +121,7 @@ struct Tests_Strongly_CC : ::testing::TestWithParam { std::cout << count << std::endl; } } + virtual void SetUp() {} virtual void TearDown() {} diff --git a/cpp/tests/components/wcc_test.cpp b/cpp/tests/components/wcc_test.cpp index cc905a87022..aadc5fec03b 100644 --- a/cpp/tests/components/wcc_test.cpp +++ b/cpp/tests/components/wcc_test.cpp @@ -27,7 +27,8 @@ template class Tests_WCC : public ::testing::TestWithParam> { public: Tests_WCC() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/components/weakly_connected_components_test.cpp b/cpp/tests/components/weakly_connected_components_test.cpp index 02bc21ef26c..b41584e6a73 100644 --- a/cpp/tests/components/weakly_connected_components_test.cpp +++ b/cpp/tests/components/weakly_connected_components_test.cpp @@ -88,7 +88,8 @@ class Tests_WeaklyConnectedComponent std::tuple> { public: Tests_WeaklyConnectedComponent() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/cores/core_number_test.cpp b/cpp/tests/cores/core_number_test.cpp index 165709c6363..8cb923e68b3 100644 --- a/cpp/tests/cores/core_number_test.cpp +++ b/cpp/tests/cores/core_number_test.cpp @@ -205,7 +205,8 @@ class Tests_CoreNumber : public ::testing::TestWithParam> { public: Tests_CoreNumber() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/cores/mg_core_number_test.cpp b/cpp/tests/cores/mg_core_number_test.cpp index 3148e243230..56fef0adae5 100644 --- a/cpp/tests/cores/mg_core_number_test.cpp +++ b/cpp/tests/cores/mg_core_number_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -51,8 +52,10 @@ class Tests_MGCoreNumber : public ::testing::TestWithParam> { public: Tests_MGCoreNumber() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -64,38 +67,23 @@ class Tests_MGCoreNumber { using weight_t = float; - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, false, true, true, true); + *handle_, input_usecase, false, true, true, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -103,18 +91,18 @@ class Tests_MGCoreNumber auto mg_graph_view = mg_graph.view(); - // 3. run MG CoreNumber + // 2. run MG CoreNumber rmm::device_uvector d_mg_core_numbers(mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - cugraph::core_number(handle, + cugraph::core_number(*handle_, mg_graph_view, d_mg_core_numbers.data(), core_number_usecase.degree_type, @@ -123,66 +111,66 @@ class Tests_MGCoreNumber if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG Core Number took " << elapsed_time * 1e-6 << " s.\n"; } - // 5. copmare SG & MG results + // 3. copmare SG & MG results if (core_number_usecase.check_correctness) { - // 5-1. aggregate MG results + // 3-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_core_numbers = - cugraph::test::device_gatherv(handle, d_mg_core_numbers.data(), d_mg_core_numbers.size()); + cugraph::test::device_gatherv(*handle_, d_mg_core_numbers.data(), d_mg_core_numbers.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 5-2. unrenumbr MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 3-2. unrenumbr MG results std::tie(std::ignore, d_mg_aggregate_core_numbers) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_core_numbers); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_core_numbers); - // 5-3. create SG graph + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, false, false, true, true); + *handle_, input_usecase, false, false, true, true); auto sg_graph_view = sg_graph.view(); ASSERT_EQ(mg_graph_view.number_of_vertices(), sg_graph_view.number_of_vertices()); - // 5-4. run SG CoreNumber + // 3-4. run SG CoreNumber rmm::device_uvector d_sg_core_numbers(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); - cugraph::core_number(handle, + cugraph::core_number(*handle_, sg_graph_view, d_sg_core_numbers.data(), core_number_usecase.degree_type, core_number_usecase.k_first, core_number_usecase.k_last); - // 5-4. compare + // 3-5. compare std::vector h_mg_aggregate_core_numbers(mg_graph_view.number_of_vertices()); raft::update_host(h_mg_aggregate_core_numbers.data(), d_mg_aggregate_core_numbers.data(), d_mg_aggregate_core_numbers.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_core_numbers(sg_graph_view.number_of_vertices()); raft::update_host(h_sg_core_numbers.data(), d_sg_core_numbers.data(), d_sg_core_numbers.size(), - handle.get_stream()); + handle_->get_stream()); - handle.sync_stream(); + handle_->sync_stream(); ASSERT_TRUE(std::equal(h_mg_aggregate_core_numbers.begin(), h_mg_aggregate_core_numbers.end(), @@ -190,8 +178,14 @@ class Tests_MGCoreNumber } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGCoreNumber::handle_ = nullptr; + using Tests_MGCoreNumber_File = Tests_MGCoreNumber; using Tests_MGCoreNumber_Rmat = Tests_MGCoreNumber; diff --git a/cpp/tests/generators/generate_rmat_test.cpp b/cpp/tests/generators/generate_rmat_test.cpp index 2562268e7a0..908ffb85f60 100644 --- a/cpp/tests/generators/generate_rmat_test.cpp +++ b/cpp/tests/generators/generate_rmat_test.cpp @@ -156,7 +156,8 @@ typedef struct GenerateRmat_Usecase_t { class Tests_GenerateRmat : public ::testing::TestWithParam { public: Tests_GenerateRmat() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} @@ -307,7 +308,8 @@ typedef struct GenerateRmats_Usecase_t { class Tests_GenerateRmats : public ::testing::TestWithParam { public: Tests_GenerateRmats() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/layout/force_atlas2_test.cu b/cpp/tests/layout/force_atlas2_test.cu index e843a66841a..bea28254631 100644 --- a/cpp/tests/layout/force_atlas2_test.cu +++ b/cpp/tests/layout/force_atlas2_test.cu @@ -56,7 +56,8 @@ typedef struct Force_Atlas2_Usecase_t { class Tests_Force_Atlas2 : public ::testing::TestWithParam { public: Tests_Force_Atlas2() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() { if (cugraph::test::g_perf) { diff --git a/cpp/tests/link_analysis/hits_test.cpp b/cpp/tests/link_analysis/hits_test.cpp index 670c6f3e289..1d4b742b201 100644 --- a/cpp/tests/link_analysis/hits_test.cpp +++ b/cpp/tests/link_analysis/hits_test.cpp @@ -135,7 +135,8 @@ template class Tests_Hits : public ::testing::TestWithParam> { public: Tests_Hits() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/link_analysis/mg_hits_test.cpp b/cpp/tests/link_analysis/mg_hits_test.cpp index acd12a4015c..f3676b3c4ec 100644 --- a/cpp/tests/link_analysis/mg_hits_test.cpp +++ b/cpp/tests/link_analysis/mg_hits_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -41,8 +42,10 @@ template class Tests_MGHits : public ::testing::TestWithParam> { public: Tests_MGHits() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -51,73 +54,58 @@ class Tests_MGHits : public ::testing::TestWithParam void run_current_test(Hits_Usecase const& hits_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, false, true); + *handle_, input_usecase, false, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; } - // 3. run hits + // 2. run hits auto mg_graph_view = mg_graph.view(); auto maximum_iterations = 200; weight_t tolerance = 1e-8; rmm::device_uvector d_mg_hubs(mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_mg_authorities( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); std::vector initial_random_hubs = (hits_usecase.check_initial_input) - ? cugraph::test::random_vector(d_mg_hubs.size(), comm_rank) + ? cugraph::test::random_vector(d_mg_hubs.size(), handle_->get_comms().get_rank()) : std::vector(0); if (hits_usecase.check_initial_input) { raft::update_device(d_mg_hubs.data(), initial_random_hubs.data(), initial_random_hubs.size(), - handle.get_stream()); + handle_->get_stream()); } if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - auto result = cugraph::hits(handle, + auto result = cugraph::hits(*handle_, mg_graph_view, d_mg_hubs.data(), d_mg_authorities.data(), @@ -129,68 +117,70 @@ class Tests_MGHits : public ::testing::TestWithParamget_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG Hits took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. compare SG & MG results + // 3. compare SG & MG results if (hits_usecase.check_correctness) { - // 4-1. aggregate MG results + // 3-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_hubs = - cugraph::test::device_gatherv(handle, d_mg_hubs.data(), d_mg_hubs.size()); + cugraph::test::device_gatherv(*handle_, d_mg_hubs.data(), d_mg_hubs.size()); auto d_mg_aggregate_authorities = - cugraph::test::device_gatherv(handle, d_mg_authorities.data(), d_mg_authorities.size()); - rmm::device_uvector d_initial_hubs(0, handle.get_stream()); + cugraph::test::device_gatherv(*handle_, d_mg_authorities.data(), d_mg_authorities.size()); + rmm::device_uvector d_initial_hubs(0, handle_->get_stream()); if (hits_usecase.check_initial_input) { - d_initial_hubs.resize(initial_random_hubs.size(), handle.get_stream()); + d_initial_hubs.resize(initial_random_hubs.size(), handle_->get_stream()); raft::update_device(d_initial_hubs.data(), initial_random_hubs.data(), initial_random_hubs.size(), - handle.get_stream()); + handle_->get_stream()); d_initial_hubs = - cugraph::test::device_gatherv(handle, d_initial_hubs.data(), d_initial_hubs.size()); + cugraph::test::device_gatherv(*handle_, d_initial_hubs.data(), d_initial_hubs.size()); std::tie(std::ignore, d_initial_hubs) = - cugraph::test::sort_by_key(handle, d_mg_aggregate_renumber_map_labels, d_initial_hubs); + cugraph::test::sort_by_key(*handle_, d_mg_aggregate_renumber_map_labels, d_initial_hubs); } - if (handle.get_comms().get_rank() == int{0}) { - // 4-2. unrenumber MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 3-2. unrenumber MG results std::tie(std::ignore, d_mg_aggregate_hubs) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_hubs); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_hubs); std::tie(std::ignore, d_mg_aggregate_authorities) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_authorities); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_authorities); - // 4-3. create SG graph + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, false, false); + *handle_, input_usecase, false, false); auto sg_graph_view = sg_graph.view(); ASSERT_TRUE(mg_graph_view.number_of_vertices() == sg_graph_view.number_of_vertices()); - // 4-4. run SG Hits + // 3-4. run SG Hits rmm::device_uvector d_sg_hubs(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_sg_authorities(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); if (hits_usecase.check_initial_input) { - raft::update_device( - d_sg_hubs.begin(), d_initial_hubs.begin(), d_initial_hubs.size(), handle.get_stream()); + raft::update_device(d_sg_hubs.begin(), + d_initial_hubs.begin(), + d_initial_hubs.size(), + handle_->get_stream()); } - auto result = cugraph::hits(handle, + auto result = cugraph::hits(*handle_, sg_graph_view, d_sg_hubs.data(), d_sg_authorities.data(), @@ -200,19 +190,19 @@ class Tests_MGHits : public ::testing::TestWithParam h_mg_aggregate_hubs(mg_graph_view.number_of_vertices()); raft::update_host(h_mg_aggregate_hubs.data(), d_mg_aggregate_hubs.data(), d_mg_aggregate_hubs.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_hubs(sg_graph_view.number_of_vertices()); raft::update_host( - h_sg_hubs.data(), d_sg_hubs.data(), d_sg_hubs.size(), handle.get_stream()); + h_sg_hubs.data(), d_sg_hubs.data(), d_sg_hubs.size(), handle_->get_stream()); - handle.sync_stream(); + handle_->sync_stream(); auto threshold_ratio = 1e-3; auto threshold_magnitude = @@ -229,8 +219,14 @@ class Tests_MGHits : public ::testing::TestWithParam handle_; }; +template +std::unique_ptr Tests_MGHits::handle_ = nullptr; + using Tests_MGHits_File = Tests_MGHits; using Tests_MGHits_Rmat = Tests_MGHits; diff --git a/cpp/tests/link_analysis/mg_pagerank_test.cpp b/cpp/tests/link_analysis/mg_pagerank_test.cpp index 75dba1202ce..e79043b3a77 100644 --- a/cpp/tests/link_analysis/mg_pagerank_test.cpp +++ b/cpp/tests/link_analysis/mg_pagerank_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -25,10 +26,7 @@ #include #include #include -#include -#include -#include #include #include #include @@ -48,8 +46,10 @@ class Tests_MGPageRank : public ::testing::TestWithParam> { public: Tests_MGPageRank() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -59,40 +59,23 @@ class Tests_MGPageRank void run_current_test(PageRank_Usecase const& pagerank_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - auto constexpr pool_size = 64; // FIXME: tuning parameter - raft::handle_t handle(rmm::cuda_stream_per_thread, - std::make_shared(pool_size)); HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - auto& comm = handle.get_comms(); - auto const comm_size = comm.get_size(); - - auto row_comm_size = static_cast(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, pagerank_usecase.test_weighted, true); + *handle_, input_usecase, pagerank_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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." << std::endl; @@ -100,13 +83,13 @@ class Tests_MGPageRank auto mg_graph_view = mg_graph.view(); - // 3. generate personalization vertex/value pairs + // 2. generate personalization vertex/value pairs std::optional> h_mg_personalization_vertices{std::nullopt}; std::optional> h_mg_personalization_values{std::nullopt}; if (pagerank_usecase.personalization_ratio > 0.0) { std::default_random_engine generator{ - static_cast(comm.get_rank()) /* seed */}; + static_cast(handle_->get_comms().get_rank()) /* seed */}; std::uniform_real_distribution distribution{0.0, 1.0}; h_mg_personalization_vertices = std::vector(mg_graph_view.local_vertex_partition_range_size()); @@ -130,39 +113,40 @@ class Tests_MGPageRank auto d_mg_personalization_vertices = h_mg_personalization_vertices ? std::make_optional>((*h_mg_personalization_vertices).size(), - handle.get_stream()) + handle_->get_stream()) : std::nullopt; auto d_mg_personalization_values = - h_mg_personalization_values ? std::make_optional>( - (*d_mg_personalization_vertices).size(), handle.get_stream()) - : std::nullopt; + h_mg_personalization_values + ? std::make_optional>((*d_mg_personalization_vertices).size(), + handle_->get_stream()) + : std::nullopt; if (d_mg_personalization_vertices) { raft::update_device((*d_mg_personalization_vertices).data(), (*h_mg_personalization_vertices).data(), (*h_mg_personalization_vertices).size(), - handle.get_stream()); + handle_->get_stream()); raft::update_device((*d_mg_personalization_values).data(), (*h_mg_personalization_values).data(), (*h_mg_personalization_values).size(), - handle.get_stream()); + handle_->get_stream()); } - // 4. run MG PageRank + // 3. run MG PageRank result_t constexpr alpha{0.85}; result_t constexpr epsilon{1e-6}; rmm::device_uvector d_mg_pageranks(mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } cugraph::pagerank( - handle, + *handle_, mg_graph_view, std::nullopt, d_mg_personalization_vertices @@ -182,70 +166,72 @@ class Tests_MGPageRank if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG PageRank took " << elapsed_time * 1e-6 << " s.\n"; } - // 5. copmare SG & MG results + // 4. copmare SG & MG results if (pagerank_usecase.check_correctness) { - // 5-1. aggregate MG results + // 4-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_personalization_vertices = d_mg_personalization_vertices ? std::optional>{cugraph::test::device_gatherv( - handle, + *handle_, (*d_mg_personalization_vertices).data(), (*d_mg_personalization_vertices).size())} : std::nullopt; auto d_mg_aggregate_personalization_values = d_mg_personalization_values ? std::optional>{cugraph::test::device_gatherv( - handle, (*d_mg_personalization_values).data(), (*d_mg_personalization_values).size())} + *handle_, + (*d_mg_personalization_values).data(), + (*d_mg_personalization_values).size())} : std::nullopt; auto d_mg_aggregate_pageranks = - cugraph::test::device_gatherv(handle, d_mg_pageranks.data(), d_mg_pageranks.size()); + cugraph::test::device_gatherv(*handle_, d_mg_pageranks.data(), d_mg_pageranks.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 5-2. unrenumbr MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 4-2. unrenumbr MG results if (d_mg_aggregate_personalization_vertices) { cugraph::unrenumber_int_vertices( - handle, + *handle_, (*d_mg_aggregate_personalization_vertices).data(), (*d_mg_aggregate_personalization_vertices).size(), d_mg_aggregate_renumber_map_labels.data(), std::vector{mg_graph_view.number_of_vertices()}); std::tie(d_mg_aggregate_personalization_vertices, d_mg_aggregate_personalization_values) = - cugraph::test::sort_by_key(handle, + cugraph::test::sort_by_key(*handle_, *d_mg_aggregate_personalization_vertices, *d_mg_aggregate_personalization_values); } std::tie(std::ignore, d_mg_aggregate_pageranks) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_pageranks); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_pageranks); - // 5-3. create SG graph + // 4-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, pagerank_usecase.test_weighted, false); + *handle_, input_usecase, pagerank_usecase.test_weighted, false); auto sg_graph_view = sg_graph.view(); ASSERT_EQ(mg_graph_view.number_of_vertices(), sg_graph_view.number_of_vertices()); - // 5-4. run SG PageRank + // 4-4. run SG PageRank rmm::device_uvector d_sg_pageranks(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); cugraph::pagerank( - handle, + *handle_, sg_graph_view, std::nullopt, d_mg_aggregate_personalization_vertices @@ -264,18 +250,20 @@ class Tests_MGPageRank std::numeric_limits::max(), // max_iterations false); - // 5-4. compare + // 4-5. compare std::vector h_mg_aggregate_pageranks(mg_graph_view.number_of_vertices()); raft::update_host(h_mg_aggregate_pageranks.data(), d_mg_aggregate_pageranks.data(), d_mg_aggregate_pageranks.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_pageranks(sg_graph_view.number_of_vertices()); - raft::update_host( - h_sg_pageranks.data(), d_sg_pageranks.data(), d_sg_pageranks.size(), handle.get_stream()); - handle.sync_stream(); + raft::update_host(h_sg_pageranks.data(), + d_sg_pageranks.data(), + d_sg_pageranks.size(), + handle_->get_stream()); + handle_->sync_stream(); auto threshold_ratio = 1e-3; auto threshold_magnitude = @@ -293,8 +281,14 @@ class Tests_MGPageRank } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGPageRank::handle_ = nullptr; + using Tests_MGPageRank_File = Tests_MGPageRank; using Tests_MGPageRank_Rmat = Tests_MGPageRank; diff --git a/cpp/tests/link_analysis/pagerank_test.cpp b/cpp/tests/link_analysis/pagerank_test.cpp index 773d4519e8c..0126cdd4ac4 100644 --- a/cpp/tests/link_analysis/pagerank_test.cpp +++ b/cpp/tests/link_analysis/pagerank_test.cpp @@ -140,7 +140,8 @@ class Tests_PageRank : public ::testing::TestWithParam> { public: Tests_PageRank() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/prims/mg_count_if_e.cu b/cpp/tests/prims/mg_count_if_e.cu index 61f7ccfa6e6..78811081799 100644 --- a/cpp/tests/prims/mg_count_if_e.cu +++ b/cpp/tests/prims/mg_count_if_e.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -170,12 +171,14 @@ struct Prims_Usecase { }; template -class Tests_MG_TransformCountIfE +class Tests_MGCountIfE : public ::testing::TestWithParam> { public: - Tests_MG_TransformCountIfE() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGCountIfE() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -188,37 +191,22 @@ class Tests_MG_TransformCountIfE bool store_transposed> void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, prims_usecase.test_weighted, true); + *handle_, input_usecase, prims_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -226,24 +214,24 @@ class Tests_MG_TransformCountIfE auto mg_graph_view = mg_graph.view(); - // 3. run MG count_if_e + // 2. run MG count_if_e const int hash_bin_count = 5; auto vertex_property_data = - generate::vertex_property((*d_mg_renumber_map_labels), hash_bin_count, handle); + generate::vertex_property((*d_mg_renumber_map_labels), hash_bin_count, *handle_); auto col_prop = - generate::column_property(handle, mg_graph_view, vertex_property_data); - auto row_prop = generate::row_property(handle, mg_graph_view, vertex_property_data); + generate::column_property(*handle_, mg_graph_view, vertex_property_data); + auto row_prop = generate::row_property(*handle_, mg_graph_view, vertex_property_data); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto result = count_if_e( - handle, + *handle_, mg_graph_view, row_prop.device_view(), col_prop.device_view(), @@ -252,33 +240,33 @@ class Tests_MG_TransformCountIfE }); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG count if e took " << elapsed_time * 1e-6 << " s.\n"; } - //// 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, prims_usecase.test_weighted, false); + *handle_, input_usecase, prims_usecase.test_weighted, false); auto sg_graph_view = sg_graph.view(); auto sg_vertex_property_data = generate::vertex_property( thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), hash_bin_count, - handle); + *handle_); auto sg_col_prop = - generate::column_property(handle, sg_graph_view, sg_vertex_property_data); + generate::column_property(*handle_, sg_graph_view, sg_vertex_property_data); auto sg_row_prop = - generate::row_property(handle, sg_graph_view, sg_vertex_property_data); + generate::row_property(*handle_, sg_graph_view, sg_vertex_property_data); auto expected_result = count_if_e( - handle, + *handle_, sg_graph_view, sg_row_prop.device_view(), sg_col_prop.device_view(), @@ -288,19 +276,25 @@ class Tests_MG_TransformCountIfE ASSERT_TRUE(expected_result == result); } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_TransformCountIfE_File = Tests_MG_TransformCountIfE; -using Tests_MG_TransformCountIfE_Rmat = Tests_MG_TransformCountIfE; +template +std::unique_ptr Tests_MGCountIfE::handle_ = nullptr; + +using Tests_MGCountIfE_File = Tests_MGCountIfE; +using Tests_MGCountIfE_Rmat = Tests_MGCountIfE; -TEST_P(Tests_MG_TransformCountIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGCountIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGCountIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>( @@ -308,14 +302,14 @@ TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTranspo cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformCountIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGCountIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGCountIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>( @@ -323,13 +317,13 @@ TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTranspo cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformCountIfE_File, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGCountIfE_File, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGCountIfE_Rmat, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test( @@ -337,13 +331,13 @@ TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTransposeFalse) cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformCountIfE_File, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGCountIfE_File, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGCountIfE_Rmat, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test( @@ -353,7 +347,7 @@ TEST_P(Tests_MG_TransformCountIfE_Rmat, CheckInt32Int32FloatTransposeTrue) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_TransformCountIfE_File, + Tests_MGCountIfE_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -363,14 +357,14 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_TransformCountIfE_Rmat, + Tests_MGCountIfE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); INSTANTIATE_TEST_SUITE_P( rmat_large_test, - Tests_MG_TransformCountIfE_Rmat, + Tests_MGCountIfE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/prims/mg_count_if_v.cu b/cpp/tests/prims/mg_count_if_v.cu index 5b127b805b3..d5fd08ebdba 100644 --- a/cpp/tests/prims/mg_count_if_v.cu +++ b/cpp/tests/prims/mg_count_if_v.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -57,12 +58,14 @@ struct Prims_Usecase { }; template -class Tests_MG_CountIfV +class Tests_MGCountIfV : public ::testing::TestWithParam> { public: - Tests_MG_CountIfV() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGCountIfV() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -71,37 +74,22 @@ class Tests_MG_CountIfV template void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true); + *handle_, input_usecase, true, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -111,95 +99,101 @@ class Tests_MG_CountIfV const int hash_bin_count = 5; - // 3. run MG count if + // 2. run MG count if if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } vertex_t const* data = (*d_mg_renumber_map_labels).data(); auto vertex_count = - count_if_v(handle, mg_graph_view, data, test_predicate(hash_bin_count)); + count_if_v(*handle_, mg_graph_view, data, test_predicate(hash_bin_count)); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG count if took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); auto expected_vertex_count = count_if_v( - handle, + *handle_, sg_graph_view, thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), test_predicate(hash_bin_count)); ASSERT_TRUE(expected_vertex_count == vertex_count); } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_CountIfV_File = Tests_MG_CountIfV; -using Tests_MG_CountIfV_Rmat = Tests_MG_CountIfV; +template +std::unique_ptr Tests_MGCountIfV::handle_ = nullptr; + +using Tests_MGCountIfV_File = Tests_MGCountIfV; +using Tests_MGCountIfV_Rmat = Tests_MGCountIfV; -TEST_P(Tests_MG_CountIfV_File, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGCountIfV_File, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_CountIfV_Rmat, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGCountIfV_Rmat, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_CountIfV_Rmat, CheckInt32Int64FloatTransposeFalse) +TEST_P(Tests_MGCountIfV_Rmat, CheckInt32Int64FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_CountIfV_Rmat, CheckInt64Int64FloatTransposeFalse) +TEST_P(Tests_MGCountIfV_Rmat, CheckInt64Int64FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_CountIfV_File, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGCountIfV_File, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_CountIfV_Rmat, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGCountIfV_Rmat, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_CountIfV_Rmat, CheckInt32Int64FloatTransposeTrue) +TEST_P(Tests_MGCountIfV_Rmat, CheckInt32Int64FloatTransposeTrue) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_CountIfV_Rmat, CheckInt64Int64FloatTransposeTrue) +TEST_P(Tests_MGCountIfV_Rmat, CheckInt64Int64FloatTransposeTrue) { auto param = GetParam(); run_current_test( @@ -208,7 +202,7 @@ TEST_P(Tests_MG_CountIfV_Rmat, CheckInt64Int64FloatTransposeTrue) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_CountIfV_File, + Tests_MGCountIfV_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -218,7 +212,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_CountIfV_Rmat, + Tests_MGCountIfV_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); @@ -229,7 +223,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_CountIfV_Rmat, + Tests_MGCountIfV_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/prims/mg_extract_if_e.cu b/cpp/tests/prims/mg_extract_if_e.cu index fc2479df985..3673f7df95f 100644 --- a/cpp/tests/prims/mg_extract_if_e.cu +++ b/cpp/tests/prims/mg_extract_if_e.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -128,12 +129,14 @@ struct Prims_Usecase { }; template -class Tests_MG_ExtractIfE +class Tests_MGExtractIfE : public ::testing::TestWithParam> { public: - Tests_MG_ExtractIfE() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGExtractIfE() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -146,38 +149,23 @@ class Tests_MG_ExtractIfE bool store_transposed> void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true); + *handle_, input_usecase, true, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -185,41 +173,41 @@ class Tests_MG_ExtractIfE auto mg_graph_view = mg_graph.view(); - // 3. run MG extract_if_e + // 2. run MG extract_if_e constexpr int hash_bin_count = 5; auto mg_property_buffer = cugraph::allocate_dataframe_buffer( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); - thrust::transform(handle.get_thrust_policy(), + thrust::transform(handle_->get_thrust_policy(), (*mg_renumber_map_labels).begin(), (*mg_renumber_map_labels).end(), cugraph::get_dataframe_buffer_begin(mg_property_buffer), property_transform_t{hash_bin_count}); cugraph::edge_partition_src_property_t mg_src_properties( - handle, mg_graph_view); + *handle_, mg_graph_view); cugraph::edge_partition_dst_property_t mg_dst_properties( - handle, mg_graph_view); + *handle_, mg_graph_view); - update_edge_partition_src_property(handle, + update_edge_partition_src_property(*handle_, mg_graph_view, cugraph::get_dataframe_buffer_cbegin(mg_property_buffer), mg_src_properties); - update_edge_partition_dst_property(handle, + update_edge_partition_dst_property(*handle_, mg_graph_view, cugraph::get_dataframe_buffer_cbegin(mg_property_buffer), mg_dst_properties); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_edgelist_srcs, mg_edgelist_dsts, mg_edgelist_weights] = - extract_if_e(handle, + extract_if_e(*handle_, mg_graph_view, mg_src_properties.device_view(), mg_dst_properties.device_view(), @@ -229,81 +217,81 @@ class Tests_MG_ExtractIfE if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG extract_if_e took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { - // 4-1. aggregate MG results + // 3-1. aggregate MG results auto mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*mg_renumber_map_labels).data(), (*mg_renumber_map_labels).size()); + *handle_, (*mg_renumber_map_labels).data(), (*mg_renumber_map_labels).size()); auto mg_aggregate_edgelist_srcs = - cugraph::test::device_gatherv(handle, mg_edgelist_srcs.data(), mg_edgelist_srcs.size()); + cugraph::test::device_gatherv(*handle_, mg_edgelist_srcs.data(), mg_edgelist_srcs.size()); auto mg_aggregate_edgelist_dsts = - cugraph::test::device_gatherv(handle, mg_edgelist_dsts.data(), mg_edgelist_dsts.size()); + cugraph::test::device_gatherv(*handle_, mg_edgelist_dsts.data(), mg_edgelist_dsts.size()); std::optional> mg_aggregate_edgelist_weights{std::nullopt}; if (mg_edgelist_weights) { mg_aggregate_edgelist_weights = cugraph::test::device_gatherv( - handle, (*mg_edgelist_weights).data(), (*mg_edgelist_weights).size()); + *handle_, (*mg_edgelist_weights).data(), (*mg_edgelist_weights).size()); } - if (handle.get_comms().get_rank() == int{0}) { - // 4-2. unrenumber MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 3-2. unrenumber MG results cugraph::unrenumber_int_vertices( - handle, + *handle_, mg_aggregate_edgelist_srcs.data(), mg_aggregate_edgelist_srcs.size(), mg_aggregate_renumber_map_labels.data(), std::vector{mg_graph_view.number_of_vertices()}); cugraph::unrenumber_int_vertices( - handle, + *handle_, mg_aggregate_edgelist_dsts.data(), mg_aggregate_edgelist_dsts.size(), mg_aggregate_renumber_map_labels.data(), std::vector{mg_graph_view.number_of_vertices()}); - // 4-3. create SG graph + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); - // 4-4. run SG extract_if_e + // 3-4. run SG extract_if_e auto sg_property_buffer = cugraph::allocate_dataframe_buffer( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); thrust::transform( - handle.get_thrust_policy(), + handle_->get_thrust_policy(), thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), cugraph::get_dataframe_buffer_begin(sg_property_buffer), property_transform_t{hash_bin_count}); cugraph::edge_partition_src_property_t - sg_src_properties(handle, sg_graph_view); + sg_src_properties(*handle_, sg_graph_view); cugraph::edge_partition_dst_property_t - sg_dst_properties(handle, sg_graph_view); + sg_dst_properties(*handle_, sg_graph_view); - update_edge_partition_src_property(handle, + update_edge_partition_src_property(*handle_, sg_graph_view, cugraph::get_dataframe_buffer_cbegin(sg_property_buffer), sg_src_properties); - update_edge_partition_dst_property(handle, + update_edge_partition_dst_property(*handle_, sg_graph_view, cugraph::get_dataframe_buffer_cbegin(sg_property_buffer), sg_dst_properties); auto [sg_edgelist_srcs, sg_edgelist_dsts, sg_edgelist_weights] = - extract_if_e(handle, + extract_if_e(*handle_, sg_graph_view, sg_src_properties.device_view(), sg_dst_properties.device_view(), @@ -311,7 +299,7 @@ class Tests_MG_ExtractIfE return src_val < dst_val; }); - // 4-5. compare + // 3-5. compare if (mg_graph_view.is_weighted()) { auto mg_edge_first = @@ -320,13 +308,13 @@ class Tests_MG_ExtractIfE (*mg_aggregate_edgelist_weights).begin())); auto sg_edge_first = thrust::make_zip_iterator(thrust::make_tuple( sg_edgelist_srcs.begin(), sg_edgelist_dsts.begin(), (*sg_edgelist_weights).begin())); - thrust::sort(handle.get_thrust_policy(), + thrust::sort(handle_->get_thrust_policy(), mg_edge_first, mg_edge_first + mg_aggregate_edgelist_srcs.size()); thrust::sort( - handle.get_thrust_policy(), sg_edge_first, sg_edge_first + sg_edgelist_srcs.size()); + handle_->get_thrust_policy(), sg_edge_first, sg_edge_first + sg_edgelist_srcs.size()); ASSERT_TRUE(thrust::equal( - handle.get_thrust_policy(), + handle_->get_thrust_policy(), mg_edge_first, mg_edge_first + mg_aggregate_edgelist_srcs.size(), sg_edge_first, @@ -337,13 +325,13 @@ class Tests_MG_ExtractIfE mg_aggregate_edgelist_srcs.begin(), mg_aggregate_edgelist_dsts.begin())); auto sg_edge_first = thrust::make_zip_iterator( thrust::make_tuple(sg_edgelist_srcs.begin(), sg_edgelist_dsts.begin())); - thrust::sort(handle.get_thrust_policy(), + thrust::sort(handle_->get_thrust_policy(), mg_edge_first, mg_edge_first + mg_aggregate_edgelist_srcs.size()); thrust::sort( - handle.get_thrust_policy(), sg_edge_first, sg_edge_first + sg_edgelist_srcs.size()); + handle_->get_thrust_policy(), sg_edge_first, sg_edge_first + sg_edgelist_srcs.size()); ASSERT_TRUE(thrust::equal( - handle.get_thrust_policy(), + handle_->get_thrust_policy(), mg_edge_first, mg_edge_first + mg_aggregate_edgelist_srcs.size(), sg_edge_first, @@ -353,19 +341,25 @@ class Tests_MG_ExtractIfE } } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_ExtractIfE_File = Tests_MG_ExtractIfE; -using Tests_MG_ExtractIfE_Rmat = Tests_MG_ExtractIfE; +template +std::unique_ptr Tests_MGExtractIfE::handle_ = nullptr; + +using Tests_MGExtractIfE_File = Tests_MGExtractIfE; +using Tests_MGExtractIfE_Rmat = Tests_MGExtractIfE; -TEST_P(Tests_MG_ExtractIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGExtractIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>( @@ -373,14 +367,14 @@ TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ExtractIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGExtractIfE_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>( @@ -388,54 +382,54 @@ TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ExtractIfE_File, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGExtractIfE_File, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int64FloatTransposeFalse) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt32Int64FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt64Int64FloatTransposeFalse) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt64Int64FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ExtractIfE_File, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGExtractIfE_File, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt32Int64FloatTransposeTrue) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt32Int64FloatTransposeTrue) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt64Int64FloatTransposeTrue) +TEST_P(Tests_MGExtractIfE_Rmat, CheckInt64Int64FloatTransposeTrue) { auto param = GetParam(); run_current_test( @@ -444,7 +438,7 @@ TEST_P(Tests_MG_ExtractIfE_Rmat, CheckInt64Int64FloatTransposeTrue) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_ExtractIfE_File, + Tests_MGExtractIfE_File, ::testing::Combine( ::testing::Values(Prims_Usecase{}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -453,7 +447,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_ExtractIfE_Rmat, + Tests_MGExtractIfE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); @@ -464,7 +458,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_ExtractIfE_Rmat, + Tests_MGExtractIfE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/prims/mg_per_v_transform_reduce_incoming_outgoing_e.cu b/cpp/tests/prims/mg_per_v_transform_reduce_incoming_outgoing_e.cu index b6132b9c870..8b4444bf9b3 100644 --- a/cpp/tests/prims/mg_per_v_transform_reduce_incoming_outgoing_e.cu +++ b/cpp/tests/prims/mg_per_v_transform_reduce_incoming_outgoing_e.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -226,12 +227,14 @@ struct Prims_Usecase { }; template -class Tests_MG_PerVTransformReduceIncomingOutgoingE +class Tests_MGPerVTransformReduceIncomingOutgoingE : public ::testing::TestWithParam> { public: - Tests_MG_PerVTransformReduceIncomingOutgoingE() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGPerVTransformReduceIncomingOutgoingE() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -244,37 +247,22 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE bool store_transposed> void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, prims_usecase.test_weighted, true); + *handle_, input_usecase, prims_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -282,7 +270,7 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE auto mg_graph_view = mg_graph.view(); - // 3. run MG transform reduce + // 2. run MG transform reduce const int hash_bin_count = 5; const int initial_value = 4; @@ -290,23 +278,23 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE auto property_initial_value = generate::initial_value(initial_value); using property_t = decltype(property_initial_value); auto vertex_property_data = - generate::vertex_property((*d_mg_renumber_map_labels), hash_bin_count, handle); + generate::vertex_property((*d_mg_renumber_map_labels), hash_bin_count, *handle_); auto col_prop = - generate::column_property(handle, mg_graph_view, vertex_property_data); - auto row_prop = generate::row_property(handle, mg_graph_view, vertex_property_data); + generate::column_property(*handle_, mg_graph_view, vertex_property_data); + auto row_prop = generate::row_property(*handle_, mg_graph_view, vertex_property_data); auto out_result = cugraph::allocate_dataframe_buffer( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); auto in_result = cugraph::allocate_dataframe_buffer( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } per_v_transform_reduce_incoming_e( - handle, + *handle_, mg_graph_view, row_prop.device_view(), col_prop.device_view(), @@ -322,7 +310,7 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG per_v_transform_reduce_incoming_e took " << elapsed_time * 1e-6 << " s.\n"; @@ -330,12 +318,12 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } per_v_transform_reduce_outgoing_e( - handle, + *handle_, mg_graph_view, row_prop.device_view(), col_prop.device_view(), @@ -351,36 +339,36 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG per_v_transform_reduce_outgoing_e took " << elapsed_time * 1e-6 << " s.\n"; } - //// 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); auto sg_vertex_property_data = generate::vertex_property( thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), hash_bin_count, - handle); + *handle_); auto sg_col_prop = - generate::column_property(handle, sg_graph_view, sg_vertex_property_data); + generate::column_property(*handle_, sg_graph_view, sg_vertex_property_data); auto sg_row_prop = - generate::row_property(handle, sg_graph_view, sg_vertex_property_data); - result_compare comp{handle}; + generate::row_property(*handle_, sg_graph_view, sg_vertex_property_data); + result_compare comp{*handle_}; auto global_out_result = cugraph::allocate_dataframe_buffer( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); per_v_transform_reduce_outgoing_e( - handle, + *handle_, sg_graph_view, sg_row_prop.device_view(), sg_col_prop.device_view(), @@ -395,9 +383,9 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE cugraph::get_dataframe_buffer_begin(global_out_result)); auto global_in_result = cugraph::allocate_dataframe_buffer( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); per_v_transform_reduce_incoming_e( - handle, + *handle_, sg_graph_view, sg_row_prop.device_view(), sg_col_prop.device_view(), @@ -410,27 +398,34 @@ class Tests_MG_PerVTransformReduceIncomingOutgoingE }, property_initial_value, cugraph::get_dataframe_buffer_begin(global_in_result)); - auto aggregate_labels = aggregate(handle, *d_mg_renumber_map_labels); - auto aggregate_out_results = aggregate(handle, out_result); - auto aggregate_in_results = aggregate(handle, in_result); - if (handle.get_comms().get_rank() == int{0}) { + auto aggregate_labels = aggregate(*handle_, *d_mg_renumber_map_labels); + auto aggregate_out_results = aggregate(*handle_, out_result); + auto aggregate_in_results = aggregate(*handle_, in_result); + if (handle_->get_comms().get_rank() == int{0}) { std::tie(std::ignore, aggregate_out_results) = - cugraph::test::sort_by_key(handle, aggregate_labels, aggregate_out_results); + cugraph::test::sort_by_key(*handle_, aggregate_labels, aggregate_out_results); std::tie(std::ignore, aggregate_in_results) = - cugraph::test::sort_by_key(handle, aggregate_labels, aggregate_in_results); + cugraph::test::sort_by_key(*handle_, aggregate_labels, aggregate_in_results); ASSERT_TRUE(comp(aggregate_out_results, global_out_result)); ASSERT_TRUE(comp(aggregate_in_results, global_in_result)); } } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_PerVTransformReduceIncomingOutgoingE_File = - Tests_MG_PerVTransformReduceIncomingOutgoingE; -using Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat = - Tests_MG_PerVTransformReduceIncomingOutgoingE; +template +std::unique_ptr + Tests_MGPerVTransformReduceIncomingOutgoingE::handle_ = nullptr; + +using Tests_MGPerVTransformReduceIncomingOutgoingE_File = + Tests_MGPerVTransformReduceIncomingOutgoingE; +using Tests_MGPerVTransformReduceIncomingOutgoingE_Rmat = + Tests_MGPerVTransformReduceIncomingOutgoingE; -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_File, +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); @@ -438,7 +433,7 @@ TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_File, std::get<1>(param)); } -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); @@ -447,7 +442,7 @@ TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_File, +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); @@ -455,7 +450,7 @@ TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_File, std::get<1>(param)); } -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); @@ -464,13 +459,13 @@ TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_File, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_File, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test( @@ -478,13 +473,13 @@ TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatT cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_File, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_File, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGPerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test( @@ -494,7 +489,7 @@ TEST_P(Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, CheckInt32Int32FloatT INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_PerVTransformReduceIncomingOutgoingE_File, + Tests_MGPerVTransformReduceIncomingOutgoingE_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -504,14 +499,14 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, + Tests_MGPerVTransformReduceIncomingOutgoingE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); INSTANTIATE_TEST_SUITE_P( rmat_large_test, - Tests_MG_PerVTransformReduceIncomingOutgoingE_Rmat, + Tests_MGPerVTransformReduceIncomingOutgoingE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/prims/mg_reduce_v.cu b/cpp/tests/prims/mg_reduce_v.cu index 2b240d5adae..e488bf2bf4f 100644 --- a/cpp/tests/prims/mg_reduce_v.cu +++ b/cpp/tests/prims/mg_reduce_v.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ struct property_transform : public thrust::unary_function(value)...); } }; + template typename Tuple, typename... Args> struct property_transform> : public property_transform { }; @@ -185,12 +187,14 @@ struct Prims_Usecase { }; template -class Tests_MG_ReduceV +class Tests_MGReduceV : public ::testing::TestWithParam> { public: - Tests_MG_ReduceV() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGReduceV() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -203,38 +207,23 @@ class Tests_MG_ReduceV bool store_transposed> void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true); + *handle_, input_usecase, true, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -242,7 +231,7 @@ class Tests_MG_ReduceV auto mg_graph_view = mg_graph.view(); - // 3. run MG reduce_v + // 2. run MG reduce_v const int hash_bin_count = 5; const int initial_value = 10; @@ -250,7 +239,7 @@ class Tests_MG_ReduceV auto property_initial_value = generate::initial_value(initial_value); using property_t = decltype(property_initial_value); auto property_data = - generate::property((*d_mg_renumber_map_labels), hash_bin_count, handle); + generate::property((*d_mg_renumber_map_labels), hash_bin_count, *handle_); auto property_iter = get_property_iterator(property_data); enum class reduction_type_t { PLUS, MINIMUM, MAXIMUM }; @@ -262,27 +251,27 @@ class Tests_MG_ReduceV for (auto reduction_type : reduction_types) { if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } switch (reduction_type) { case reduction_type_t::PLUS: - results[reduction_type] = reduce_v(handle, + results[reduction_type] = reduce_v(*handle_, mg_graph_view, property_iter, property_initial_value, cugraph::reduce_op::plus{}); break; case reduction_type_t::MINIMUM: - results[reduction_type] = reduce_v(handle, + results[reduction_type] = reduce_v(*handle_, mg_graph_view, property_iter, property_initial_value, cugraph::reduce_op::minimum{}); break; case reduction_type_t::MAXIMUM: - results[reduction_type] = reduce_v(handle, + results[reduction_type] = reduce_v(*handle_, mg_graph_view, property_iter, property_initial_value, @@ -293,48 +282,48 @@ class Tests_MG_ReduceV if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG reduce_v took " << elapsed_time * 1e-6 << " s.\n"; } } - // 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); auto sg_property_data = generate::property( thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), hash_bin_count, - handle); + *handle_); auto sg_property_iter = get_property_iterator(sg_property_data); for (auto reduction_type : reduction_types) { property_t expected_result{}; switch (reduction_type) { case reduction_type_t::PLUS: - expected_result = reduce_v(handle, + expected_result = reduce_v(*handle_, sg_graph_view, sg_property_iter, property_initial_value, cugraph::reduce_op::plus{}); break; case reduction_type_t::MINIMUM: - expected_result = reduce_v(handle, + expected_result = reduce_v(*handle_, sg_graph_view, sg_property_iter, property_initial_value, cugraph::reduce_op::minimum{}); break; case reduction_type_t::MAXIMUM: - expected_result = reduce_v(handle, + expected_result = reduce_v(*handle_, sg_graph_view, sg_property_iter, property_initial_value, @@ -347,19 +336,25 @@ class Tests_MG_ReduceV } } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_ReduceV_File = Tests_MG_ReduceV; -using Tests_MG_ReduceV_Rmat = Tests_MG_ReduceV; +template +std::unique_ptr Tests_MGReduceV::handle_ = nullptr; + +using Tests_MGReduceV_File = Tests_MGReduceV; +using Tests_MGReduceV_Rmat = Tests_MGReduceV; -TEST_P(Tests_MG_ReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>( @@ -367,14 +362,14 @@ TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>( @@ -382,54 +377,54 @@ TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ReduceV_File, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGReduceV_File, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGReduceV_Rmat, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int64FloatTransposeFalse) +TEST_P(Tests_MGReduceV_Rmat, CheckInt32Int64FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt64Int64FloatTransposeFalse) +TEST_P(Tests_MGReduceV_Rmat, CheckInt64Int64FloatTransposeFalse) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ReduceV_File, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGReduceV_File, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGReduceV_Rmat, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt32Int64FloatTransposeTrue) +TEST_P(Tests_MGReduceV_Rmat, CheckInt32Int64FloatTransposeTrue) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_ReduceV_Rmat, CheckInt64Int64FloatTransposeTrue) +TEST_P(Tests_MGReduceV_Rmat, CheckInt64Int64FloatTransposeTrue) { auto param = GetParam(); run_current_test( @@ -438,7 +433,7 @@ TEST_P(Tests_MG_ReduceV_Rmat, CheckInt64Int64FloatTransposeTrue) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_ReduceV_File, + Tests_MGReduceV_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -447,7 +442,7 @@ INSTANTIATE_TEST_SUITE_P( cugraph::test::File_Usecase("test/datasets/webbase-1M.mtx")))); INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_ReduceV_Rmat, + Tests_MGReduceV_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); @@ -458,7 +453,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_ReduceV_Rmat, + Tests_MGReduceV_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/prims/mg_transform_reduce_e.cu b/cpp/tests/prims/mg_transform_reduce_e.cu index aad921e278d..064b6ae21a2 100644 --- a/cpp/tests/prims/mg_transform_reduce_e.cu +++ b/cpp/tests/prims/mg_transform_reduce_e.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -208,12 +209,14 @@ struct Prims_Usecase { }; template -class Tests_MG_TransformReduceE +class Tests_MGTransformReduceE : public ::testing::TestWithParam> { public: - Tests_MG_TransformReduceE() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGTransformReduceE() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -226,37 +229,22 @@ class Tests_MG_TransformReduceE bool store_transposed> void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, prims_usecase.test_weighted, true); + *handle_, input_usecase, prims_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -264,7 +252,7 @@ class Tests_MG_TransformReduceE auto mg_graph_view = mg_graph.view(); - // 3. run MG transform reduce + // 2. run MG transform reduce const int hash_bin_count = 5; const int initial_value = 4; @@ -272,19 +260,19 @@ class Tests_MG_TransformReduceE auto property_initial_value = generate::initial_value(initial_value); using property_t = decltype(property_initial_value); auto vertex_property_data = - generate::vertex_property((*d_mg_renumber_map_labels), hash_bin_count, handle); + generate::vertex_property((*d_mg_renumber_map_labels), hash_bin_count, *handle_); auto col_prop = - generate::column_property(handle, mg_graph_view, vertex_property_data); - auto row_prop = generate::row_property(handle, mg_graph_view, vertex_property_data); + generate::column_property(*handle_, mg_graph_view, vertex_property_data); + auto row_prop = generate::row_property(*handle_, mg_graph_view, vertex_property_data); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto result = transform_reduce_e( - handle, + *handle_, mg_graph_view, row_prop.device_view(), col_prop.device_view(), @@ -299,33 +287,33 @@ class Tests_MG_TransformReduceE if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG transform reduce took " << elapsed_time * 1e-6 << " s.\n"; } - //// 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); auto sg_vertex_property_data = generate::vertex_property( thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), hash_bin_count, - handle); + *handle_); auto sg_col_prop = - generate::column_property(handle, sg_graph_view, sg_vertex_property_data); + generate::column_property(*handle_, sg_graph_view, sg_vertex_property_data); auto sg_row_prop = - generate::row_property(handle, sg_graph_view, sg_vertex_property_data); + generate::row_property(*handle_, sg_graph_view, sg_vertex_property_data); auto expected_result = transform_reduce_e( - handle, + *handle_, sg_graph_view, sg_row_prop.device_view(), sg_col_prop.device_view(), @@ -341,19 +329,25 @@ class Tests_MG_TransformReduceE ASSERT_TRUE(compare(expected_result, result)); } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_TransformReduceE_File = Tests_MG_TransformReduceE; -using Tests_MG_TransformReduceE_Rmat = Tests_MG_TransformReduceE; +template +std::unique_ptr Tests_MGTransformReduceE::handle_ = nullptr; + +using Tests_MGTransformReduceE_File = Tests_MGTransformReduceE; +using Tests_MGTransformReduceE_Rmat = Tests_MGTransformReduceE; -TEST_P(Tests_MG_TransformReduceE_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGTransformReduceE_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGTransformReduceE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>( @@ -361,14 +355,14 @@ TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTupleIntFloatTranspos cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceE_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGTransformReduceE_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGTransformReduceE_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>( @@ -376,13 +370,13 @@ TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTupleIntFloatTranspos cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceE_File, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGTransformReduceE_File, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGTransformReduceE_Rmat, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test( @@ -390,13 +384,13 @@ TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTransposeFalse) cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceE_File, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGTransformReduceE_File, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGTransformReduceE_Rmat, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test( @@ -406,7 +400,7 @@ TEST_P(Tests_MG_TransformReduceE_Rmat, CheckInt32Int32FloatTransposeTrue) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_TransformReduceE_File, + Tests_MGTransformReduceE_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -416,14 +410,14 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_TransformReduceE_Rmat, + Tests_MGTransformReduceE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); INSTANTIATE_TEST_SUITE_P( rmat_large_test, - Tests_MG_TransformReduceE_Rmat, + Tests_MGTransformReduceE_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/prims/mg_transform_reduce_v.cu b/cpp/tests/prims/mg_transform_reduce_v.cu index 38742c721cc..d7b2f18cdd8 100644 --- a/cpp/tests/prims/mg_transform_reduce_v.cu +++ b/cpp/tests/prims/mg_transform_reduce_v.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -129,12 +130,14 @@ struct Prims_Usecase { }; template -class Tests_MG_TransformReduceV +class Tests_MGTransformReduceV : public ::testing::TestWithParam> { public: - Tests_MG_TransformReduceV() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGTransformReduceV() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -147,37 +150,22 @@ class Tests_MG_TransformReduceV bool store_transposed> void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true); + *handle_, input_usecase, true, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -185,7 +173,7 @@ class Tests_MG_TransformReduceV auto mg_graph_view = mg_graph.view(); - // 3. run MG transform reduce + // 2. run MG transform reduce const int hash_bin_count = 5; const int initial_value = 10; @@ -202,13 +190,13 @@ class Tests_MG_TransformReduceV for (auto reduction_type : reduction_types) { if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } switch (reduction_type) { case reduction_type_t::PLUS: - results[reduction_type] = transform_reduce_v(handle, + results[reduction_type] = transform_reduce_v(*handle_, mg_graph_view, d_mg_renumber_map_labels->begin(), prop, @@ -216,7 +204,7 @@ class Tests_MG_TransformReduceV cugraph::reduce_op::plus{}); break; case reduction_type_t::MINIMUM: - results[reduction_type] = transform_reduce_v(handle, + results[reduction_type] = transform_reduce_v(*handle_, mg_graph_view, d_mg_renumber_map_labels->begin(), prop, @@ -224,7 +212,7 @@ class Tests_MG_TransformReduceV cugraph::reduce_op::minimum{}); break; case reduction_type_t::MAXIMUM: - results[reduction_type] = transform_reduce_v(handle, + results[reduction_type] = transform_reduce_v(*handle_, mg_graph_view, d_mg_renumber_map_labels->begin(), prop, @@ -236,20 +224,20 @@ class Tests_MG_TransformReduceV if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG transform reduce took " << elapsed_time * 1e-6 << " s.\n"; } } - // 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); for (auto reduction_type : reduction_types) { @@ -257,7 +245,7 @@ class Tests_MG_TransformReduceV switch (reduction_type) { case reduction_type_t::PLUS: expected_result = transform_reduce_v( - handle, + *handle_, sg_graph_view, thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), prop, @@ -266,7 +254,7 @@ class Tests_MG_TransformReduceV break; case reduction_type_t::MINIMUM: expected_result = transform_reduce_v( - handle, + *handle_, sg_graph_view, thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), prop, @@ -275,7 +263,7 @@ class Tests_MG_TransformReduceV break; case reduction_type_t::MAXIMUM: expected_result = transform_reduce_v( - handle, + *handle_, sg_graph_view, thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), prop, @@ -289,19 +277,25 @@ class Tests_MG_TransformReduceV } } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_TransformReduceV_File = Tests_MG_TransformReduceV; -using Tests_MG_TransformReduceV_Rmat = Tests_MG_TransformReduceV; +template +std::unique_ptr Tests_MGTransformReduceV::handle_ = nullptr; + +using Tests_MGTransformReduceV_File = Tests_MGTransformReduceV; +using Tests_MGTransformReduceV_Rmat = Tests_MGTransformReduceV; -TEST_P(Tests_MG_TransformReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGTransformReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) +TEST_P(Tests_MGTransformReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeFalse) { auto param = GetParam(); run_current_test, false>( @@ -309,14 +303,14 @@ TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTranspos cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGTransformReduceV_File, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) +TEST_P(Tests_MGTransformReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTransposeTrue) { auto param = GetParam(); run_current_test, true>( @@ -324,13 +318,13 @@ TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTupleIntFloatTranspos cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceV_File, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGTransformReduceV_File, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTransposeFalse) +TEST_P(Tests_MGTransformReduceV_Rmat, CheckInt32Int32FloatTransposeFalse) { auto param = GetParam(); run_current_test( @@ -338,13 +332,13 @@ TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTransposeFalse) cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceV_File, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGTransformReduceV_File, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTransposeTrue) +TEST_P(Tests_MGTransformReduceV_Rmat, CheckInt32Int32FloatTransposeTrue) { auto param = GetParam(); run_current_test( @@ -354,7 +348,7 @@ TEST_P(Tests_MG_TransformReduceV_Rmat, CheckInt32Int32FloatTransposeTrue) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_TransformReduceV_File, + Tests_MGTransformReduceV_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -364,14 +358,14 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_TransformReduceV_Rmat, + Tests_MGTransformReduceV_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); INSTANTIATE_TEST_SUITE_P( rmat_large_test, - Tests_MG_TransformReduceV_Rmat, + Tests_MGTransformReduceV_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/prims/mg_transform_reduce_v_frontier_outgoing_e_by_dst.cu b/cpp/tests/prims/mg_transform_reduce_v_frontier_outgoing_e_by_dst.cu index a894e6ba693..8beed65fa86 100644 --- a/cpp/tests/prims/mg_transform_reduce_v_frontier_outgoing_e_by_dst.cu +++ b/cpp/tests/prims/mg_transform_reduce_v_frontier_outgoing_e_by_dst.cu @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -122,12 +123,14 @@ struct Prims_Usecase { }; template -class Tests_MG_TransformReduceVFrontierOutgoingEByDst +class Tests_MGTransformReduceVFrontierOutgoingEByDst : public ::testing::TestWithParam> { public: - Tests_MG_TransformReduceVFrontierOutgoingEByDst() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGTransformReduceVFrontierOutgoingEByDst() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -152,24 +155,9 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst static_assert(thrust::tuple_size::value == size_t{2}); } - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph constexpr bool is_multi_gpu = true; constexpr bool renumber = true; // needs to be true for multi gpu case @@ -177,17 +165,17 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst false; // needs to be false for using transform_reduce_v_frontier_outgoing_e_by_dst if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, false, renumber); + *handle_, input_usecase, false, renumber); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -195,42 +183,42 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst auto mg_graph_view = mg_graph.view(); - // 3. run MG transform reduce + // 2. run MG transform reduce const int hash_bin_count = 5; auto mg_property_buffer = cugraph::allocate_dataframe_buffer( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); - thrust::transform(handle.get_thrust_policy(), + thrust::transform(handle_->get_thrust_policy(), (*mg_renumber_map_labels).begin(), (*mg_renumber_map_labels).end(), cugraph::get_dataframe_buffer_begin(mg_property_buffer), property_transform_t{hash_bin_count}); cugraph::edge_partition_src_property_t mg_src_properties( - handle, mg_graph_view); + *handle_, mg_graph_view); cugraph::edge_partition_dst_property_t mg_dst_properties( - handle, mg_graph_view); + *handle_, mg_graph_view); - update_edge_partition_src_property(handle, + update_edge_partition_src_property(*handle_, mg_graph_view, cugraph::get_dataframe_buffer_cbegin(mg_property_buffer), mg_src_properties); - update_edge_partition_dst_property(handle, + update_edge_partition_dst_property(*handle_, mg_graph_view, cugraph::get_dataframe_buffer_cbegin(mg_property_buffer), mg_dst_properties); auto mg_key_buffer = cugraph::allocate_dataframe_buffer( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); if constexpr (std::is_same_v) { - thrust::sequence(handle.get_thrust_policy(), + thrust::sequence(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(mg_key_buffer), cugraph::get_dataframe_buffer_end(mg_key_buffer), mg_graph_view.local_vertex_partition_range_first()); } else { - thrust::tabulate(handle.get_thrust_policy(), + thrust::tabulate(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(mg_key_buffer), cugraph::get_dataframe_buffer_end(mg_key_buffer), [mg_renumber_map_labels = (*mg_renumber_map_labels).data(), @@ -245,7 +233,7 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst constexpr size_t bucket_idx_cur = 0; constexpr size_t num_buckets = 1; - cugraph::vertex_frontier_t mg_vertex_frontier(handle, + cugraph::vertex_frontier_t mg_vertex_frontier(*handle_, num_buckets); mg_vertex_frontier.bucket(bucket_idx_cur) .insert(cugraph::get_dataframe_buffer_begin(mg_key_buffer), @@ -253,18 +241,18 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto mg_new_frontier_key_buffer = - cugraph::allocate_dataframe_buffer(0, handle.get_stream()); + cugraph::allocate_dataframe_buffer(0, handle_->get_stream()); [[maybe_unused]] auto mg_payload_buffer = - cugraph::detail::allocate_optional_payload_buffer(0, handle.get_stream()); + cugraph::detail::allocate_optional_payload_buffer(0, handle_->get_stream()); if constexpr (std::is_same_v) { mg_new_frontier_key_buffer = cugraph::transform_reduce_v_frontier_outgoing_e_by_dst( - handle, + *handle_, mg_graph_view, mg_vertex_frontier, bucket_idx_cur, @@ -275,7 +263,7 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst } else { std::tie(mg_new_frontier_key_buffer, mg_payload_buffer) = cugraph::transform_reduce_v_frontier_outgoing_e_by_dst( - handle, + *handle_, mg_graph_view, mg_vertex_frontier, bucket_idx_cur, @@ -287,60 +275,60 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG transform_reduce_v_frontier_outgoing_e_by_dst took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. compare SG & MG results + // 3. compare SG & MG results if (prims_usecase.check_correctness) { auto mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*mg_renumber_map_labels).data(), (*mg_renumber_map_labels).size()); + *handle_, (*mg_renumber_map_labels).data(), (*mg_renumber_map_labels).size()); auto mg_aggregate_new_frontier_key_buffer = - cugraph::allocate_dataframe_buffer(0, handle.get_stream()); + cugraph::allocate_dataframe_buffer(0, handle_->get_stream()); if constexpr (std::is_same_v) { mg_aggregate_new_frontier_key_buffer = cugraph::test::device_gatherv( - handle, mg_new_frontier_key_buffer.data(), mg_new_frontier_key_buffer.size()); + *handle_, mg_new_frontier_key_buffer.data(), mg_new_frontier_key_buffer.size()); } else { std::get<0>(mg_aggregate_new_frontier_key_buffer) = - cugraph::test::device_gatherv(handle, + cugraph::test::device_gatherv(*handle_, std::get<0>(mg_new_frontier_key_buffer).data(), std::get<0>(mg_new_frontier_key_buffer).size()); std::get<1>(mg_aggregate_new_frontier_key_buffer) = - cugraph::test::device_gatherv(handle, + cugraph::test::device_gatherv(*handle_, std::get<1>(mg_new_frontier_key_buffer).data(), std::get<1>(mg_new_frontier_key_buffer).size()); } [[maybe_unused]] auto mg_aggregate_payload_buffer = - cugraph::detail::allocate_optional_payload_buffer(0, handle.get_stream()); + cugraph::detail::allocate_optional_payload_buffer(0, handle_->get_stream()); if constexpr (!std::is_same_v) { if constexpr (std::is_arithmetic_v) { mg_aggregate_payload_buffer = cugraph::test::device_gatherv( - handle, mg_payload_buffer.data(), mg_payload_buffer.size()); + *handle_, mg_payload_buffer.data(), mg_payload_buffer.size()); } else { std::get<0>(mg_aggregate_payload_buffer) = cugraph::test::device_gatherv( - handle, std::get<0>(mg_payload_buffer).data(), std::get<0>(mg_payload_buffer).size()); + *handle_, std::get<0>(mg_payload_buffer).data(), std::get<0>(mg_payload_buffer).size()); std::get<1>(mg_aggregate_payload_buffer) = cugraph::test::device_gatherv( - handle, std::get<1>(mg_payload_buffer).data(), std::get<1>(mg_payload_buffer).size()); + *handle_, std::get<1>(mg_payload_buffer).data(), std::get<1>(mg_payload_buffer).size()); } } - if (handle.get_comms().get_rank() == int{0}) { + if (handle_->get_comms().get_rank() == int{0}) { if constexpr (std::is_same_v) { cugraph::unrenumber_int_vertices( - handle, + *handle_, mg_aggregate_new_frontier_key_buffer.begin(), mg_aggregate_new_frontier_key_buffer.size(), mg_aggregate_renumber_map_labels.data(), std::vector{mg_graph_view.number_of_vertices()}); } else { cugraph::unrenumber_int_vertices( - handle, + *handle_, std::get<0>(mg_aggregate_new_frontier_key_buffer).begin(), std::get<0>(mg_aggregate_new_frontier_key_buffer).size(), mg_aggregate_renumber_map_labels.data(), @@ -348,56 +336,56 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst } if constexpr (std::is_same_v) { - thrust::sort(handle.get_thrust_policy(), + thrust::sort(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(mg_aggregate_new_frontier_key_buffer), cugraph::get_dataframe_buffer_end(mg_aggregate_new_frontier_key_buffer)); } else { thrust::sort_by_key( - handle.get_thrust_policy(), + handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(mg_aggregate_new_frontier_key_buffer), cugraph::get_dataframe_buffer_end(mg_aggregate_new_frontier_key_buffer), cugraph::get_dataframe_buffer_begin(mg_aggregate_payload_buffer)); } cugraph::graph_t sg_graph( - handle); + *handle_); std::tie(sg_graph, std::ignore) = cugraph::test:: construct_graph( - handle, input_usecase, false, false); + *handle_, input_usecase, false, false); auto sg_graph_view = sg_graph.view(); auto sg_property_buffer = cugraph::allocate_dataframe_buffer( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); thrust::transform( - handle.get_thrust_policy(), + handle_->get_thrust_policy(), thrust::make_counting_iterator(vertex_t{0}), thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_size()), cugraph::get_dataframe_buffer_begin(sg_property_buffer), property_transform_t{hash_bin_count}); cugraph::edge_partition_src_property_t - sg_src_properties(handle, sg_graph_view); + sg_src_properties(*handle_, sg_graph_view); cugraph::edge_partition_dst_property_t - sg_dst_properties(handle, sg_graph_view); - update_edge_partition_src_property(handle, + sg_dst_properties(*handle_, sg_graph_view); + update_edge_partition_src_property(*handle_, sg_graph_view, cugraph::get_dataframe_buffer_cbegin(sg_property_buffer), sg_src_properties); - update_edge_partition_dst_property(handle, + update_edge_partition_dst_property(*handle_, sg_graph_view, cugraph::get_dataframe_buffer_cbegin(sg_property_buffer), sg_dst_properties); auto sg_key_buffer = cugraph::allocate_dataframe_buffer( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); if constexpr (std::is_same_v) { - thrust::sequence(handle.get_thrust_policy(), + thrust::sequence(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(sg_key_buffer), cugraph::get_dataframe_buffer_end(sg_key_buffer), sg_graph_view.local_vertex_partition_range_first()); } else { - thrust::tabulate(handle.get_thrust_policy(), + thrust::tabulate(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(sg_key_buffer), cugraph::get_dataframe_buffer_end(sg_key_buffer), [] __device__(size_t i) { @@ -407,19 +395,19 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst }); } - cugraph::vertex_frontier_t sg_vertex_frontier(handle, + cugraph::vertex_frontier_t sg_vertex_frontier(*handle_, num_buckets); sg_vertex_frontier.bucket(bucket_idx_cur) .insert(cugraph::get_dataframe_buffer_begin(sg_key_buffer), cugraph::get_dataframe_buffer_end(sg_key_buffer)); auto sg_new_frontier_key_buffer = - cugraph::allocate_dataframe_buffer(0, handle.get_stream()); + cugraph::allocate_dataframe_buffer(0, handle_->get_stream()); [[maybe_unused]] auto sg_payload_buffer = - cugraph::detail::allocate_optional_payload_buffer(0, handle.get_stream()); + cugraph::detail::allocate_optional_payload_buffer(0, handle_->get_stream()); if constexpr (std::is_same_v) { sg_new_frontier_key_buffer = cugraph::transform_reduce_v_frontier_outgoing_e_by_dst( - handle, + *handle_, sg_graph_view, sg_vertex_frontier, bucket_idx_cur, @@ -430,7 +418,7 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst } else { std::tie(sg_new_frontier_key_buffer, sg_payload_buffer) = cugraph::transform_reduce_v_frontier_outgoing_e_by_dst( - handle, + *handle_, sg_graph_view, sg_vertex_frontier, bucket_idx_cur, @@ -441,18 +429,18 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst } if constexpr (std::is_same_v) { - thrust::sort(handle.get_thrust_policy(), + thrust::sort(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(sg_new_frontier_key_buffer), cugraph::get_dataframe_buffer_end(sg_new_frontier_key_buffer)); } else { - thrust::sort_by_key(handle.get_thrust_policy(), + thrust::sort_by_key(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(sg_new_frontier_key_buffer), cugraph::get_dataframe_buffer_end(sg_new_frontier_key_buffer), cugraph::get_dataframe_buffer_begin(sg_payload_buffer)); } bool key_passed = - thrust::equal(handle.get_thrust_policy(), + thrust::equal(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(sg_new_frontier_key_buffer), cugraph::get_dataframe_buffer_end(sg_new_frontier_key_buffer), cugraph::get_dataframe_buffer_begin(mg_aggregate_new_frontier_key_buffer)); @@ -460,7 +448,7 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst if constexpr (!std::is_same_v) { bool payload_passed = - thrust::equal(handle.get_thrust_policy(), + thrust::equal(handle_->get_thrust_policy(), cugraph::get_dataframe_buffer_begin(sg_payload_buffer), cugraph::get_dataframe_buffer_begin(sg_payload_buffer), cugraph::get_dataframe_buffer_end(mg_aggregate_payload_buffer)); @@ -469,20 +457,27 @@ class Tests_MG_TransformReduceVFrontierOutgoingEByDst } } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_TransformReduceVFrontierOutgoingEByDst_File = - Tests_MG_TransformReduceVFrontierOutgoingEByDst; -using Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat = - Tests_MG_TransformReduceVFrontierOutgoingEByDst; +template +std::unique_ptr + Tests_MGTransformReduceVFrontierOutgoingEByDst::handle_ = nullptr; + +using Tests_MGTransformReduceVFrontierOutgoingEByDst_File = + Tests_MGTransformReduceVFrontierOutgoingEByDst; +using Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat = + Tests_MGTransformReduceVFrontierOutgoingEByDst; -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatVoidVoid) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatVoidVoid) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatVoidVoid) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatVoidVoid) { auto param = GetParam(); run_current_test( @@ -490,13 +485,13 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32Floa cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatVoidInt32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatVoidInt32) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatVoidInt32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatVoidInt32) { auto param = GetParam(); run_current_test( @@ -504,16 +499,14 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32Floa cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, - CheckInt32Int32FloatVoidTupleFloatInt32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatVoidTupleFloatInt32) { auto param = GetParam(); run_current_test>( std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, - CheckInt32Int32FloatVoidTupleFloatInt32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatVoidTupleFloatInt32) { auto param = GetParam(); run_current_test>( @@ -521,13 +514,13 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatInt32Void) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatInt32Void) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatInt32Void) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatInt32Void) { auto param = GetParam(); run_current_test( @@ -535,14 +528,14 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32Floa cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatInt32Int32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatInt32Int32) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatInt32Int32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatInt32Int32) { auto param = GetParam(); run_current_test( @@ -550,7 +543,7 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32Floa cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int32FloatInt32TupleFloatInt32) { auto param = GetParam(); @@ -558,7 +551,7 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int32FloatInt32TupleFloatInt32) { auto param = GetParam(); @@ -567,14 +560,14 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int64FloatInt32Int32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt32Int64FloatInt32Int32) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int64FloatInt32Int32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int64FloatInt32Int32) { auto param = GetParam(); run_current_test( @@ -582,14 +575,14 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt32Int64Floa cugraph::test::override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, CheckInt64Int64FloatInt32Int32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_File, CheckInt64Int64FloatInt32Int32) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt64Int64FloatInt32Int32) +TEST_P(Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt64Int64FloatInt32Int32) { auto param = GetParam(); run_current_test( @@ -599,7 +592,7 @@ TEST_P(Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, CheckInt64Int64Floa INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_TransformReduceVFrontierOutgoingEByDst_File, + Tests_MGTransformReduceVFrontierOutgoingEByDst_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -609,7 +602,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, + Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); @@ -620,7 +613,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_TransformReduceVFrontierOutgoingEByDst_Rmat, + Tests_MGTransformReduceVFrontierOutgoingEByDst_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/sampling/detail/mg_gather_one_hop.cu b/cpp/tests/sampling/detail/mg_gather_one_hop.cu index 11e3df78f8e..09329967b1f 100644 --- a/cpp/tests/sampling/detail/mg_gather_one_hop.cu +++ b/cpp/tests/sampling/detail/mg_gather_one_hop.cu @@ -18,17 +18,19 @@ #include +#include + #include #include -#include - #include #include #include #include #include +#include + struct Prims_Usecase { bool check_correctness{true}; }; @@ -38,8 +40,10 @@ class Tests_MG_GatherEdges : public ::testing::TestWithParam> { public: Tests_MG_GatherEdges() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -47,29 +51,13 @@ class Tests_MG_GatherEdges template void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - using namespace cugraph::test; - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } @@ -77,11 +65,11 @@ class Tests_MG_GatherEdges auto [mg_graph, mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true, false, sort_adjacency_list); + *handle_, input_usecase, true, true, false, sort_adjacency_list); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -91,15 +79,15 @@ class Tests_MG_GatherEdges constexpr vertex_t repetitions_per_vertex = 5; constexpr vertex_t source_sample_count = 3; - // 3. Gather mnmg call + // 2. Gather mnmg call // Generate random vertex ids in the range of current gpu auto [global_degree_offsets, global_out_degrees] = - cugraph::detail::get_global_degree_information(handle, mg_graph_view); + cugraph::detail::get_global_degree_information(*handle_, mg_graph_view); // Generate random sources to gather on auto random_sources = - cugraph::test::random_vertex_ids(handle, + cugraph::test::random_vertex_ids(*handle_, mg_graph_view.local_vertex_partition_range_first(), mg_graph_view.local_vertex_partition_range_last(), std::min(mg_graph_view.local_vertex_partition_range_size() * @@ -110,38 +98,38 @@ class Tests_MG_GatherEdges // FIXME: allgather is probably a poor name for this function. // It's really an allgather across the row communicator auto active_sources = - cugraph::detail::allgather_active_majors(handle, std::move(random_sources)); + cugraph::detail::allgather_active_majors(*handle_, std::move(random_sources)); auto [src, dst, edge_ids] = - cugraph::detail::gather_one_hop_edgelist(handle, mg_graph_view, active_sources); + cugraph::detail::gather_one_hop_edgelist(*handle_, mg_graph_view, active_sources); if (prims_usecase.check_correctness) { // Gather outputs to gpu 0 auto mg_out_srcs = cugraph::test::device_gatherv( - handle, raft::device_span{src.data(), src.size()}); + *handle_, raft::device_span{src.data(), src.size()}); auto mg_out_dsts = cugraph::test::device_gatherv( - handle, raft::device_span{dst.data(), dst.size()}); + *handle_, raft::device_span{dst.data(), dst.size()}); // Gather relevant edges from graph - auto& col_comm = handle.get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); + auto& col_comm = handle_->get_subcomm(cugraph::partition_2d::key_naming_t().col_name()); auto const col_rank = col_comm.get_rank(); auto all_active_sources = cugraph::test::device_allgatherv( - handle, + *handle_, raft::device_span{active_sources.data(), col_rank == 0 ? active_sources.size() : 0}); thrust::sort( - handle.get_thrust_policy(), all_active_sources.begin(), all_active_sources.end()); + handle_->get_thrust_policy(), all_active_sources.begin(), all_active_sources.end()); // Gather input graph edgelist - rmm::device_uvector sg_src(0, handle.get_stream()); - rmm::device_uvector sg_dst(0, handle.get_stream()); + rmm::device_uvector sg_src(0, handle_->get_stream()); + rmm::device_uvector sg_dst(0, handle_->get_stream()); std::tie(sg_src, sg_dst, std::ignore) = - mg_graph_view.decompress_to_edgelist(handle, std::nullopt); + mg_graph_view.decompress_to_edgelist(*handle_, std::nullopt); auto begin_iter = thrust::make_zip_iterator(sg_src.begin(), sg_dst.begin()); auto new_end = thrust::remove_if( - handle.get_thrust_policy(), + handle_->get_thrust_policy(), begin_iter, begin_iter + sg_src.size(), [sources = all_active_sources.data(), size = all_active_sources.size()] __device__(auto t) { @@ -149,51 +137,57 @@ class Tests_MG_GatherEdges return !thrust::binary_search(thrust::seq, sources, sources + size, src); }); - sg_src.resize(thrust::distance(begin_iter, new_end), handle.get_stream()); - sg_dst.resize(thrust::distance(begin_iter, new_end), handle.get_stream()); + sg_src.resize(thrust::distance(begin_iter, new_end), handle_->get_stream()); + sg_dst.resize(thrust::distance(begin_iter, new_end), handle_->get_stream()); auto aggregated_sg_src = cugraph::test::device_gatherv( - handle, raft::device_span{sg_src.begin(), sg_src.size()}); + *handle_, raft::device_span{sg_src.begin(), sg_src.size()}); auto aggregated_sg_dst = cugraph::test::device_gatherv( - handle, raft::device_span{sg_dst.begin(), sg_dst.size()}); + *handle_, raft::device_span{sg_dst.begin(), sg_dst.size()}); - thrust::sort(handle.get_thrust_policy(), + thrust::sort(handle_->get_thrust_policy(), thrust::make_zip_iterator(mg_out_srcs.begin(), mg_out_dsts.begin()), thrust::make_zip_iterator(mg_out_srcs.end(), mg_out_dsts.end())); - thrust::sort(handle.get_thrust_policy(), + thrust::sort(handle_->get_thrust_policy(), thrust::make_zip_iterator(aggregated_sg_src.begin(), aggregated_sg_dst.begin()), thrust::make_zip_iterator(aggregated_sg_src.end(), aggregated_sg_dst.end())); // FIXME: This is ignoring the case of the same seed being specified multiple // times. Not sure that's worth worrying about, so taking the easy way out here. auto unique_end = - thrust::unique(handle.get_thrust_policy(), + thrust::unique(handle_->get_thrust_policy(), thrust::make_zip_iterator(mg_out_srcs.begin(), mg_out_dsts.begin()), thrust::make_zip_iterator(mg_out_srcs.end(), mg_out_dsts.end())); mg_out_srcs.resize( thrust::distance(thrust::make_zip_iterator(mg_out_srcs.begin(), mg_out_dsts.begin()), unique_end), - handle.get_stream()); + handle_->get_stream()); mg_out_dsts.resize( thrust::distance(thrust::make_zip_iterator(mg_out_srcs.begin(), mg_out_dsts.begin()), unique_end), - handle.get_stream()); + handle_->get_stream()); - auto passed = thrust::equal(handle.get_thrust_policy(), + auto passed = thrust::equal(handle_->get_thrust_policy(), mg_out_srcs.begin(), mg_out_srcs.end(), aggregated_sg_src.begin()); - passed &= thrust::equal(handle.get_thrust_policy(), + passed &= thrust::equal(handle_->get_thrust_policy(), mg_out_dsts.begin(), mg_out_dsts.end(), aggregated_sg_dst.begin()); ASSERT_TRUE(passed); } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MG_GatherEdges::handle_ = nullptr; + using Tests_MG_GatherEdges_File = Tests_MG_GatherEdges; using Tests_MG_GatherEdges_Rmat = Tests_MG_GatherEdges; diff --git a/cpp/tests/sampling/detail/mg_gather_utils.cu b/cpp/tests/sampling/detail/mg_gather_utils.cu index dc0a2fb2cc1..c38f333b35f 100644 --- a/cpp/tests/sampling/detail/mg_gather_utils.cu +++ b/cpp/tests/sampling/detail/mg_gather_utils.cu @@ -18,19 +18,20 @@ #include +#include + #include #include -#include - -#include - #include #include +#include #include #include #include +#include + struct Prims_Usecase { bool check_correctness{true}; }; @@ -136,8 +137,10 @@ class Tests_MG_GatherEdges : public ::testing::TestWithParam> { public: Tests_MG_GatherEdges() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -145,29 +148,13 @@ class Tests_MG_GatherEdges template void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - using namespace cugraph::test; - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } @@ -175,11 +162,11 @@ class Tests_MG_GatherEdges auto [mg_graph, mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true, false, sort_adjacency_list); + *handle_, input_usecase, true, true, false, sort_adjacency_list); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -190,47 +177,47 @@ class Tests_MG_GatherEdges constexpr vertex_t repetitions_per_vertex = 5; constexpr vertex_t source_sample_count = 3; - // 3. Gather mnmg call + // 2. Gather mnmg call // Generate random vertex ids in the range of current gpu auto [global_degree_offsets, global_out_degrees] = - cugraph::detail::get_global_degree_information(handle, mg_graph_view); + cugraph::detail::get_global_degree_information(*handle_, mg_graph_view); // Generate random sources to gather on auto random_sources = - random_vertex_ids(handle, - mg_graph_view.local_vertex_partition_range_first(), - mg_graph_view.local_vertex_partition_range_last(), - std::min(mg_graph_view.local_vertex_partition_range_size() * - (repetitions_per_vertex + vertex_t{1}), - source_sample_count), - repetitions_per_vertex); + cugraph::test::random_vertex_ids(*handle_, + mg_graph_view.local_vertex_partition_range_first(), + mg_graph_view.local_vertex_partition_range_last(), + std::min(mg_graph_view.local_vertex_partition_range_size() * + (repetitions_per_vertex + vertex_t{1}), + source_sample_count), + repetitions_per_vertex); // FIXME: allgather is probably a poor name for this function. // It's really an allgather across the row communicator auto active_sources = - cugraph::detail::allgather_active_majors(handle, std::move(random_sources)); + cugraph::detail::allgather_active_majors(*handle_, std::move(random_sources)); // get source global out degrees to generate indices auto active_source_degrees = cugraph::detail::get_active_major_global_degrees( - handle, mg_graph_view, active_sources, global_out_degrees); + *handle_, mg_graph_view, active_sources, global_out_degrees); auto random_destination_offsets = - generate_random_destination_indices(handle, - active_source_degrees, - mg_graph_view.number_of_vertices(), - edge_t{-1}, - indices_per_source); + cugraph::test::generate_random_destination_indices(*handle_, + active_source_degrees, + mg_graph_view.number_of_vertices(), + edge_t{-1}, + indices_per_source); rmm::device_uvector input_destination_offsets(random_destination_offsets.size(), - handle.get_stream()); + handle_->get_stream()); raft::copy(input_destination_offsets.data(), random_destination_offsets.data(), random_destination_offsets.size(), - handle.get_stream()); + handle_->get_stream()); auto [src, dst, dst_map] = - cugraph::detail::gather_local_edges(handle, + cugraph::detail::gather_local_edges(*handle_, mg_graph_view, active_sources, std::move(random_destination_offsets), @@ -241,14 +228,14 @@ class Tests_MG_GatherEdges // NOTE: This test assumes that edgea within the data structure are sorted // We'll use gather_one_hop_edgelist to pull out the relevant edges auto [h_src, h_dst] = test_gather_local_edges( - handle, mg_graph_view, active_sources, input_destination_offsets, indices_per_source); + *handle_, mg_graph_view, active_sources, input_destination_offsets, indices_per_source); auto agg_src = cugraph::test::device_gatherv( - handle, raft::device_span{src.data(), src.size()}); + *handle_, raft::device_span{src.data(), src.size()}); auto agg_dst = cugraph::test::device_gatherv( - handle, raft::device_span{dst.data(), dst.size()}); + *handle_, raft::device_span{dst.data(), dst.size()}); - thrust::sort(handle.get_thrust_policy(), + thrust::sort(handle_->get_thrust_policy(), thrust::make_zip_iterator(agg_src.begin(), agg_dst.begin()), thrust::make_zip_iterator(agg_src.end(), agg_dst.end())); thrust::sort(thrust::host, @@ -257,8 +244,8 @@ class Tests_MG_GatherEdges std::vector h_agg_src(agg_src.size()); std::vector h_agg_dst(agg_dst.size()); - raft::update_host(h_agg_src.data(), agg_src.data(), agg_src.size(), handle.get_stream()); - raft::update_host(h_agg_dst.data(), agg_dst.data(), agg_dst.size(), handle.get_stream()); + raft::update_host(h_agg_src.data(), agg_src.data(), agg_src.size(), handle_->get_stream()); + raft::update_host(h_agg_dst.data(), agg_dst.data(), agg_dst.size(), handle_->get_stream()); // FIXME: Why are the randomly selected vertices on each GPU so similar?? @@ -267,8 +254,14 @@ class Tests_MG_GatherEdges ASSERT_TRUE(passed); } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MG_GatherEdges::handle_ = nullptr; + using Tests_MG_GatherEdges_File = Tests_MG_GatherEdges; using Tests_MG_GatherEdges_Rmat = Tests_MG_GatherEdges; diff --git a/cpp/tests/sampling/detail/mg_nbr_sampling.cu b/cpp/tests/sampling/detail/mg_nbr_sampling.cu index 94b017c1669..02313439354 100644 --- a/cpp/tests/sampling/detail/mg_nbr_sampling.cu +++ b/cpp/tests/sampling/detail/mg_nbr_sampling.cu @@ -15,29 +15,34 @@ */ #include "nbr_sampling_utils.cuh" + #include +#include + #include #include -#include - #include #include #include +#include + struct Prims_Usecase { bool check_correctness{true}; bool flag_replacement{true}; }; template -class Tests_MG_Nbr_Sampling +class Tests_MGNbrSampling : public ::testing::TestWithParam> { public: - Tests_MG_Nbr_Sampling() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGNbrSampling() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -45,31 +50,15 @@ class Tests_MG_Nbr_Sampling template void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - using namespace cugraph::test; using gpu_t = int; - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } @@ -77,11 +66,11 @@ class Tests_MG_Nbr_Sampling auto [mg_graph, mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true, false, sort_adjacency_list); + *handle_, input_usecase, true, true, false, sort_adjacency_list); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -95,13 +84,13 @@ class Tests_MG_Nbr_Sampling // Generate random vertex ids in the range of current gpu // Generate random sources to gather on - auto random_sources = random_vertex_ids(handle, + auto random_sources = random_vertex_ids(*handle_, mg_graph_view.local_vertex_partition_range_first(), mg_graph_view.local_vertex_partition_range_last(), source_sample_count, repetitions_per_vertex); - rmm::device_uvector random_source_gpu_ids(random_sources.size(), handle.get_stream()); - thrust::fill(handle.get_thrust_policy(), + rmm::device_uvector random_source_gpu_ids(random_sources.size(), handle_->get_stream()); + thrust::fill(handle_->get_thrust_policy(), random_source_gpu_ids.begin(), random_source_gpu_ids.end(), comm_rank); @@ -116,9 +105,9 @@ class Tests_MG_Nbr_Sampling // gather input: // auto&& [tuple_vertex_ranks, counts] = cugraph::detail::original::shuffle_to_gpus( - handle, mg_graph_view, begin_in_pairs, end_in_pairs, gpu_t{}); + *handle_, mg_graph_view, begin_in_pairs, end_in_pairs, gpu_t{}); - auto&& [tuple_quad, v_sizes] = cugraph::uniform_nbr_sample(handle, + auto&& [tuple_quad, v_sizes] = cugraph::uniform_nbr_sample(*handle_, mg_graph_view, random_sources.begin(), random_source_gpu_ids.begin(), @@ -131,7 +120,7 @@ class Tests_MG_Nbr_Sampling auto&& d_gpu_ids = std::get<2>(tuple_quad); if (prims_usecase.check_correctness) { - auto self_rank = handle.get_comms().get_rank(); + auto self_rank = handle_->get_comms().get_rank(); // bring inputs and outputs on one rank // and check if test passed: @@ -170,7 +159,7 @@ class Tests_MG_Nbr_Sampling auto start_offset_in = coalesced_in.cbegin() + offset; raft::update_host( - v_per_rank.data(), start_offset_in, static_cast(count), handle.get_stream()); + v_per_rank.data(), start_offset_in, static_cast(count), handle_->get_stream()); accumulator.insert(accumulator.begin() + offset, v_per_rank.begin(), v_per_rank.end()); }; @@ -206,43 +195,49 @@ class Tests_MG_Nbr_Sampling } } } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_Nbr_Sampling_File = Tests_MG_Nbr_Sampling; +template +std::unique_ptr Tests_MGNbrSampling::handle_ = nullptr; + +using Tests_MGNbrSampling_File = Tests_MGNbrSampling; -using Tests_MG_Nbr_Sampling_Rmat = Tests_MG_Nbr_Sampling; +using Tests_MGNbrSampling_Rmat = Tests_MGNbrSampling; -TEST_P(Tests_MG_Nbr_Sampling_File, CheckInt32Int32Float) +TEST_P(Tests_MGNbrSampling_File, CheckInt32Int32Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_File, CheckInt32Int64Float) +TEST_P(Tests_MGNbrSampling_File, CheckInt32Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_File, CheckInt64Int64Float) +TEST_P(Tests_MGNbrSampling_File, CheckInt64Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt32Int32Float) +TEST_P(Tests_MGNbrSampling_Rmat, CheckInt32Int32Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt32Int64Float) +TEST_P(Tests_MGNbrSampling_Rmat, CheckInt32Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt64Int64Float) +TEST_P(Tests_MGNbrSampling_Rmat, CheckInt64Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); @@ -250,7 +245,7 @@ TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt64Int64Float) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_Nbr_Sampling_File, + Tests_MGNbrSampling_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true, true}, Prims_Usecase{true, false}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -260,7 +255,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_Nbr_Sampling_Rmat, + Tests_MGNbrSampling_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false, true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); @@ -271,7 +266,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_Nbr_Sampling_Rmat, + Tests_MGNbrSampling_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false, true}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/sampling/mg_random_walks_test.cu b/cpp/tests/sampling/mg_random_walks_test.cu index b2a225e7b74..b909f6fb6bc 100644 --- a/cpp/tests/sampling/mg_random_walks_test.cu +++ b/cpp/tests/sampling/mg_random_walks_test.cu @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -83,11 +84,13 @@ struct Node2VecRandomWalks_Usecase { }; template -class Tests_RandomWalks : public ::testing::TestWithParam { +class Tests_MGRandomWalks : public ::testing::TestWithParam { public: - Tests_RandomWalks() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGRandomWalks() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -95,21 +98,8 @@ class Tests_RandomWalks : public ::testing::TestWithParam { template void run_current_test(tuple_t const& param) { - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - auto& comm = handle.get_comms(); - auto const comm_size = comm.get_size(); - - auto row_comm_size = static_cast(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - auto [randomwalks_usecase, input_usecase] = param; if (cugraph::test::g_perf) { @@ -120,7 +110,7 @@ class Tests_RandomWalks : public ::testing::TestWithParam { bool renumber{true}; auto [graph, d_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, randomwalks_usecase.test_weighted, renumber); + *handle_, input_usecase, randomwalks_usecase.test_weighted, renumber); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement @@ -132,9 +122,9 @@ class Tests_RandomWalks : public ::testing::TestWithParam { auto graph_view = graph.view(); edge_t num_paths = 10; - rmm::device_uvector d_start(num_paths, handle.get_stream()); + rmm::device_uvector d_start(num_paths, handle_->get_stream()); - thrust::tabulate(handle.get_thrust_policy(), + thrust::tabulate(handle_->get_thrust_policy(), d_start.begin(), d_start.end(), [num_vertices = graph_view.number_of_vertices()] __device__(auto idx) { @@ -148,10 +138,10 @@ class Tests_RandomWalks : public ::testing::TestWithParam { #if 0 auto [vertices, weights] = randomwalks_usecase( - handle, graph_view, raft::device_span{d_start.data(), d_start.size()}, size_t{10}); + *handle_, graph_view, raft::device_span{d_start.data(), d_start.size()}, size_t{10}); #else EXPECT_THROW( - randomwalks_usecase(handle, + randomwalks_usecase(*handle_, graph_view, raft::device_span{d_start.data(), d_start.size()}, size_t{10}), @@ -171,20 +161,26 @@ class Tests_RandomWalks : public ::testing::TestWithParam { #endif } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGRandomWalks::handle_ = nullptr; + using Tests_UniformRandomWalks_File = - Tests_RandomWalks>; + Tests_MGRandomWalks>; using Tests_UniformRandomWalks_Rmat = - Tests_RandomWalks>; + Tests_MGRandomWalks>; using Tests_BiasedRandomWalks_File = - Tests_RandomWalks>; + Tests_MGRandomWalks>; using Tests_BiasedRandomWalks_Rmat = - Tests_RandomWalks>; + Tests_MGRandomWalks>; using Tests_Node2VecRandomWalks_File = - Tests_RandomWalks>; + Tests_MGRandomWalks>; using Tests_Node2VecRandomWalks_Rmat = - Tests_RandomWalks>; + Tests_MGRandomWalks>; TEST_P(Tests_UniformRandomWalks_File, Initialize_i32_i32_f) { diff --git a/cpp/tests/sampling/mg_uniform_neighbor_sampling.cu b/cpp/tests/sampling/mg_uniform_neighbor_sampling.cu index afc04d2f5d1..83e63c1f6e7 100644 --- a/cpp/tests/sampling/mg_uniform_neighbor_sampling.cu +++ b/cpp/tests/sampling/mg_uniform_neighbor_sampling.cu @@ -15,27 +15,29 @@ */ #include "detail/nbr_sampling_utils.cuh" -#include -#include -#include +#include #include #include #include +#include + struct Prims_Usecase { bool check_correctness{true}; bool flag_replacement{true}; }; template -class Tests_MG_Nbr_Sampling +class Tests_MGNbrSampling : public ::testing::TestWithParam> { public: - Tests_MG_Nbr_Sampling() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGNbrSampling() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -43,30 +45,13 @@ class Tests_MG_Nbr_Sampling template void run_current_test(Prims_Usecase const& prims_usecase, input_usecase_t const& input_usecase) { - using namespace cugraph::test; - - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } @@ -74,11 +59,11 @@ class Tests_MG_Nbr_Sampling auto [mg_graph, mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true, false, sort_adjacency_list); + *handle_, input_usecase, true, true, false, sort_adjacency_list); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -91,20 +76,20 @@ class Tests_MG_Nbr_Sampling // Generate random vertex ids in the range of current gpu auto random_sources = - random_vertex_ids(handle, - mg_graph_view.local_vertex_partition_range_first(), - mg_graph_view.local_vertex_partition_range_last(), - std::min(mg_graph_view.local_vertex_partition_range_size() * - (repetitions_per_vertex + vertex_t{1}), - source_sample_count), - repetitions_per_vertex, - comm_rank); + cugraph::test::random_vertex_ids(*handle_, + mg_graph_view.local_vertex_partition_range_first(), + mg_graph_view.local_vertex_partition_range_last(), + std::min(mg_graph_view.local_vertex_partition_range_size() * + (repetitions_per_vertex + vertex_t{1}), + source_sample_count), + repetitions_per_vertex, + handle_->get_comms().get_rank()); std::vector h_fan_out{indices_per_source}; // depth = 1 #ifdef NO_CUGRAPH_OPS EXPECT_THROW(cugraph::uniform_nbr_sample( - handle, + *handle_, mg_graph_view, raft::device_span(random_sources.data(), random_sources.size()), raft::host_span(h_fan_out.data(), h_fan_out.size()), @@ -112,7 +97,7 @@ class Tests_MG_Nbr_Sampling std::exception); #else auto&& [d_src_out, d_dst_out, d_indices, d_counts] = cugraph::uniform_nbr_sample( - handle, + *handle_, mg_graph_view, raft::device_span(random_sources.data(), random_sources.size()), raft::host_span(h_fan_out.data(), h_fan_out.size()), @@ -121,13 +106,13 @@ class Tests_MG_Nbr_Sampling if (prims_usecase.check_correctness) { // Consolidate results on GPU 0 auto d_mg_start_src = cugraph::test::device_gatherv( - handle, raft::device_span{random_sources.data(), random_sources.size()}); + *handle_, raft::device_span{random_sources.data(), random_sources.size()}); auto d_mg_aggregate_src = cugraph::test::device_gatherv( - handle, raft::device_span{d_src_out.data(), d_src_out.size()}); + *handle_, raft::device_span{d_src_out.data(), d_src_out.size()}); auto d_mg_aggregate_dst = cugraph::test::device_gatherv( - handle, raft::device_span{d_dst_out.data(), d_dst_out.size()}); + *handle_, raft::device_span{d_dst_out.data(), d_dst_out.size()}); auto d_mg_aggregate_indices = cugraph::test::device_gatherv( - handle, raft::device_span{d_indices.data(), d_indices.size()}); + *handle_, raft::device_span{d_indices.data(), d_indices.size()}); #if 0 // FIXME: extract_induced_subgraphs not currently support MG, so we'll skip this validation @@ -135,38 +120,38 @@ class Tests_MG_Nbr_Sampling // First validate that the extracted edges are actually a subset of the // edges in the input graph - rmm::device_uvector d_vertices(2 * d_mg_aggregate_src.size(), handle.get_stream()); - raft::copy(d_vertices.data(), d_mg_aggregate_src.data(), d_mg_aggregate_src.size(), handle.get_stream()); + rmm::device_uvector d_vertices(2 * d_mg_aggregate_src.size(), handle_->get_stream()); + raft::copy(d_vertices.data(), d_mg_aggregate_src.data(), d_mg_aggregate_src.size(), handle_->get_stream()); raft::copy(d_vertices.data() + d_mg_aggregate_src.size(), d_mg_aggregate_dst.data(), d_mg_aggregate_dst.size(), - handle.get_stream()); - thrust::sort(handle.get_thrust_policy(), d_vertices.begin(), d_vertices.end()); + handle_->get_stream()); + thrust::sort(handle_->get_thrust_policy(), d_vertices.begin(), d_vertices.end()); auto vertices_end = - thrust::unique(handle.get_thrust_policy(), d_vertices.begin(), d_vertices.end()); - d_vertices.resize(thrust::distance(d_vertices.begin(), vertices_end), handle.get_stream()); + thrust::unique(handle_->get_thrust_policy(), d_vertices.begin(), d_vertices.end()); + d_vertices.resize(thrust::distance(d_vertices.begin(), vertices_end), handle_->get_stream()); - d_vertices = cugraph::detail::shuffle_int_vertices_by_gpu_id(handle, std::move(d_vertices), mg_graph_view.vertex_partition_range_lasts()); + d_vertices = cugraph::detail::shuffle_int_vertices_by_gpu_id(*handle_, std::move(d_vertices), mg_graph_view.vertex_partition_range_lasts()); - thrust::sort(handle.get_thrust_policy(), d_vertices.begin(), d_vertices.end()); + thrust::sort(handle_->get_thrust_policy(), d_vertices.begin(), d_vertices.end()); - rmm::device_uvector d_subgraph_offsets(2, handle.get_stream()); + rmm::device_uvector d_subgraph_offsets(2, handle_->get_stream()); std::vector h_subgraph_offsets({0, d_vertices.size()}); raft::update_device(d_subgraph_offsets.data(), h_subgraph_offsets.data(), h_subgraph_offsets.size(), - handle.get_stream()); + handle_->get_stream()); auto [d_src_in, d_dst_in, d_indices_in, d_ignore] = extract_induced_subgraphs( - handle, mg_graph_view, d_subgraph_offsets.data(), d_vertices.data(), 1, true); + *handle_, mg_graph_view, d_subgraph_offsets.data(), d_vertices.data(), 1, true); cugraph::test::validate_extracted_graph_is_subgraph( - handle, d_src_in, d_dst_in, *d_indices_in, d_src_out, d_dst_out, d_indices); + *handle_, d_src_in, d_dst_in, *d_indices_in, d_src_out, d_dst_out, d_indices); #endif if (d_mg_aggregate_src.size() > 0) { - cugraph::test::validate_sampling_depth(handle, + cugraph::test::validate_sampling_depth(*handle_, std::move(d_mg_aggregate_src), std::move(d_mg_aggregate_dst), std::move(d_mg_aggregate_indices), @@ -176,43 +161,49 @@ class Tests_MG_Nbr_Sampling } #endif } + + private: + static std::unique_ptr handle_; }; -using Tests_MG_Nbr_Sampling_File = Tests_MG_Nbr_Sampling; +template +std::unique_ptr Tests_MGNbrSampling::handle_ = nullptr; + +using Tests_MGNbrSampling_File = Tests_MGNbrSampling; -using Tests_MG_Nbr_Sampling_Rmat = Tests_MG_Nbr_Sampling; +using Tests_MGNbrSampling_Rmat = Tests_MGNbrSampling; -TEST_P(Tests_MG_Nbr_Sampling_File, CheckInt32Int32Float) +TEST_P(Tests_MGNbrSampling_File, CheckInt32Int32Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_File, CheckInt32Int64Float) +TEST_P(Tests_MGNbrSampling_File, CheckInt32Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_File, CheckInt64Int64Float) +TEST_P(Tests_MGNbrSampling_File, CheckInt64Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt32Int32Float) +TEST_P(Tests_MGNbrSampling_Rmat, CheckInt32Int32Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt32Int64Float) +TEST_P(Tests_MGNbrSampling_Rmat, CheckInt32Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt64Int64Float) +TEST_P(Tests_MGNbrSampling_Rmat, CheckInt64Int64Float) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); @@ -220,7 +211,7 @@ TEST_P(Tests_MG_Nbr_Sampling_Rmat, CheckInt64Int64Float) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_MG_Nbr_Sampling_File, + Tests_MGNbrSampling_File, ::testing::Combine( ::testing::Values(Prims_Usecase{true, true}, Prims_Usecase{true, false}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), @@ -230,7 +221,7 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( rmat_small_test, - Tests_MG_Nbr_Sampling_Rmat, + Tests_MGNbrSampling_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false, true}), ::testing::Values(cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); @@ -241,7 +232,7 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_MG_Nbr_Sampling_Rmat, + Tests_MGNbrSampling_Rmat, ::testing::Combine(::testing::Values(Prims_Usecase{false, true}), ::testing::Values(cugraph::test::Rmat_Usecase( 20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); diff --git a/cpp/tests/sampling/random_walks_test.cu b/cpp/tests/sampling/random_walks_test.cu index 66f7648c541..1015e21cc29 100644 --- a/cpp/tests/sampling/random_walks_test.cu +++ b/cpp/tests/sampling/random_walks_test.cu @@ -80,7 +80,8 @@ class Tests_RandomWalks : public ::testing::TestWithParam> { public: Tests_RandomWalks() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/sampling/sg_uniform_neighbor_sampling.cu b/cpp/tests/sampling/sg_uniform_neighbor_sampling.cu index da141035dda..ebe70411668 100644 --- a/cpp/tests/sampling/sg_uniform_neighbor_sampling.cu +++ b/cpp/tests/sampling/sg_uniform_neighbor_sampling.cu @@ -32,7 +32,8 @@ class Tests_Uniform_Neighbor_Sampling : public ::testing::TestWithParam> { public: Tests_Uniform_Neighbor_Sampling() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/coarsen_graph_test.cpp b/cpp/tests/structure/coarsen_graph_test.cpp index 665f84492df..30db0c132b2 100644 --- a/cpp/tests/structure/coarsen_graph_test.cpp +++ b/cpp/tests/structure/coarsen_graph_test.cpp @@ -232,7 +232,8 @@ class Tests_CoarsenGraph : public ::testing::TestWithParam> { public: Tests_CoarsenGraph() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/count_self_loops_and_multi_edges_test.cpp b/cpp/tests/structure/count_self_loops_and_multi_edges_test.cpp index 26bbd8fe776..8df66bcde9a 100644 --- a/cpp/tests/structure/count_self_loops_and_multi_edges_test.cpp +++ b/cpp/tests/structure/count_self_loops_and_multi_edges_test.cpp @@ -68,7 +68,8 @@ class Tests_CountSelfLoopsAndMultiEdges std::tuple> { public: Tests_CountSelfLoopsAndMultiEdges() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/degree_test.cpp b/cpp/tests/structure/degree_test.cpp index d2d3696f9c4..95a096d5137 100644 --- a/cpp/tests/structure/degree_test.cpp +++ b/cpp/tests/structure/degree_test.cpp @@ -72,7 +72,8 @@ typedef struct Degree_Usecase_t { class Tests_Degree : public ::testing::TestWithParam { public: Tests_Degree() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/graph_test.cpp b/cpp/tests/structure/graph_test.cpp index 7fbb95eac2a..7527c1a02e8 100644 --- a/cpp/tests/structure/graph_test.cpp +++ b/cpp/tests/structure/graph_test.cpp @@ -77,7 +77,8 @@ template class Tests_Graph : public ::testing::TestWithParam> { public: Tests_Graph() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/mg_count_self_loops_and_multi_edges_test.cpp b/cpp/tests/structure/mg_count_self_loops_and_multi_edges_test.cpp index df0183b61f6..29f0daa25b2 100644 --- a/cpp/tests/structure/mg_count_self_loops_and_multi_edges_test.cpp +++ b/cpp/tests/structure/mg_count_self_loops_and_multi_edges_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -47,8 +48,10 @@ class Tests_MGCountSelfLoopsAndMultiEdges std::tuple> { public: Tests_MGCountSelfLoopsAndMultiEdges() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -60,38 +63,23 @@ class Tests_MGCountSelfLoopsAndMultiEdges CountSelfLoopsAndMultiEdges_Usecase const& count_self_loops_and_multi_edges_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, false, true); + *handle_, input_usecase, false, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -99,19 +87,19 @@ class Tests_MGCountSelfLoopsAndMultiEdges auto mg_graph_view = mg_graph.view(); - // 3. run MG count_self_loops & count_multi_edges + // 2. run MG count_self_loops & count_multi_edges if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - auto num_self_loops = mg_graph_view.count_self_loops(handle); + auto num_self_loops = mg_graph_view.count_self_loops(*handle_); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG Counting self-loops took " << elapsed_time * 1e-6 << " s.\n"; @@ -119,47 +107,54 @@ class Tests_MGCountSelfLoopsAndMultiEdges if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - auto num_multi_edges = mg_graph_view.count_multi_edges(handle); + auto num_multi_edges = mg_graph_view.count_multi_edges(*handle_); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG Counting multi-edges took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. copmare SG & MG results + // 3. copmare SG & MG results if (count_self_loops_and_multi_edges_usecase.check_correctness) { - // 4-1. create SG graph + // 3-1. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, false, false); + *handle_, input_usecase, false, false); auto sg_graph_view = sg_graph.view(); ASSERT_EQ(mg_graph_view.number_of_vertices(), sg_graph_view.number_of_vertices()); - // 4-2. run SG count_self_loops & count_multi_edges + // 3-2. run SG count_self_loops & count_multi_edges - auto sg_num_self_loops = sg_graph_view.count_self_loops(handle); - auto sg_num_multi_edges = sg_graph_view.count_multi_edges(handle); + auto sg_num_self_loops = sg_graph_view.count_self_loops(*handle_); + auto sg_num_multi_edges = sg_graph_view.count_multi_edges(*handle_); - // 4-3. compare + // 3-3. compare ASSERT_EQ(num_self_loops, sg_num_self_loops); ASSERT_EQ(num_multi_edges, sg_num_multi_edges); } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGCountSelfLoopsAndMultiEdges::handle_ = + nullptr; + using Tests_MGCountSelfLoopsAndMultiEdges_File = Tests_MGCountSelfLoopsAndMultiEdges; using Tests_MGCountSelfLoopsAndMultiEdges_Rmat = diff --git a/cpp/tests/structure/mg_symmetrize_test.cpp b/cpp/tests/structure/mg_symmetrize_test.cpp index 27dcfb3b523..4020b474fb8 100644 --- a/cpp/tests/structure/mg_symmetrize_test.cpp +++ b/cpp/tests/structure/mg_symmetrize_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -45,8 +46,10 @@ class Tests_MGSymmetrize : public ::testing::TestWithParam> { public: Tests_MGSymmetrize() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -55,102 +58,87 @@ class Tests_MGSymmetrize void run_current_test(Symmetrize_Usecase const& symmetrize_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, symmetrize_usecase.test_weighted, true); + *handle_, input_usecase, symmetrize_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; } - // 3. run MG symmetrize + // 2. run MG symmetrize if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } *d_mg_renumber_map_labels = mg_graph.symmetrize( - handle, std::move(*d_mg_renumber_map_labels), symmetrize_usecase.reciprocal); + *handle_, std::move(*d_mg_renumber_map_labels), symmetrize_usecase.reciprocal); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG symmetrize took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. copmare SG & MG results + // 3. copmare SG & MG results if (symmetrize_usecase.check_correctness) { - // 4-1. decompress MG results + // 3-1. decompress MG results auto [d_mg_srcs, d_mg_dsts, d_mg_weights] = - mg_graph.decompress_to_edgelist(handle, d_mg_renumber_map_labels, false); + mg_graph.decompress_to_edgelist(*handle_, d_mg_renumber_map_labels, false); - // 4-2. aggregate MG results + // 3-2. aggregate MG results auto d_mg_aggregate_srcs = - cugraph::test::device_gatherv(handle, d_mg_srcs.data(), d_mg_srcs.size()); + cugraph::test::device_gatherv(*handle_, d_mg_srcs.data(), d_mg_srcs.size()); auto d_mg_aggregate_dsts = - cugraph::test::device_gatherv(handle, d_mg_dsts.data(), d_mg_dsts.size()); + cugraph::test::device_gatherv(*handle_, d_mg_dsts.data(), d_mg_dsts.size()); std::optional> d_mg_aggregate_weights{std::nullopt}; if (d_mg_weights) { d_mg_aggregate_weights = - cugraph::test::device_gatherv(handle, (*d_mg_weights).data(), (*d_mg_weights).size()); + cugraph::test::device_gatherv(*handle_, (*d_mg_weights).data(), (*d_mg_weights).size()); } - if (handle.get_comms().get_rank() == int{0}) { - // 4-3. create SG graph + if (handle_->get_comms().get_rank() == int{0}) { + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, symmetrize_usecase.test_weighted, false); + *handle_, input_usecase, symmetrize_usecase.test_weighted, false); - // 4-4. run SG symmetrize + // 3-4. run SG symmetrize auto d_sg_renumber_map_labels = - sg_graph.symmetrize(handle, std::nullopt, symmetrize_usecase.reciprocal); + sg_graph.symmetrize(*handle_, std::nullopt, symmetrize_usecase.reciprocal); ASSERT_FALSE(d_sg_renumber_map_labels.has_value()); - // 4-5. decompress SG results + // 3-5. decompress SG results auto [d_sg_srcs, d_sg_dsts, d_sg_weights] = - sg_graph.decompress_to_edgelist(handle, std::nullopt, false); + sg_graph.decompress_to_edgelist(*handle_, std::nullopt, false); - // 4-6. compare + // 3-6. compare ASSERT_TRUE(mg_graph.number_of_vertices() == sg_graph.number_of_vertices()); ASSERT_TRUE(mg_graph.number_of_edges() == sg_graph.number_of_edges()); @@ -164,16 +152,16 @@ class Tests_MGSymmetrize raft::update_host(h_mg_aggregate_srcs.data(), d_mg_aggregate_srcs.data(), d_mg_aggregate_srcs.size(), - handle.get_stream()); + handle_->get_stream()); raft::update_host(h_mg_aggregate_dsts.data(), d_mg_aggregate_dsts.data(), d_mg_aggregate_dsts.size(), - handle.get_stream()); + handle_->get_stream()); if (h_mg_aggregate_weights) { raft::update_host((*h_mg_aggregate_weights).data(), (*d_mg_aggregate_weights).data(), (*d_mg_aggregate_weights).size(), - handle.get_stream()); + handle_->get_stream()); } std::vector h_sg_srcs(d_sg_srcs.size()); @@ -181,14 +169,14 @@ class Tests_MGSymmetrize auto h_sg_weights = d_sg_weights ? std::make_optional>(d_sg_srcs.size()) : std::nullopt; raft::update_host( - h_sg_srcs.data(), d_sg_srcs.data(), d_sg_srcs.size(), handle.get_stream()); + h_sg_srcs.data(), d_sg_srcs.data(), d_sg_srcs.size(), handle_->get_stream()); raft::update_host( - h_sg_dsts.data(), d_sg_dsts.data(), d_sg_dsts.size(), handle.get_stream()); + h_sg_dsts.data(), d_sg_dsts.data(), d_sg_dsts.size(), handle_->get_stream()); if (h_sg_weights) { raft::update_host((*h_sg_weights).data(), (*d_sg_weights).data(), (*d_sg_weights).size(), - handle.get_stream()); + handle_->get_stream()); } if (symmetrize_usecase.test_weighted) { @@ -224,8 +212,14 @@ class Tests_MGSymmetrize } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGSymmetrize::handle_ = nullptr; + using Tests_MGSymmetrize_File = Tests_MGSymmetrize; using Tests_MGSymmetrize_Rmat = Tests_MGSymmetrize; diff --git a/cpp/tests/structure/mg_transpose_storage_test.cpp b/cpp/tests/structure/mg_transpose_storage_test.cpp index 0a10f5ab70d..36b4a2f350a 100644 --- a/cpp/tests/structure/mg_transpose_storage_test.cpp +++ b/cpp/tests/structure/mg_transpose_storage_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -44,8 +45,10 @@ class Tests_MGTransposeStorage : public ::testing::TestWithParam> { public: Tests_MGTransposeStorage() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -54,98 +57,84 @@ class Tests_MGTransposeStorage void run_current_test(TransposeStorage_Usecase const& transpose_storage_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, transpose_storage_usecase.test_weighted, true); + *handle_, input_usecase, transpose_storage_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; } - // 3. run MG transpose storage + // 2. run MG transpose storage if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } cugraph::graph_t - mg_storage_transposed_graph(handle); + mg_storage_transposed_graph(*handle_); std::tie(mg_storage_transposed_graph, *d_mg_renumber_map_labels) = - mg_graph.transpose_storage(handle, std::move(*d_mg_renumber_map_labels)); + mg_graph.transpose_storage(*handle_, std::move(*d_mg_renumber_map_labels)); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG transpose storage took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. copmare SG & MG results + // 3. copmare SG & MG results if (transpose_storage_usecase.check_correctness) { - // 4-1. decompress MG results + // 3-1. decompress MG results auto [d_mg_srcs, d_mg_dsts, d_mg_weights] = - mg_storage_transposed_graph.decompress_to_edgelist(handle, d_mg_renumber_map_labels, false); + mg_storage_transposed_graph.decompress_to_edgelist( + *handle_, d_mg_renumber_map_labels, false); - // 4-2. aggregate MG results + // 3-2. aggregate MG results auto d_mg_aggregate_srcs = - cugraph::test::device_gatherv(handle, d_mg_srcs.data(), d_mg_srcs.size()); + cugraph::test::device_gatherv(*handle_, d_mg_srcs.data(), d_mg_srcs.size()); auto d_mg_aggregate_dsts = - cugraph::test::device_gatherv(handle, d_mg_dsts.data(), d_mg_dsts.size()); + cugraph::test::device_gatherv(*handle_, d_mg_dsts.data(), d_mg_dsts.size()); std::optional> d_mg_aggregate_weights{std::nullopt}; if (d_mg_weights) { d_mg_aggregate_weights = - cugraph::test::device_gatherv(handle, (*d_mg_weights).data(), (*d_mg_weights).size()); + cugraph::test::device_gatherv(*handle_, (*d_mg_weights).data(), (*d_mg_weights).size()); } - if (handle.get_comms().get_rank() == int{0}) { - // 4-3. create SG graph + if (handle_->get_comms().get_rank() == int{0}) { + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, transpose_storage_usecase.test_weighted, false); + *handle_, input_usecase, transpose_storage_usecase.test_weighted, false); - // 4-4. decompress SG results + // 3-4. decompress SG results auto [d_sg_srcs, d_sg_dsts, d_sg_weights] = - sg_graph.decompress_to_edgelist(handle, std::nullopt, false); + sg_graph.decompress_to_edgelist(*handle_, std::nullopt, false); - // 4-5. compare + // 3-5. compare ASSERT_TRUE(mg_graph.number_of_vertices() == sg_graph.number_of_vertices()); ASSERT_TRUE(mg_graph.number_of_edges() == sg_graph.number_of_edges()); @@ -159,16 +148,16 @@ class Tests_MGTransposeStorage raft::update_host(h_mg_aggregate_srcs.data(), d_mg_aggregate_srcs.data(), d_mg_aggregate_srcs.size(), - handle.get_stream()); + handle_->get_stream()); raft::update_host(h_mg_aggregate_dsts.data(), d_mg_aggregate_dsts.data(), d_mg_aggregate_dsts.size(), - handle.get_stream()); + handle_->get_stream()); if (h_mg_aggregate_weights) { raft::update_host((*h_mg_aggregate_weights).data(), (*d_mg_aggregate_weights).data(), (*d_mg_aggregate_weights).size(), - handle.get_stream()); + handle_->get_stream()); } std::vector h_sg_srcs(d_sg_srcs.size()); @@ -176,14 +165,14 @@ class Tests_MGTransposeStorage auto h_sg_weights = d_sg_weights ? std::make_optional>(d_sg_srcs.size()) : std::nullopt; raft::update_host( - h_sg_srcs.data(), d_sg_srcs.data(), d_sg_srcs.size(), handle.get_stream()); + h_sg_srcs.data(), d_sg_srcs.data(), d_sg_srcs.size(), handle_->get_stream()); raft::update_host( - h_sg_dsts.data(), d_sg_dsts.data(), d_sg_dsts.size(), handle.get_stream()); + h_sg_dsts.data(), d_sg_dsts.data(), d_sg_dsts.size(), handle_->get_stream()); if (h_sg_weights) { raft::update_host((*h_sg_weights).data(), (*d_sg_weights).data(), (*d_sg_weights).size(), - handle.get_stream()); + handle_->get_stream()); } if (transpose_storage_usecase.test_weighted) { @@ -219,8 +208,14 @@ class Tests_MGTransposeStorage } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGTransposeStorage::handle_ = nullptr; + using Tests_MGTransposeStorage_File = Tests_MGTransposeStorage; using Tests_MGTransposeStorage_Rmat = Tests_MGTransposeStorage; diff --git a/cpp/tests/structure/mg_transpose_test.cpp b/cpp/tests/structure/mg_transpose_test.cpp index 3643af9c090..3edf6e8c0a3 100644 --- a/cpp/tests/structure/mg_transpose_test.cpp +++ b/cpp/tests/structure/mg_transpose_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -44,8 +45,10 @@ class Tests_MGTranspose : public ::testing::TestWithParam> { public: Tests_MGTranspose() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -54,100 +57,85 @@ class Tests_MGTranspose void run_current_test(Transpose_Usecase const& transpose_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, transpose_usecase.test_weighted, true); + *handle_, input_usecase, transpose_usecase.test_weighted, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; } - // 3. run MG transpose + // 2. run MG transpose if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - *d_mg_renumber_map_labels = mg_graph.transpose(handle, std::move(*d_mg_renumber_map_labels)); + *d_mg_renumber_map_labels = mg_graph.transpose(*handle_, std::move(*d_mg_renumber_map_labels)); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG transpose took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. copmare SG & MG results + // 3. copmare SG & MG results if (transpose_usecase.check_correctness) { - // 4-1. decompress MG results + // 3-1. decompress MG results auto [d_mg_srcs, d_mg_dsts, d_mg_weights] = - mg_graph.decompress_to_edgelist(handle, d_mg_renumber_map_labels, false); + mg_graph.decompress_to_edgelist(*handle_, d_mg_renumber_map_labels, false); - // 4-2. aggregate MG results + // 3-2. aggregate MG results auto d_mg_aggregate_srcs = - cugraph::test::device_gatherv(handle, d_mg_srcs.data(), d_mg_srcs.size()); + cugraph::test::device_gatherv(*handle_, d_mg_srcs.data(), d_mg_srcs.size()); auto d_mg_aggregate_dsts = - cugraph::test::device_gatherv(handle, d_mg_dsts.data(), d_mg_dsts.size()); + cugraph::test::device_gatherv(*handle_, d_mg_dsts.data(), d_mg_dsts.size()); std::optional> d_mg_aggregate_weights{std::nullopt}; if (d_mg_weights) { d_mg_aggregate_weights = - cugraph::test::device_gatherv(handle, (*d_mg_weights).data(), (*d_mg_weights).size()); + cugraph::test::device_gatherv(*handle_, (*d_mg_weights).data(), (*d_mg_weights).size()); } - if (handle.get_comms().get_rank() == int{0}) { - // 4-3. create SG graph + if (handle_->get_comms().get_rank() == int{0}) { + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, transpose_usecase.test_weighted, false); + *handle_, input_usecase, transpose_usecase.test_weighted, false); - // 4-4. run SG transpose + // 3-4. run SG transpose - auto d_sg_renumber_map_labels = sg_graph.transpose(handle, std::nullopt); + auto d_sg_renumber_map_labels = sg_graph.transpose(*handle_, std::nullopt); ASSERT_FALSE(d_sg_renumber_map_labels.has_value()); - // 4-5. decompress SG results + // 3-5. decompress SG results auto [d_sg_srcs, d_sg_dsts, d_sg_weights] = - sg_graph.decompress_to_edgelist(handle, std::nullopt, false); + sg_graph.decompress_to_edgelist(*handle_, std::nullopt, false); - // 4-6. compare + // 3-6. compare ASSERT_TRUE(mg_graph.number_of_vertices() == sg_graph.number_of_vertices()); ASSERT_TRUE(mg_graph.number_of_edges() == sg_graph.number_of_edges()); @@ -161,16 +149,16 @@ class Tests_MGTranspose raft::update_host(h_mg_aggregate_srcs.data(), d_mg_aggregate_srcs.data(), d_mg_aggregate_srcs.size(), - handle.get_stream()); + handle_->get_stream()); raft::update_host(h_mg_aggregate_dsts.data(), d_mg_aggregate_dsts.data(), d_mg_aggregate_dsts.size(), - handle.get_stream()); + handle_->get_stream()); if (h_mg_aggregate_weights) { raft::update_host((*h_mg_aggregate_weights).data(), (*d_mg_aggregate_weights).data(), (*d_mg_aggregate_weights).size(), - handle.get_stream()); + handle_->get_stream()); } std::vector h_sg_srcs(d_sg_srcs.size()); @@ -178,14 +166,14 @@ class Tests_MGTranspose auto h_sg_weights = d_sg_weights ? std::make_optional>(d_sg_srcs.size()) : std::nullopt; raft::update_host( - h_sg_srcs.data(), d_sg_srcs.data(), d_sg_srcs.size(), handle.get_stream()); + h_sg_srcs.data(), d_sg_srcs.data(), d_sg_srcs.size(), handle_->get_stream()); raft::update_host( - h_sg_dsts.data(), d_sg_dsts.data(), d_sg_dsts.size(), handle.get_stream()); + h_sg_dsts.data(), d_sg_dsts.data(), d_sg_dsts.size(), handle_->get_stream()); if (h_sg_weights) { raft::update_host((*h_sg_weights).data(), (*d_sg_weights).data(), (*d_sg_weights).size(), - handle.get_stream()); + handle_->get_stream()); } if (transpose_usecase.test_weighted) { @@ -221,8 +209,14 @@ class Tests_MGTranspose } } } + + private: + static std::unique_ptr handle_; }; +template +std::unique_ptr Tests_MGTranspose::handle_ = nullptr; + using Tests_MGTranspose_File = Tests_MGTranspose; using Tests_MGTranspose_Rmat = Tests_MGTranspose; diff --git a/cpp/tests/structure/renumbering_test.cpp b/cpp/tests/structure/renumbering_test.cpp index 71c465e2db6..2313f1c317a 100644 --- a/cpp/tests/structure/renumbering_test.cpp +++ b/cpp/tests/structure/renumbering_test.cpp @@ -47,7 +47,8 @@ class Tests_Renumbering : public ::testing::TestWithParam> { public: Tests_Renumbering() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/symmetrize_test.cpp b/cpp/tests/structure/symmetrize_test.cpp index 35d799dc790..837b38170c5 100644 --- a/cpp/tests/structure/symmetrize_test.cpp +++ b/cpp/tests/structure/symmetrize_test.cpp @@ -176,7 +176,8 @@ class Tests_Symmetrize : public ::testing::TestWithParam> { public: Tests_Symmetrize() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/transpose_storage_test.cpp b/cpp/tests/structure/transpose_storage_test.cpp index 9d64d65b750..239b5912d24 100644 --- a/cpp/tests/structure/transpose_storage_test.cpp +++ b/cpp/tests/structure/transpose_storage_test.cpp @@ -41,7 +41,8 @@ class Tests_TransposeStorage : public ::testing::TestWithParam> { public: Tests_TransposeStorage() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/transpose_test.cpp b/cpp/tests/structure/transpose_test.cpp index 55436a9bd36..8e2df0c0821 100644 --- a/cpp/tests/structure/transpose_test.cpp +++ b/cpp/tests/structure/transpose_test.cpp @@ -41,7 +41,8 @@ class Tests_Transpose : public ::testing::TestWithParam> { public: Tests_Transpose() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/structure/weight_sum_test.cpp b/cpp/tests/structure/weight_sum_test.cpp index 733f466de6f..68dd7ee531c 100644 --- a/cpp/tests/structure/weight_sum_test.cpp +++ b/cpp/tests/structure/weight_sum_test.cpp @@ -74,7 +74,8 @@ typedef struct WeightSum_Usecase_t { class Tests_WeightSum : public ::testing::TestWithParam { public: Tests_WeightSum() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/traversal/bfs_test.cpp b/cpp/tests/traversal/bfs_test.cpp index 04adad87c8b..53cca39eec2 100644 --- a/cpp/tests/traversal/bfs_test.cpp +++ b/cpp/tests/traversal/bfs_test.cpp @@ -87,7 +87,8 @@ template class Tests_BFS : public ::testing::TestWithParam> { public: Tests_BFS() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/traversal/extract_bfs_paths_test.cu b/cpp/tests/traversal/extract_bfs_paths_test.cu index 5f4274e28ff..d5b3de76a22 100644 --- a/cpp/tests/traversal/extract_bfs_paths_test.cu +++ b/cpp/tests/traversal/extract_bfs_paths_test.cu @@ -51,7 +51,8 @@ class Tests_ExtractBfsPaths : public ::testing::TestWithParam> { public: Tests_ExtractBfsPaths() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/traversal/legacy/bfs_test.cu b/cpp/tests/traversal/legacy/bfs_test.cu index 879b2b4a398..7d0b3faa0a5 100644 --- a/cpp/tests/traversal/legacy/bfs_test.cu +++ b/cpp/tests/traversal/legacy/bfs_test.cu @@ -76,7 +76,8 @@ class Tests_BFS : public ::testing::TestWithParam { public: Tests_BFS() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/traversal/legacy/sssp_test.cu b/cpp/tests/traversal/legacy/sssp_test.cu index 82c7d010a9d..1e93e8211d6 100644 --- a/cpp/tests/traversal/legacy/sssp_test.cu +++ b/cpp/tests/traversal/legacy/sssp_test.cu @@ -139,7 +139,8 @@ typedef struct SSSP_Usecase_t { class Tests_SSSP : public ::testing::TestWithParam { public: Tests_SSSP() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() { if (cugraph::test::g_perf) { @@ -148,6 +149,7 @@ class Tests_SSSP : public ::testing::TestWithParam { } } } + virtual void SetUp() {} virtual void TearDown() {} diff --git a/cpp/tests/traversal/mg_bfs_test.cpp b/cpp/tests/traversal/mg_bfs_test.cpp index 628593e85ab..8c96fe084ec 100644 --- a/cpp/tests/traversal/mg_bfs_test.cpp +++ b/cpp/tests/traversal/mg_bfs_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -46,8 +47,10 @@ template class Tests_MGBFS : public ::testing::TestWithParam> { public: Tests_MGBFS() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -58,38 +61,23 @@ class Tests_MGBFS : public ::testing::TestWithParam(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, false, true); + *handle_, input_usecase, false, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -101,25 +89,26 @@ class Tests_MGBFS : public ::testing::TestWithParam(bfs_usecase.source) < mg_graph_view.number_of_vertices()) << "Invalid starting source."; - // 3. run MG BFS + // 2. run MG BFS rmm::device_uvector d_mg_distances(mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_mg_predecessors( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto const d_mg_source = mg_graph_view.in_local_vertex_partition_range_nocheck(bfs_usecase.source) - ? std::make_optional>(bfs_usecase.source, handle.get_stream()) + ? std::make_optional>(bfs_usecase.source, + handle_->get_stream()) : std::nullopt; - cugraph::bfs(handle, + cugraph::bfs(*handle_, mg_graph_view, d_mg_distances.data(), d_mg_predecessors.data(), @@ -130,66 +119,66 @@ class Tests_MGBFS : public ::testing::TestWithParamget_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG BFS took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. compare SG & MG results + // 3. compare SG & MG results if (bfs_usecase.check_correctness) { - // 4-1. aggregate MG results + // 3-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_distances = - cugraph::test::device_gatherv(handle, d_mg_distances.data(), d_mg_distances.size()); + cugraph::test::device_gatherv(*handle_, d_mg_distances.data(), d_mg_distances.size()); auto d_mg_aggregate_predecessors = - cugraph::test::device_gatherv(handle, d_mg_predecessors.data(), d_mg_predecessors.size()); + cugraph::test::device_gatherv(*handle_, d_mg_predecessors.data(), d_mg_predecessors.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 4-2. unrenumbr MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 3-2. unrenumbr MG results cugraph::unrenumber_int_vertices( - handle, + *handle_, d_mg_aggregate_predecessors.data(), d_mg_aggregate_predecessors.size(), d_mg_aggregate_renumber_map_labels.data(), std::vector{mg_graph_view.number_of_vertices()}); std::tie(std::ignore, d_mg_aggregate_distances) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_distances); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_distances); std::tie(std::ignore, d_mg_aggregate_predecessors) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_predecessors); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_predecessors); - // 4-3. create SG graph + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, false, false); + *handle_, input_usecase, false, false); auto sg_graph_view = sg_graph.view(); ASSERT_TRUE(mg_graph_view.number_of_vertices() == sg_graph_view.number_of_vertices()); - // 4-4. run SG BFS + // 3-4. run SG BFS rmm::device_uvector d_sg_distances(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_sg_predecessors( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); vertex_t unrenumbered_source{}; raft::update_host(&unrenumbered_source, d_mg_aggregate_renumber_map_labels.data() + bfs_usecase.source, size_t{1}, - handle.get_stream()); - handle.sync_stream(); + handle_->get_stream()); + handle_->sync_stream(); - rmm::device_scalar const d_sg_source(unrenumbered_source, handle.get_stream()); - cugraph::bfs(handle, + rmm::device_scalar const d_sg_source(unrenumbered_source, handle_->get_stream()); + cugraph::bfs(*handle_, sg_graph_view, d_sg_distances.data(), d_sg_predecessors.data(), @@ -197,18 +186,18 @@ class Tests_MGBFS : public ::testing::TestWithParam::max()); - // 4-5. compare + // 3-5. compare std::vector h_sg_offsets(sg_graph_view.number_of_vertices() + 1); std::vector h_sg_indices(sg_graph_view.number_of_edges()); raft::update_host(h_sg_offsets.data(), sg_graph_view.local_edge_partition_view().offsets(), sg_graph_view.number_of_vertices() + 1, - handle.get_stream()); + handle_->get_stream()); raft::update_host(h_sg_indices.data(), sg_graph_view.local_edge_partition_view().indices(), sg_graph_view.number_of_edges(), - handle.get_stream()); + handle_->get_stream()); std::vector h_mg_aggregate_distances(mg_graph_view.number_of_vertices()); std::vector h_mg_aggregate_predecessors(mg_graph_view.number_of_vertices()); @@ -216,22 +205,24 @@ class Tests_MGBFS : public ::testing::TestWithParamget_stream()); raft::update_host(h_mg_aggregate_predecessors.data(), d_mg_aggregate_predecessors.data(), d_mg_aggregate_predecessors.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_distances(sg_graph_view.number_of_vertices()); std::vector h_sg_predecessors(sg_graph_view.number_of_vertices()); - raft::update_host( - h_sg_distances.data(), d_sg_distances.data(), d_sg_distances.size(), handle.get_stream()); + raft::update_host(h_sg_distances.data(), + d_sg_distances.data(), + d_sg_distances.size(), + handle_->get_stream()); raft::update_host(h_sg_predecessors.data(), d_sg_predecessors.data(), d_sg_predecessors.size(), - handle.get_stream()); - handle.sync_stream(); + handle_->get_stream()); + handle_->sync_stream(); ASSERT_TRUE(std::equal(h_mg_aggregate_distances.begin(), h_mg_aggregate_distances.end(), @@ -258,8 +249,14 @@ class Tests_MGBFS : public ::testing::TestWithParam handle_; }; +template +std::unique_ptr Tests_MGBFS::handle_ = nullptr; + using Tests_MGBFS_File = Tests_MGBFS; using Tests_MGBFS_Rmat = Tests_MGBFS; diff --git a/cpp/tests/traversal/mg_extract_bfs_paths_test.cu b/cpp/tests/traversal/mg_extract_bfs_paths_test.cu index 351f1c28abf..df6f757c71a 100644 --- a/cpp/tests/traversal/mg_extract_bfs_paths_test.cu +++ b/cpp/tests/traversal/mg_extract_bfs_paths_test.cu @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -43,46 +44,35 @@ #include #include -struct ExtractBfsPaths_Usecase { +struct ExtractBFSPaths_Usecase { size_t source{0}; size_t num_paths_to_check{0}; bool check_correctness{true}; }; template -class Tests_ExtractBfsPaths - : public ::testing::TestWithParam> { +class Tests_MGExtractBFSPaths + : public ::testing::TestWithParam> { public: - Tests_ExtractBfsPaths() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + Tests_MGExtractBFSPaths() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} template - void run_current_test(ExtractBfsPaths_Usecase const& extract_bfs_paths_usecase, + void run_current_test(ExtractBFSPaths_Usecase const& extract_bfs_paths_usecase, input_usecase_t const& input_usecase) { constexpr bool renumber = true; using weight_t = float; - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement hr_clock.start(); @@ -90,7 +80,7 @@ class Tests_ExtractBfsPaths auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, renumber); + *handle_, input_usecase, true, renumber); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement @@ -110,17 +100,17 @@ class Tests_ExtractBfsPaths << "Invalid num_paths_to_check, more than number of vertices"; rmm::device_uvector d_mg_distances(mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_mg_predecessors( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); auto const d_mg_source = mg_graph_view.in_local_vertex_partition_range_nocheck(extract_bfs_paths_usecase.source) ? std::make_optional>(extract_bfs_paths_usecase.source, - handle.get_stream()) + handle_->get_stream()) : std::nullopt; - cugraph::bfs(handle, + cugraph::bfs(*handle_, mg_graph_view, d_mg_distances.data(), d_mg_predecessors.data(), @@ -133,22 +123,22 @@ class Tests_ExtractBfsPaths std::vector h_mg_predecessors(mg_graph_view.local_vertex_partition_range_size()); raft::update_host( - h_mg_distances.data(), d_mg_distances.data(), d_mg_distances.size(), handle.get_stream()); + h_mg_distances.data(), d_mg_distances.data(), d_mg_distances.size(), handle_->get_stream()); raft::update_host(h_mg_predecessors.data(), d_mg_predecessors.data(), d_mg_predecessors.size(), - handle.get_stream()); + handle_->get_stream()); vertex_t invalid_vertex = cugraph::invalid_vertex_id::value; auto d_mg_destinations = cugraph::test::randomly_select_destinations( - handle, + *handle_, mg_graph_view.local_vertex_partition_range_size(), mg_graph_view.local_vertex_partition_range_first(), d_mg_predecessors, extract_bfs_paths_usecase.num_paths_to_check); - rmm::device_uvector d_mg_paths(0, handle.get_stream()); + rmm::device_uvector d_mg_paths(0, handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement @@ -159,7 +149,7 @@ class Tests_ExtractBfsPaths vertex_t mg_max_path_length{0}; - std::tie(d_mg_paths, mg_max_path_length) = extract_bfs_paths(handle, + std::tie(d_mg_paths, mg_max_path_length) = extract_bfs_paths(*handle_, mg_graph_view, d_mg_distances.data(), d_mg_predecessors.data(), @@ -176,50 +166,50 @@ class Tests_ExtractBfsPaths if (extract_bfs_paths_usecase.check_correctness) { auto [sg_graph, d_sg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); rmm::device_uvector d_sg_destinations(d_mg_destinations.size(), - handle.get_stream()); + handle_->get_stream()); raft::copy(d_sg_destinations.data(), d_mg_destinations.data(), d_mg_destinations.size(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_sg_distances(sg_graph_view.number_of_vertices(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_sg_predecessors(sg_graph_view.number_of_vertices(), - handle.get_stream()); - rmm::device_uvector d_sg_paths(0, handle.get_stream()); + handle_->get_stream()); + rmm::device_uvector d_sg_paths(0, handle_->get_stream()); // // I think I can do this with allgatherv... think about this. // allgather distances and predecessors // { - std::vector rx_counts(comm.get_size(), size_t{0}); - std::vector displacements(comm.get_size(), size_t{0}); - for (int i = 0; i < comm.get_size(); ++i) { + std::vector rx_counts(handle_->get_comms().get_size(), size_t{0}); + std::vector displacements(handle_->get_comms().get_size(), size_t{0}); + for (int i = 0; i < handle_->get_comms().get_size(); ++i) { rx_counts[i] = mg_graph_view.vertex_partition_range_size(i); displacements[i] = (i == 0) ? 0 : displacements[i - 1] + rx_counts[i - 1]; } - comm.allgatherv(d_mg_distances.data(), - d_sg_distances.data(), - rx_counts.data(), - displacements.data(), - handle.get_stream()); - - comm.allgatherv(d_mg_predecessors.data(), - d_sg_predecessors.data(), - rx_counts.data(), - displacements.data(), - handle.get_stream()); + handle_->get_comms().allgatherv(d_mg_distances.data(), + d_sg_distances.data(), + rx_counts.data(), + displacements.data(), + handle_->get_stream()); + + handle_->get_comms().allgatherv(d_mg_predecessors.data(), + d_sg_predecessors.data(), + rx_counts.data(), + displacements.data(), + handle_->get_stream()); } vertex_t sg_max_path_length; - std::tie(d_sg_paths, sg_max_path_length) = extract_bfs_paths(handle, + std::tie(d_sg_paths, sg_max_path_length) = extract_bfs_paths(*handle_, sg_graph_view, d_sg_distances.data(), d_sg_predecessors.data(), @@ -230,9 +220,9 @@ class Tests_ExtractBfsPaths std::vector h_sg_paths(d_sg_paths.size()); raft::update_host( - h_mg_paths.data(), d_mg_paths.data(), d_mg_paths.size(), handle.get_stream()); + h_mg_paths.data(), d_mg_paths.data(), d_mg_paths.size(), handle_->get_stream()); raft::update_host( - h_sg_paths.data(), d_sg_paths.data(), d_sg_paths.size(), handle.get_stream()); + h_sg_paths.data(), d_sg_paths.data(), d_sg_paths.size(), handle_->get_stream()); ASSERT_EQ(d_mg_paths.size(), mg_max_path_length * d_mg_destinations.size()); ASSERT_EQ(d_sg_paths.size(), sg_max_path_length * d_sg_destinations.size()); @@ -254,33 +244,39 @@ class Tests_ExtractBfsPaths } } } + + private: + static std::unique_ptr handle_; }; -using Tests_ExtractBfsPaths_File = Tests_ExtractBfsPaths; -using Tests_ExtractBfsPaths_Rmat = Tests_ExtractBfsPaths; +template +std::unique_ptr Tests_MGExtractBFSPaths::handle_ = nullptr; + +using Tests_MGExtractBFSPaths_File = Tests_MGExtractBFSPaths; +using Tests_MGExtractBFSPaths_Rmat = Tests_MGExtractBFSPaths; // FIXME: add tests for type combinations -TEST_P(Tests_ExtractBfsPaths_File, CheckInt32Int32) +TEST_P(Tests_MGExtractBFSPaths_File, CheckInt32Int32) { auto param = GetParam(); run_current_test(std::get<0>(param), std::get<1>(param)); } -TEST_P(Tests_ExtractBfsPaths_Rmat, CheckInt32Int32) +TEST_P(Tests_MGExtractBFSPaths_Rmat, CheckInt32Int32) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_ExtractBfsPaths_Rmat, CheckInt32Int64) +TEST_P(Tests_MGExtractBFSPaths_Rmat, CheckInt32Int64) { auto param = GetParam(); run_current_test( std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param))); } -TEST_P(Tests_ExtractBfsPaths_Rmat, CheckInt64Int64) +TEST_P(Tests_MGExtractBFSPaths_Rmat, CheckInt64Int64) { auto param = GetParam(); run_current_test( @@ -289,27 +285,27 @@ TEST_P(Tests_ExtractBfsPaths_Rmat, CheckInt64Int64) INSTANTIATE_TEST_SUITE_P( file_test, - Tests_ExtractBfsPaths_File, + Tests_MGExtractBFSPaths_File, ::testing::Values( // enable correctness checks - std::make_tuple(ExtractBfsPaths_Usecase{0, 10}, + std::make_tuple(ExtractBFSPaths_Usecase{0, 10}, cugraph::test::File_Usecase("test/datasets/karate.mtx")), - std::make_tuple(ExtractBfsPaths_Usecase{0, 100}, + std::make_tuple(ExtractBFSPaths_Usecase{0, 100}, cugraph::test::File_Usecase("test/datasets/polbooks.mtx")), - std::make_tuple(ExtractBfsPaths_Usecase{0, 100}, + std::make_tuple(ExtractBFSPaths_Usecase{0, 100}, cugraph::test::File_Usecase("test/datasets/netscience.mtx")), - std::make_tuple(ExtractBfsPaths_Usecase{100, 100}, + std::make_tuple(ExtractBFSPaths_Usecase{100, 100}, cugraph::test::File_Usecase("test/datasets/netscience.mtx")), - std::make_tuple(ExtractBfsPaths_Usecase{1000, 2000}, + std::make_tuple(ExtractBFSPaths_Usecase{1000, 2000}, cugraph::test::File_Usecase("test/datasets/wiki2003.mtx")), - std::make_tuple(ExtractBfsPaths_Usecase{1000, 20000}, + std::make_tuple(ExtractBFSPaths_Usecase{1000, 20000}, cugraph::test::File_Usecase("test/datasets/wiki-Talk.mtx")))); INSTANTIATE_TEST_SUITE_P(rmat_small_test, - Tests_ExtractBfsPaths_Rmat, + Tests_MGExtractBFSPaths_Rmat, ::testing::Values( // enable correctness checks - std::make_tuple(ExtractBfsPaths_Usecase{0, 20}, + std::make_tuple(ExtractBFSPaths_Usecase{0, 20}, cugraph::test::Rmat_Usecase( 10, 16, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); @@ -319,11 +315,11 @@ INSTANTIATE_TEST_SUITE_P( vertex & edge type combination) by command line arguments and do not include more than one Rmat_Usecase that differ only in scale or edge factor (to avoid running same benchmarks more than once) */ - Tests_ExtractBfsPaths_Rmat, + Tests_MGExtractBFSPaths_Rmat, ::testing::Values( // disable correctness checks for large graphs std::make_pair( - ExtractBfsPaths_Usecase{0, 1000, false}, + ExtractBFSPaths_Usecase{0, 1000, false}, cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, false, false, 0, true)))); CUGRAPH_MG_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/traversal/mg_sssp_test.cpp b/cpp/tests/traversal/mg_sssp_test.cpp index a4aa2d4244d..6a804aaccea 100644 --- a/cpp/tests/traversal/mg_sssp_test.cpp +++ b/cpp/tests/traversal/mg_sssp_test.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -46,8 +47,10 @@ template class Tests_MGSSSP : public ::testing::TestWithParam> { public: Tests_MGSSSP() {} - static void SetupTestCase() {} - static void TearDownTestCase() {} + + static void SetUpTestCase() { handle_ = cugraph::test::initialize_mg_handle(); } + + static void TearDownTestCase() { handle_.reset(); } virtual void SetUp() {} virtual void TearDown() {} @@ -56,37 +59,23 @@ class Tests_MGSSSP : public ::testing::TestWithParam void run_current_test(SSSP_Usecase const& sssp_usecase, input_usecase_t const& input_usecase) { - // 1. initialize handle - raft::handle_t handle{}; HighResClock hr_clock{}; - raft::comms::initialize_mpi_comms(&handle, MPI_COMM_WORLD); - 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(sqrt(static_cast(comm_size))); - while (comm_size % row_comm_size != 0) { - --row_comm_size; - } - cugraph::partition_2d::subcomm_factory_t - subcomm_factory(handle, row_comm_size); - - // 2. create MG graph + // 1. create MG graph if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } auto [mg_graph, d_mg_renumber_map_labels] = cugraph::test::construct_graph( - handle, input_usecase, true, true); + *handle_, input_usecase, true, true); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + 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"; @@ -98,20 +87,20 @@ class Tests_MGSSSP : public ::testing::TestWithParam(sssp_usecase.source) < mg_graph_view.number_of_vertices()) << "Invalid starting source."; - // 3. run MG SSSP + // 2. run MG SSSP rmm::device_uvector d_mg_distances(mg_graph_view.local_vertex_partition_range_size(), - handle.get_stream()); + handle_->get_stream()); rmm::device_uvector d_mg_predecessors( - mg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + mg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); if (cugraph::test::g_perf) { RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - handle.get_comms().barrier(); + handle_->get_comms().barrier(); hr_clock.start(); } - cugraph::sssp(handle, + cugraph::sssp(*handle_, mg_graph_view, d_mg_distances.data(), d_mg_predecessors.data(), @@ -120,71 +109,71 @@ class Tests_MGSSSP : public ::testing::TestWithParamget_comms().barrier(); double elapsed_time{0.0}; hr_clock.stop(&elapsed_time); std::cout << "MG SSSP took " << elapsed_time * 1e-6 << " s.\n"; } - // 4. copmare SG & MG results + // 3. copmare SG & MG results if (sssp_usecase.check_correctness) { - // 4-1. aggregate MG results + // 3-1. aggregate MG results auto d_mg_aggregate_renumber_map_labels = cugraph::test::device_gatherv( - handle, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); + *handle_, (*d_mg_renumber_map_labels).data(), (*d_mg_renumber_map_labels).size()); auto d_mg_aggregate_distances = - cugraph::test::device_gatherv(handle, d_mg_distances.data(), d_mg_distances.size()); + cugraph::test::device_gatherv(*handle_, d_mg_distances.data(), d_mg_distances.size()); auto d_mg_aggregate_predecessors = - cugraph::test::device_gatherv(handle, d_mg_predecessors.data(), d_mg_predecessors.size()); + cugraph::test::device_gatherv(*handle_, d_mg_predecessors.data(), d_mg_predecessors.size()); - if (handle.get_comms().get_rank() == int{0}) { - // 4-2. unrenumber MG results + if (handle_->get_comms().get_rank() == int{0}) { + // 3-2. unrenumber MG results cugraph::unrenumber_int_vertices( - handle, + *handle_, d_mg_aggregate_predecessors.data(), d_mg_aggregate_predecessors.size(), d_mg_aggregate_renumber_map_labels.data(), std::vector{mg_graph_view.number_of_vertices()}); std::tie(std::ignore, d_mg_aggregate_distances) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_distances); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_distances); std::tie(std::ignore, d_mg_aggregate_predecessors) = cugraph::test::sort_by_key( - handle, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_predecessors); + *handle_, d_mg_aggregate_renumber_map_labels, d_mg_aggregate_predecessors); - // 4-3. create SG graph + // 3-3. create SG graph - cugraph::graph_t sg_graph(handle); + cugraph::graph_t sg_graph(*handle_); std::tie(sg_graph, std::ignore) = cugraph::test::construct_graph( - handle, input_usecase, true, false); + *handle_, input_usecase, true, false); auto sg_graph_view = sg_graph.view(); ASSERT_TRUE(mg_graph_view.number_of_vertices() == sg_graph_view.number_of_vertices()); - // 4-4. run SG SSSP + // 3-4. run SG SSSP rmm::device_uvector d_sg_distances( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); rmm::device_uvector d_sg_predecessors( - sg_graph_view.local_vertex_partition_range_size(), handle.get_stream()); + sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); vertex_t unrenumbered_source{}; raft::update_host(&unrenumbered_source, d_mg_aggregate_renumber_map_labels.data() + sssp_usecase.source, size_t{1}, - handle.get_stream()); - handle.sync_stream(); + handle_->get_stream()); + handle_->sync_stream(); - cugraph::sssp(handle, + cugraph::sssp(*handle_, sg_graph_view, d_sg_distances.data(), d_sg_predecessors.data(), unrenumbered_source, std::numeric_limits::max()); - // 4-5. compare + // 3-5. compare std::vector h_sg_offsets(sg_graph_view.number_of_vertices() + 1); std::vector h_sg_indices(sg_graph_view.number_of_edges()); @@ -192,37 +181,39 @@ class Tests_MGSSSP : public ::testing::TestWithParamget_stream()); raft::update_host(h_sg_indices.data(), sg_graph_view.local_edge_partition_view().indices(), sg_graph_view.number_of_edges(), - handle.get_stream()); + handle_->get_stream()); raft::update_host(h_sg_weights.data(), *(sg_graph_view.local_edge_partition_view().weights()), sg_graph_view.number_of_edges(), - handle.get_stream()); + handle_->get_stream()); std::vector h_mg_aggregate_distances(mg_graph_view.number_of_vertices()); std::vector h_mg_aggregate_predecessors(mg_graph_view.number_of_vertices()); raft::update_host(h_mg_aggregate_distances.data(), d_mg_aggregate_distances.data(), d_mg_aggregate_distances.size(), - handle.get_stream()); + handle_->get_stream()); raft::update_host(h_mg_aggregate_predecessors.data(), d_mg_aggregate_predecessors.data(), d_mg_aggregate_predecessors.size(), - handle.get_stream()); + handle_->get_stream()); std::vector h_sg_distances(sg_graph_view.number_of_vertices()); std::vector h_sg_predecessors(sg_graph_view.number_of_vertices()); - raft::update_host( - h_sg_distances.data(), d_sg_distances.data(), d_sg_distances.size(), handle.get_stream()); + raft::update_host(h_sg_distances.data(), + d_sg_distances.data(), + d_sg_distances.size(), + handle_->get_stream()); raft::update_host(h_sg_predecessors.data(), d_sg_predecessors.data(), d_sg_predecessors.size(), - handle.get_stream()); + handle_->get_stream()); - handle.sync_stream(); + handle_->sync_stream(); auto max_weight_element = std::max_element(h_sg_weights.begin(), h_sg_weights.end()); auto epsilon = *max_weight_element * weight_t{1e-6}; @@ -259,8 +250,14 @@ class Tests_MGSSSP : public ::testing::TestWithParam handle_; }; +template +std::unique_ptr Tests_MGSSSP::handle_ = nullptr; + using Tests_MGSSSP_File = Tests_MGSSSP; using Tests_MGSSSP_Rmat = Tests_MGSSSP; diff --git a/cpp/tests/traversal/ms_bfs_test.cu b/cpp/tests/traversal/ms_bfs_test.cu index 369ccd7b2c5..b9935f76cc0 100644 --- a/cpp/tests/traversal/ms_bfs_test.cu +++ b/cpp/tests/traversal/ms_bfs_test.cu @@ -78,7 +78,8 @@ void translate_vertex_ids(raft::handle_t const& handle, class Tests_MsBfs : public ::testing::TestWithParam { public: Tests_MsBfs() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/traversal/sssp_test.cpp b/cpp/tests/traversal/sssp_test.cpp index b3bca20e01e..81c80a4fe5c 100644 --- a/cpp/tests/traversal/sssp_test.cpp +++ b/cpp/tests/traversal/sssp_test.cpp @@ -91,7 +91,8 @@ template class Tests_SSSP : public ::testing::TestWithParam> { public: Tests_SSSP() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} virtual void SetUp() {} diff --git a/cpp/tests/tree/mst_test.cu b/cpp/tests/tree/mst_test.cu index 75122e20451..67f65941710 100644 --- a/cpp/tests/tree/mst_test.cu +++ b/cpp/tests/tree/mst_test.cu @@ -58,8 +58,10 @@ typedef struct Mst_Usecase_t { class Tests_Mst : public ::testing::TestWithParam { public: Tests_Mst() {} - static void SetupTestCase() {} + + static void SetUpTestCase() {} static void TearDownTestCase() {} + virtual void SetUp() {} virtual void TearDown() {} diff --git a/cpp/tests/utilities/base_fixture.hpp b/cpp/tests/utilities/base_fixture.hpp index 09c9e343e3b..88991a6bb40 100644 --- a/cpp/tests/utilities/base_fixture.hpp +++ b/cpp/tests/utilities/base_fixture.hpp @@ -16,10 +16,12 @@ #pragma once -#include #include +#include #include +#include + #include #include #include @@ -216,11 +218,9 @@ inline auto parse_test_options(int argc, char** argv) #define CUGRAPH_MG_TEST_PROGRAM_MAIN() \ int main(int argc, char** argv) \ { \ - MPI_TRY(MPI_Init(&argc, &argv)); \ - int comm_rank{}; \ - int comm_size{}; \ - MPI_TRY(MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank)); \ - MPI_TRY(MPI_Comm_size(MPI_COMM_WORLD, &comm_size)); \ + cugraph::test::initialize_mpi(argc, argv); \ + auto comm_rank = cugraph::test::query_mpi_comm_world_rank(); \ + auto comm_size = cugraph::test::query_mpi_comm_world_size(); \ int num_gpus_per_node{}; \ RAFT_CUDA_TRY(cudaGetDeviceCount(&num_gpus_per_node)); \ RAFT_CUDA_TRY(cudaSetDevice(comm_rank % num_gpus_per_node)); \ @@ -243,6 +243,6 @@ inline auto parse_test_options(int argc, char** argv) ? std::make_optional(cmd_opts["test_file_name"].as()) \ : std::nullopt; \ auto ret = RUN_ALL_TESTS(); \ - MPI_TRY(MPI_Finalize()); \ + cugraph::test::finalize_mpi(); \ return ret; \ } diff --git a/cpp/tests/utilities/mg_utilities.cpp b/cpp/tests/utilities/mg_utilities.cpp new file mode 100644 index 00000000000..be98c96fc1b --- /dev/null +++ b/cpp/tests/utilities/mg_utilities.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2021-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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include + +#include +#include +#include + +#include + +namespace cugraph { +namespace test { + +void initialize_mpi(int argc, char** argv) { RAFT_MPI_TRY(MPI_Init(&argc, &argv)); } + +void finalize_mpi() { RAFT_MPI_TRY(MPI_Finalize()); } + +int query_mpi_comm_world_rank() +{ + int comm_rank{}; + RAFT_MPI_TRY(MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank)); + return comm_rank; +} + +int query_mpi_comm_world_size() +{ + int comm_size{}; + RAFT_MPI_TRY(MPI_Comm_size(MPI_COMM_WORLD, &comm_size)); + return comm_size; +} + +std::unique_ptr initialize_mg_handle() +{ + std::unique_ptr handle{nullptr}; + + auto constexpr pool_size = 64; // FIXME: tuning parameter + + handle = std::make_unique(rmm::cuda_stream_per_thread, + std::make_shared(pool_size)); + + raft::comms::initialize_mpi_comms(handle.get(), MPI_COMM_WORLD); + auto& comm = handle->get_comms(); + auto const comm_size = comm.get_size(); + + auto row_comm_size = static_cast(sqrt(static_cast(comm_size))); + while (comm_size % row_comm_size != 0) { + --row_comm_size; + } + + cugraph::partition_2d::subcomm_factory_t subcomm_factory( + *handle, row_comm_size); + + return std::move(handle); +} + +void enforce_p2p_initialization(raft::handle_t const& handle) +{ + auto& comm = handle.get_comms(); + auto const comm_size = comm.get_size(); + + rmm::device_uvector tx_ints(comm_size, handle.get_stream()); + rmm::device_uvector rx_ints(comm_size, handle.get_stream()); + std::vector tx_sizes(comm_size, size_t{1}); + std::vector tx_offsets(comm_size); + std::iota(tx_offsets.begin(), tx_offsets.end(), size_t{0}); + std::vector tx_ranks(comm_size); + std::iota(tx_ranks.begin(), tx_ranks.end(), int32_t{0}); + auto rx_sizes = tx_sizes; + auto rx_offsets = tx_offsets; + auto rx_ranks = tx_ranks; + + comm.device_multicast_sendrecv(tx_ints.data(), + tx_sizes, + tx_offsets, + tx_ranks, + rx_ints.data(), + rx_sizes, + rx_offsets, + rx_ranks, + handle.get_stream()); + + handle.sync_stream(); +} + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/mg_utilities.hpp b/cpp/tests/utilities/mg_utilities.hpp new file mode 100644 index 00000000000..88212b3420e --- /dev/null +++ b/cpp/tests/utilities/mg_utilities.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2021-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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +#include + +namespace cugraph { +namespace test { + +void initialize_mpi(int argc, char** argv); + +void finalize_mpi(); + +int query_mpi_comm_world_rank(); +int query_mpi_comm_world_size(); + +std::unique_ptr initialize_mg_handle(); + +// NCCL lazily initializes for P2P, and this enforces P2P initialization for better performance +// measurements +void enforce_p2p_initialization(raft::handle_t const& handle); + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/misc_utilities.cpp b/cpp/tests/utilities/misc_utilities.cpp index 1194cc3788f..85949416ad6 100644 --- a/cpp/tests/utilities/misc_utilities.cpp +++ b/cpp/tests/utilities/misc_utilities.cpp @@ -15,11 +15,8 @@ */ #include -#include -#include - -#include -#include +#include +#include namespace cugraph { namespace test { @@ -35,34 +32,5 @@ std::string getFileName(const std::string& s) return (""); } -void enforce_p2p_initialization(raft::handle_t const& handle) -{ - auto& comm = handle.get_comms(); - auto const comm_size = comm.get_size(); - - rmm::device_uvector tx_ints(comm_size, handle.get_stream()); - rmm::device_uvector rx_ints(comm_size, handle.get_stream()); - std::vector tx_sizes(comm_size, size_t{1}); - std::vector tx_offsets(comm_size); - std::iota(tx_offsets.begin(), tx_offsets.end(), size_t{0}); - std::vector tx_ranks(comm_size); - std::iota(tx_ranks.begin(), tx_ranks.end(), int32_t{0}); - auto rx_sizes = tx_sizes; - auto rx_offsets = tx_offsets; - auto rx_ranks = tx_ranks; - - comm.device_multicast_sendrecv(tx_ints.data(), - tx_sizes, - tx_offsets, - tx_ranks, - rx_ints.data(), - rx_sizes, - rx_offsets, - rx_ranks, - handle.get_stream()); - - handle.sync_stream(); -} - } // namespace test } // namespace cugraph diff --git a/cpp/tests/utilities/test_utilities.hpp b/cpp/tests/utilities/test_utilities.hpp index 655680a1070..ce8813bcb20 100644 --- a/cpp/tests/utilities/test_utilities.hpp +++ b/cpp/tests/utilities/test_utilities.hpp @@ -361,9 +361,5 @@ std::vector random_vector(L size, unsigned seed = 0) return v; } -// NCCL lazily initializes for P2P, and this enforces P2P initialization for better performance -// measurements -void enforce_p2p_initialization(raft::handle_t const& handle); - } // namespace test } // namespace cugraph