From d6fa29e7888030f669e570876558dfb6805e01c6 Mon Sep 17 00:00:00 2001 From: Seunghwa Kang <45857425+seunghwak@users.noreply.github.com> Date: Tue, 19 Mar 2024 13:38:15 -0700 Subject: [PATCH] Refactor test utility functions and update SG & MG core_number tests to test with edge masking (#4253) We previously had `test_utilities.hpp` having all different sorts of function declarations and `property_generator.cuh` (which is necessary to create an edge mask) was only for primitives testing. This PR divides `test_utilities.hpp` to multiple files (`check_utilities.hpp`, `conversion_utilities.hpp`, `csv_file_utilities.hpp`, `matrix_market_file_utilities.hpp`, and `misc_utilties.hpp`) renamed/moved `tests/prims/property_generator.cuh` to `tests/utilities/property_generator_utilities.hpp` (now this file can be included from .cpp files). Updated SG & MG core_number tests to use property generator to create an edge mask. Authors: - Seunghwa Kang (https://github.com/seunghwak) Approvers: - Naim (https://github.com/naimnv) - Joseph Nke (https://github.com/jnke2016) - Chuck Hastings (https://github.com/ChuckHastings) URL: https://github.com/rapidsai/cugraph/pull/4253 --- cpp/src/cores/core_number_impl.cuh | 2 - .../transform_reduce_e_by_src_dst_key.cuh | 1 + cpp/tests/CMakeLists.txt | 6 +- cpp/tests/c_api/mg_test_utils.cpp | 2 +- .../betweenness_centrality_reference.hpp | 2 - .../betweenness_centrality_test.cpp | 9 +- .../betweenness_centrality_validate.cu | 2 +- .../edge_betweenness_centrality_test.cpp | 20 +- .../eigenvector_centrality_test.cpp | 2 +- cpp/tests/centrality/katz_centrality_test.cpp | 2 +- .../mg_betweenness_centrality_test.cpp | 2 +- .../mg_edge_betweenness_centrality_test.cpp | 12 +- .../mg_eigenvector_centrality_test.cpp | 2 +- .../centrality/mg_katz_centrality_test.cpp | 2 +- cpp/tests/community/egonet_test.cpp | 1 - cpp/tests/community/egonet_validate.cu | 2 +- cpp/tests/community/legacy_ecg_test.cpp | 2 + cpp/tests/community/leiden_test.cpp | 1 - cpp/tests/community/louvain_test.cpp | 2 +- cpp/tests/community/mg_ecg_test.cpp | 2 +- cpp/tests/community/mg_egonet_test.cu | 2 +- cpp/tests/community/mg_leiden_test.cpp | 2 +- cpp/tests/community/mg_louvain_test.cpp | 3 +- .../community/mg_triangle_count_test.cpp | 2 +- cpp/tests/community/triangle_count_test.cpp | 2 +- cpp/tests/components/mg_mis_test.cu | 2 - .../components/mg_vertex_coloring_test.cu | 2 - .../mg_weakly_connected_components_test.cpp | 1 + cpp/tests/components/mis_test.cu | 1 - cpp/tests/components/scc_test.cu | 1 - cpp/tests/components/vertex_coloring_test.cu | 1 - .../weakly_connected_components_test.cpp | 2 +- cpp/tests/cores/core_number_test.cpp | 80 ++- cpp/tests/cores/k_core_test.cpp | 1 - cpp/tests/cores/mg_core_number_test.cpp | 56 +- cpp/tests/cores/mg_k_core_test.cpp | 1 + cpp/tests/generators/erdos_renyi_test.cpp | 2 +- .../generate_bipartite_rmat_test.cpp | 2 +- cpp/tests/generators/generate_rmat_test.cpp | 2 +- cpp/tests/generators/generators_test.cpp | 3 +- cpp/tests/layout/legacy/force_atlas2_test.cu | 1 - cpp/tests/linear_assignment/hungarian_test.cu | 2 +- cpp/tests/link_analysis/hits_test.cpp | 30 +- cpp/tests/link_analysis/mg_hits_test.cpp | 38 +- cpp/tests/link_analysis/mg_pagerank_test.cpp | 4 +- cpp/tests/link_analysis/pagerank_test.cpp | 4 +- .../link_prediction/mg_similarity_test.cpp | 9 +- .../mg_weighted_similarity_test.cpp | 9 +- .../link_prediction/similarity_compare.cpp | 2 +- cpp/tests/link_prediction/similarity_test.cpp | 330 ---------- cpp/tests/link_prediction/similarity_test.cu | 19 +- .../weighted_similarity_test.cpp | 14 +- cpp/tests/prims/mg_count_if_e.cu | 32 +- cpp/tests/prims/mg_count_if_v.cu | 2 +- cpp/tests/prims/mg_extract_transform_e.cu | 21 +- ...extract_transform_v_frontier_outgoing_e.cu | 21 +- ...r_v_pair_transform_dst_nbr_intersection.cu | 8 +- ...transform_dst_nbr_weighted_intersection.cu | 8 +- ...er_v_random_select_transform_outgoing_e.cu | 18 +- ...rm_reduce_dst_key_aggregated_outgoing_e.cu | 68 +- ..._v_transform_reduce_incoming_outgoing_e.cu | 40 +- cpp/tests/prims/mg_reduce_v.cu | 22 +- cpp/tests/prims/mg_transform_e.cu | 18 +- ...st_nbr_intersection_of_e_endpoints_by_v.cu | 45 +- cpp/tests/prims/mg_transform_reduce_e.cu | 34 +- .../mg_transform_reduce_e_by_src_dst_key.cu | 74 +-- cpp/tests/prims/mg_transform_reduce_v.cu | 7 +- ...orm_reduce_v_frontier_outgoing_e_by_dst.cu | 38 +- cpp/tests/prims/property_generator.cuh | 176 ------ .../sampling/detail/nbr_sampling_utils.cuh | 1 - cpp/tests/sampling/mg_random_walks_test.cpp | 1 - cpp/tests/sampling/sg_random_walks_test.cpp | 1 - cpp/tests/structure/coarsen_graph_test.cpp | 2 +- .../count_self_loops_and_multi_edges_test.cpp | 2 +- cpp/tests/structure/degree_test.cpp | 2 +- ...has_edge_and_compute_multiplicity_test.cpp | 2 +- cpp/tests/structure/induced_subgraph_test.cpp | 8 +- ..._count_self_loops_and_multi_edges_test.cpp | 2 +- ...has_edge_and_compute_multiplicity_test.cpp | 2 +- .../structure/mg_induced_subgraph_test.cu | 1 + .../mg_select_random_vertices_test.cpp | 2 +- cpp/tests/structure/mg_symmetrize_test.cpp | 2 +- .../structure/mg_transpose_storage_test.cpp | 2 +- cpp/tests/structure/mg_transpose_test.cpp | 2 +- cpp/tests/structure/renumbering_test.cpp | 2 +- cpp/tests/structure/symmetrize_test.cpp | 2 +- .../structure/transpose_storage_test.cpp | 2 +- cpp/tests/structure/transpose_test.cpp | 2 +- cpp/tests/structure/weight_sum_test.cpp | 9 +- cpp/tests/traversal/bfs_test.cpp | 2 +- cpp/tests/traversal/extract_bfs_paths_test.cu | 2 +- cpp/tests/traversal/k_hop_nbrs_test.cpp | 2 +- cpp/tests/traversal/mg_bfs_test.cpp | 2 +- .../traversal/mg_extract_bfs_paths_test.cu | 2 +- cpp/tests/traversal/mg_k_hop_nbrs_test.cpp | 2 +- cpp/tests/traversal/mg_sssp_test.cpp | 2 +- cpp/tests/traversal/ms_bfs_test.cu | 1 - .../traversal/od_shortest_distances_test.cpp | 2 +- cpp/tests/traversal/sssp_test.cpp | 2 +- cpp/tests/tree/mst_test.cu | 1 - cpp/tests/utilities/check_utilities.hpp | 103 +++ cpp/tests/utilities/conversion_utilities.hpp | 234 +++++++ ...impl.cuh => conversion_utilities_impl.cuh} | 25 +- ...ities_mg.cu => conversion_utilities_mg.cu} | 134 ++-- ...ities_sg.cu => conversion_utilities_sg.cu} | 110 ++-- cpp/tests/utilities/csv_file_utilities.cu | 2 +- cpp/tests/utilities/csv_file_utilities.hpp | 59 ++ .../utilities/matrix_market_file_utilities.cu | 2 +- .../matrix_market_file_utilities.hpp | 122 ++++ cpp/tests/utilities/mg_utilities.cpp | 4 +- cpp/tests/utilities/misc_utilities.cpp | 2 +- cpp/tests/utilities/misc_utilities.hpp | 44 ++ .../utilities/property_generator_kernels.cuh | 85 +++ .../property_generator_utilities.hpp | 68 ++ .../property_generator_utilities_impl.cuh | 127 ++++ .../property_generator_utilities_mg.cu | 58 ++ .../property_generator_utilities_sg.cu | 58 ++ cpp/tests/utilities/test_graphs.hpp | 4 +- cpp/tests/utilities/test_utilities.hpp | 584 ------------------ 119 files changed, 1662 insertions(+), 1570 deletions(-) delete mode 100644 cpp/tests/link_prediction/similarity_test.cpp delete mode 100644 cpp/tests/prims/property_generator.cuh create mode 100644 cpp/tests/utilities/check_utilities.hpp create mode 100644 cpp/tests/utilities/conversion_utilities.hpp rename cpp/tests/utilities/{test_utilities_impl.cuh => conversion_utilities_impl.cuh} (96%) rename cpp/tests/utilities/{test_utilities_mg.cu => conversion_utilities_mg.cu} (84%) rename cpp/tests/utilities/{test_utilities_sg.cu => conversion_utilities_sg.cu} (78%) create mode 100644 cpp/tests/utilities/csv_file_utilities.hpp create mode 100644 cpp/tests/utilities/matrix_market_file_utilities.hpp create mode 100644 cpp/tests/utilities/misc_utilities.hpp create mode 100644 cpp/tests/utilities/property_generator_kernels.cuh create mode 100644 cpp/tests/utilities/property_generator_utilities.hpp create mode 100644 cpp/tests/utilities/property_generator_utilities_impl.cuh create mode 100644 cpp/tests/utilities/property_generator_utilities_mg.cu create mode 100644 cpp/tests/utilities/property_generator_utilities_sg.cu delete mode 100644 cpp/tests/utilities/test_utilities.hpp diff --git a/cpp/src/cores/core_number_impl.cuh b/cpp/src/cores/core_number_impl.cuh index 8c9234d6f7d..358b0ac2e00 100644 --- a/cpp/src/cores/core_number_impl.cuh +++ b/cpp/src/cores/core_number_impl.cuh @@ -88,8 +88,6 @@ void core_number(raft::handle_t const& handle, { // check input arguments. - CUGRAPH_EXPECTS(!graph_view.has_edge_mask(), "unimplemented."); - CUGRAPH_EXPECTS(graph_view.is_symmetric(), "Invalid input argument: core_number currently supports only undirected graphs."); CUGRAPH_EXPECTS(!graph_view.is_multigraph(), diff --git a/cpp/src/prims/transform_reduce_e_by_src_dst_key.cuh b/cpp/src/prims/transform_reduce_e_by_src_dst_key.cuh index 00876012906..2fb87527c62 100644 --- a/cpp/src/prims/transform_reduce_e_by_src_dst_key.cuh +++ b/cpp/src/prims/transform_reduce_e_by_src_dst_key.cuh @@ -19,6 +19,7 @@ #include "prims/property_op_utils.cuh" #include +#include #include #include #include diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 4d37c93326d..f2eb4c38a2b 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -25,9 +25,10 @@ rapids_test_init() add_library(cugraphtestutil STATIC utilities/matrix_market_file_utilities.cu utilities/csv_file_utilities.cu + utilities/property_generator_utilities_sg.cu utilities/thrust_wrapper.cu utilities/misc_utilities.cpp - utilities/test_utilities_sg.cu + utilities/conversion_utilities_sg.cu link_prediction/similarity_compare.cpp centrality/betweenness_centrality_validate.cu community/egonet_validate.cu @@ -438,7 +439,8 @@ if(BUILD_CUGRAPH_MG_TESTS) add_library(cugraphmgtestutil STATIC utilities/device_comm_wrapper.cu utilities/mg_utilities.cpp - utilities/test_utilities_mg.cu + utilities/conversion_utilities_mg.cu + utilities/property_generator_utilities_mg.cu sampling/random_walks_check_mg.cu c_api/mg_test_utils.cpp ) diff --git a/cpp/tests/c_api/mg_test_utils.cpp b/cpp/tests/c_api/mg_test_utils.cpp index 956f7872b5d..58c5e59c16f 100644 --- a/cpp/tests/c_api/mg_test_utils.cpp +++ b/cpp/tests/c_api/mg_test_utils.cpp @@ -19,8 +19,8 @@ #include "c_api/array.hpp" #include "c_api/c_test_utils.h" #include "c_api/resource_handle.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/centrality/betweenness_centrality_reference.hpp b/cpp/tests/centrality/betweenness_centrality_reference.hpp index cf197d19312..e0f094ee9cd 100644 --- a/cpp/tests/centrality/betweenness_centrality_reference.hpp +++ b/cpp/tests/centrality/betweenness_centrality_reference.hpp @@ -16,8 +16,6 @@ #pragma once -#include "utilities/test_utilities.hpp" - #include #include diff --git a/cpp/tests/centrality/betweenness_centrality_test.cpp b/cpp/tests/centrality/betweenness_centrality_test.cpp index 8f4b45516fd..a9a11d20f6f 100644 --- a/cpp/tests/centrality/betweenness_centrality_test.cpp +++ b/cpp/tests/centrality/betweenness_centrality_test.cpp @@ -16,8 +16,8 @@ #include "betweenness_centrality_reference.hpp" #include "betweenness_centrality_validate.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -116,8 +116,11 @@ class Tests_BetweennessCentrality } if (betweenness_usecase.check_correctness) { - auto [h_offsets, h_indices, h_wgt] = - cugraph::test::graph_to_host_csr(handle, graph_view, edge_weight_view); + auto [h_offsets, h_indices, h_wgt] = cugraph::test::graph_to_host_csr( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); auto h_seeds = cugraph::test::to_host(handle, d_seeds); auto h_reference_centralities = diff --git a/cpp/tests/centrality/betweenness_centrality_validate.cu b/cpp/tests/centrality/betweenness_centrality_validate.cu index 3983c3b004c..7d5df4d754e 100644 --- a/cpp/tests/centrality/betweenness_centrality_validate.cu +++ b/cpp/tests/centrality/betweenness_centrality_validate.cu @@ -15,7 +15,7 @@ */ #include "betweenness_centrality_validate.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/check_utilities.hpp" #include diff --git a/cpp/tests/centrality/edge_betweenness_centrality_test.cpp b/cpp/tests/centrality/edge_betweenness_centrality_test.cpp index f2f40e1d4cb..6e1e24e64d8 100644 --- a/cpp/tests/centrality/edge_betweenness_centrality_test.cpp +++ b/cpp/tests/centrality/edge_betweenness_centrality_test.cpp @@ -16,8 +16,8 @@ #include "centrality/betweenness_centrality_reference.hpp" #include "centrality/betweenness_centrality_validate.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -116,8 +116,11 @@ class Tests_EdgeBetweennessCentrality if (betweenness_usecase.check_correctness) { // Compute reference edge betweenness result - auto [h_offsets, h_indices, h_wgt] = - cugraph::test::graph_to_host_csr(handle, graph_view, edge_weight_view); + auto [h_offsets, h_indices, h_wgt] = cugraph::test::graph_to_host_csr( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); auto h_seeds = cugraph::test::to_host(handle, d_seeds); @@ -133,13 +136,20 @@ class Tests_EdgeBetweennessCentrality rmm::device_uvector d_reference_dst_vertex_ids(0, handle.get_stream()); std::tie(d_reference_src_vertex_ids, d_reference_dst_vertex_ids, std::ignore) = - cugraph::test::graph_to_device_coo(handle, graph_view, edge_weight_view); + cugraph::test::graph_to_device_coo( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); auto d_reference_centralities = cugraph::test::to_device(handle, h_reference_centralities); auto [d_cugraph_src_vertex_ids, d_cugraph_dst_vertex_ids, d_cugraph_results] = cugraph::test::graph_to_device_coo( - handle, graph_view, std::make_optional(d_centralities.view())); + handle, + graph_view, + std::make_optional(d_centralities.view()), + std::optional>(std::nullopt)); cugraph::test::edge_betweenness_centrality_validate(handle, d_cugraph_src_vertex_ids, diff --git a/cpp/tests/centrality/eigenvector_centrality_test.cpp b/cpp/tests/centrality/eigenvector_centrality_test.cpp index b3e6d148237..3387f11c1f2 100644 --- a/cpp/tests/centrality/eigenvector_centrality_test.cpp +++ b/cpp/tests/centrality/eigenvector_centrality_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/centrality/katz_centrality_test.cpp b/cpp/tests/centrality/katz_centrality_test.cpp index b3ffd2f053b..52481c1f4a8 100644 --- a/cpp/tests/centrality/katz_centrality_test.cpp +++ b/cpp/tests/centrality/katz_centrality_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/centrality/mg_betweenness_centrality_test.cpp b/cpp/tests/centrality/mg_betweenness_centrality_test.cpp index c9ebd192d6c..8c28d493c65 100644 --- a/cpp/tests/centrality/mg_betweenness_centrality_test.cpp +++ b/cpp/tests/centrality/mg_betweenness_centrality_test.cpp @@ -15,9 +15,9 @@ */ #include "centrality/betweenness_centrality_validate.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/centrality/mg_edge_betweenness_centrality_test.cpp b/cpp/tests/centrality/mg_edge_betweenness_centrality_test.cpp index ae4a02e537f..7b3613f8210 100644 --- a/cpp/tests/centrality/mg_edge_betweenness_centrality_test.cpp +++ b/cpp/tests/centrality/mg_edge_betweenness_centrality_test.cpp @@ -15,9 +15,9 @@ */ #include "centrality/betweenness_centrality_validate.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -119,7 +119,10 @@ class Tests_MGEdgeBetweennessCentrality // Extract MG results auto [d_cugraph_src_vertex_ids, d_cugraph_dst_vertex_ids, d_cugraph_results] = cugraph::test::graph_to_device_coo( - *handle_, mg_graph_view, std::make_optional(d_centralities.view())); + *handle_, + mg_graph_view, + std::make_optional(d_centralities.view()), + std::optional>(std::nullopt)); // Create SG graph so we can generate SG results cugraph::graph_t sg_graph(*handle_); @@ -152,7 +155,10 @@ class Tests_MGEdgeBetweennessCentrality auto [d_sg_src_vertex_ids, d_sg_dst_vertex_ids, d_sg_reference_centralities] = cugraph::test::graph_to_device_coo( - *handle_, sg_graph.view(), std::make_optional(d_sg_centralities.view())); + *handle_, + sg_graph.view(), + std::make_optional(d_sg_centralities.view()), + std::optional>(std::nullopt)); cugraph::test::edge_betweenness_centrality_validate(*handle_, d_cugraph_src_vertex_ids, diff --git a/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp b/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp index 4bd93bf87df..2081aea56b0 100644 --- a/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp +++ b/cpp/tests/centrality/mg_eigenvector_centrality_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/centrality/mg_katz_centrality_test.cpp b/cpp/tests/centrality/mg_katz_centrality_test.cpp index e8a3b2024d4..4455e6d7b99 100644 --- a/cpp/tests/centrality/mg_katz_centrality_test.cpp +++ b/cpp/tests/centrality/mg_katz_centrality_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/community/egonet_test.cpp b/cpp/tests/community/egonet_test.cpp index 848626d3df9..4795142d4ef 100644 --- a/cpp/tests/community/egonet_test.cpp +++ b/cpp/tests/community/egonet_test.cpp @@ -16,7 +16,6 @@ #include "community/egonet_validate.hpp" #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/community/egonet_validate.cu b/cpp/tests/community/egonet_validate.cu index ec7b5386cd5..9830deb8e1b 100644 --- a/cpp/tests/community/egonet_validate.cu +++ b/cpp/tests/community/egonet_validate.cu @@ -15,7 +15,7 @@ */ #include "community/egonet_validate.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include diff --git a/cpp/tests/community/legacy_ecg_test.cpp b/cpp/tests/community/legacy_ecg_test.cpp index c061215415a..c1b35cb975b 100644 --- a/cpp/tests/community/legacy_ecg_test.cpp +++ b/cpp/tests/community/legacy_ecg_test.cpp @@ -8,6 +8,8 @@ * license agreement from NVIDIA CORPORATION is strictly prohibited. * */ +#include "utilities/conversion_utilities.hpp" + #include #include diff --git a/cpp/tests/community/leiden_test.cpp b/cpp/tests/community/leiden_test.cpp index 0594fa39f9b..5ce0903f723 100644 --- a/cpp/tests/community/leiden_test.cpp +++ b/cpp/tests/community/leiden_test.cpp @@ -10,7 +10,6 @@ */ #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/community/louvain_test.cpp b/cpp/tests/community/louvain_test.cpp index b4445119367..0f30e0a7f12 100644 --- a/cpp/tests/community/louvain_test.cpp +++ b/cpp/tests/community/louvain_test.cpp @@ -9,8 +9,8 @@ * */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/community/mg_ecg_test.cpp b/cpp/tests/community/mg_ecg_test.cpp index e021d381ee6..a5e02c4f532 100644 --- a/cpp/tests/community/mg_ecg_test.cpp +++ b/cpp/tests/community/mg_ecg_test.cpp @@ -15,9 +15,9 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/community/mg_egonet_test.cu b/cpp/tests/community/mg_egonet_test.cu index 4f4a3cec925..66ab1f47312 100644 --- a/cpp/tests/community/mg_egonet_test.cu +++ b/cpp/tests/community/mg_egonet_test.cu @@ -17,9 +17,9 @@ #include "egonet_validate.hpp" #include "structure/detail/structure_utils.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/community/mg_leiden_test.cpp b/cpp/tests/community/mg_leiden_test.cpp index ff5b315f4a1..f1a2fc83192 100644 --- a/cpp/tests/community/mg_leiden_test.cpp +++ b/cpp/tests/community/mg_leiden_test.cpp @@ -15,9 +15,9 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/community/mg_louvain_test.cpp b/cpp/tests/community/mg_louvain_test.cpp index 53117d7823c..733ee9368ac 100644 --- a/cpp/tests/community/mg_louvain_test.cpp +++ b/cpp/tests/community/mg_louvain_test.cpp @@ -15,9 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/check_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/community/mg_triangle_count_test.cpp b/cpp/tests/community/mg_triangle_count_test.cpp index 70a3b38f09d..96e6fbb9f16 100644 --- a/cpp/tests/community/mg_triangle_count_test.cpp +++ b/cpp/tests/community/mg_triangle_count_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/community/triangle_count_test.cpp b/cpp/tests/community/triangle_count_test.cpp index ae41df072ca..90defcdc91b 100644 --- a/cpp/tests/community/triangle_count_test.cpp +++ b/cpp/tests/community/triangle_count_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/components/mg_mis_test.cu b/cpp/tests/components/mg_mis_test.cu index 04c346b0f00..c2469ba867d 100644 --- a/cpp/tests/components/mg_mis_test.cu +++ b/cpp/tests/components/mg_mis_test.cu @@ -16,12 +16,10 @@ #include "prims/fill_edge_src_dst_property.cuh" #include "prims/per_v_transform_reduce_incoming_outgoing_e.cuh" -#include "prims/property_generator.cuh" #include "prims/reduce_op.cuh" #include "prims/update_edge_src_dst_property.cuh" #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/components/mg_vertex_coloring_test.cu b/cpp/tests/components/mg_vertex_coloring_test.cu index ce4dadaa786..2c54e3cf065 100644 --- a/cpp/tests/components/mg_vertex_coloring_test.cu +++ b/cpp/tests/components/mg_vertex_coloring_test.cu @@ -16,13 +16,11 @@ #include "prims/fill_edge_src_dst_property.cuh" #include "prims/per_v_transform_reduce_incoming_outgoing_e.cuh" -#include "prims/property_generator.cuh" #include "prims/reduce_op.cuh" #include "prims/transform_reduce_e.cuh" #include "prims/update_edge_src_dst_property.cuh" #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/components/mg_weakly_connected_components_test.cpp b/cpp/tests/components/mg_weakly_connected_components_test.cpp index 88ffcdd5793..c510e3139fb 100644 --- a/cpp/tests/components/mg_weakly_connected_components_test.cpp +++ b/cpp/tests/components/mg_weakly_connected_components_test.cpp @@ -15,6 +15,7 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" diff --git a/cpp/tests/components/mis_test.cu b/cpp/tests/components/mis_test.cu index f3bdd3d0e8b..f98aa1fe0c7 100644 --- a/cpp/tests/components/mis_test.cu +++ b/cpp/tests/components/mis_test.cu @@ -18,7 +18,6 @@ #include "prims/reduce_op.cuh" #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/components/scc_test.cu b/cpp/tests/components/scc_test.cu index 914e7bb5004..c6c0af50528 100644 --- a/cpp/tests/components/scc_test.cu +++ b/cpp/tests/components/scc_test.cu @@ -15,7 +15,6 @@ #include "components/legacy/scc_matrix.cuh" #include "converters/legacy/COOtoCSR.cuh" #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/components/vertex_coloring_test.cu b/cpp/tests/components/vertex_coloring_test.cu index 27a0c5013bd..c7c37c6ad56 100644 --- a/cpp/tests/components/vertex_coloring_test.cu +++ b/cpp/tests/components/vertex_coloring_test.cu @@ -19,7 +19,6 @@ #include "prims/transform_reduce_e.cuh" #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/components/weakly_connected_components_test.cpp b/cpp/tests/components/weakly_connected_components_test.cpp index 747b49346e6..2dd82316b00 100644 --- a/cpp/tests/components/weakly_connected_components_test.cpp +++ b/cpp/tests/components/weakly_connected_components_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/thrust_wrapper.hpp" #include #include diff --git a/cpp/tests/cores/core_number_test.cpp b/cpp/tests/cores/core_number_test.cpp index 026a4a5f0df..fb6f26278af 100644 --- a/cpp/tests/cores/core_number_test.cpp +++ b/cpp/tests/cores/core_number_test.cpp @@ -15,11 +15,13 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include +#include #include #include #include @@ -198,6 +200,7 @@ struct CoreNumber_Usecase { size_t k_last{std::numeric_limits::max()}; // vertices that belong (k_last + 1)-core will // have core numbers of k_last + bool edge_masking{false}; bool check_correctness{true}; }; @@ -242,6 +245,13 @@ class Tests_CoreNumber } auto graph_view = graph.view(); + std::optional> edge_mask{std::nullopt}; + if (core_number_usecase.edge_masking) { + edge_mask = + cugraph::test::generate::edge_property(handle, graph_view, 2); + graph_view.attach_edge_mask((*edge_mask).view()); + } + ASSERT_TRUE(core_number_usecase.k_first <= core_number_usecase.k_last) << "Invalid pair of (k_first, k_last)."; @@ -267,18 +277,17 @@ class Tests_CoreNumber } if (core_number_usecase.check_correctness) { - cugraph::graph_t unrenumbered_graph(handle); - if (renumber) { - std::tie(unrenumbered_graph, std::ignore, std::ignore) = - cugraph::test::construct_graph( - handle, input_usecase, false, false, true, true); - } - auto unrenumbered_graph_view = renumber ? unrenumbered_graph.view() : graph_view; - - auto h_offsets = cugraph::test::to_host( - handle, unrenumbered_graph_view.local_edge_partition_view().offsets()); - auto h_indices = cugraph::test::to_host( - handle, unrenumbered_graph_view.local_edge_partition_view().indices()); + std::vector h_offsets{}; + std::vector h_indices{}; + std::tie(h_offsets, h_indices, std::ignore) = + cugraph::test::graph_to_host_csr( + handle, + graph_view, + std::nullopt, + d_renumber_map_labels + ? std::make_optional>((*d_renumber_map_labels).data(), + (*d_renumber_map_labels).size()) + : std::nullopt); auto h_reference_core_numbers = core_number_reference(h_offsets.data(), h_indices.data(), @@ -342,14 +351,23 @@ INSTANTIATE_TEST_SUITE_P( // enable correctness checks testing::Values( CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), false}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::IN, size_t{2}, size_t{2}, false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, size_t{1}, size_t{3}, false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::INOUT, size_t{2}, size_t{4}, false}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max()}, - CoreNumber_Usecase{cugraph::k_core_degree_type_t::IN, size_t{2}, size_t{2}}, - CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, size_t{1}, size_t{3}}, - CoreNumber_Usecase{cugraph::k_core_degree_type_t::INOUT, size_t{2}, size_t{4}}), + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), true}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), true}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), true}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::IN, size_t{2}, size_t{2}, true}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, size_t{1}, size_t{3}, true}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::INOUT, size_t{2}, size_t{4}, true}), testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), cugraph::test::File_Usecase("test/datasets/polbooks.mtx"), cugraph::test::File_Usecase("test/datasets/netscience.mtx")))); @@ -361,11 +379,17 @@ INSTANTIATE_TEST_SUITE_P( // enable correctness checks testing::Values( CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), true}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), true}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max()}), + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), true}), testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, true, false)))); INSTANTIATE_TEST_SUITE_P( @@ -377,8 +401,16 @@ INSTANTIATE_TEST_SUITE_P( Tests_CoreNumber_Rmat, ::testing::Combine( // disable correctness checks for large graphs - testing::Values(CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), false}), + testing::Values(CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, + size_t{0}, + std::numeric_limits::max(), + false, + false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, + size_t{0}, + std::numeric_limits::max(), + true, + false}), testing::Values(cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, true, false)))); CUGRAPH_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/cores/k_core_test.cpp b/cpp/tests/cores/k_core_test.cpp index ce5637a49f8..064b7862842 100644 --- a/cpp/tests/cores/k_core_test.cpp +++ b/cpp/tests/cores/k_core_test.cpp @@ -17,7 +17,6 @@ #include "k_core_validate.hpp" #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/cores/mg_core_number_test.cpp b/cpp/tests/cores/mg_core_number_test.cpp index ed6e9b86111..ac99d7d4a93 100644 --- a/cpp/tests/cores/mg_core_number_test.cpp +++ b/cpp/tests/cores/mg_core_number_test.cpp @@ -15,10 +15,11 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -44,6 +45,7 @@ struct CoreNumber_Usecase { size_t k_last{std::numeric_limits::max()}; // vertices that belong (k_last + 1)-core will // have core numbers of k_last + bool edge_masking{false}; bool check_correctness{true}; }; @@ -92,6 +94,13 @@ class Tests_MGCoreNumber auto mg_graph_view = mg_graph.view(); + std::optional> edge_mask{std::nullopt}; + if (core_number_usecase.edge_masking) { + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); + mg_graph_view.attach_edge_mask((*edge_mask).view()); + } + // 2. run MG CoreNumber rmm::device_uvector d_mg_core_numbers(mg_graph_view.local_vertex_partition_range_size(), @@ -215,14 +224,23 @@ INSTANTIATE_TEST_SUITE_P( // enable correctness checks ::testing::Values( CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::IN, size_t{2}, size_t{2}, false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, size_t{1}, size_t{3}, false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::INOUT, size_t{2}, size_t{4}, false}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), true}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max()}, - CoreNumber_Usecase{cugraph::k_core_degree_type_t::IN, size_t{2}, size_t{2}}, - CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, size_t{1}, size_t{3}}, - CoreNumber_Usecase{cugraph::k_core_degree_type_t::INOUT, size_t{2}, size_t{4}}), + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), true}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), true}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::IN, size_t{2}, size_t{2}, true}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, size_t{1}, size_t{3}, true}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::INOUT, size_t{2}, size_t{4}, true}), ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), cugraph::test::File_Usecase("test/datasets/polbooks.mtx"), cugraph::test::File_Usecase("test/datasets/netscience.mtx")))); @@ -233,11 +251,17 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Combine( ::testing::Values( CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), false}, + CoreNumber_Usecase{ + cugraph::k_core_degree_type_t::IN, size_t{0}, std::numeric_limits::max(), true}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max()}, + cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), true}, CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max()}), + cugraph::k_core_degree_type_t::INOUT, size_t{0}, std::numeric_limits::max(), true}), ::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, true, false)))); INSTANTIATE_TEST_SUITE_P( @@ -248,8 +272,16 @@ INSTANTIATE_TEST_SUITE_P( factor (to avoid running same benchmarks more than once) */ Tests_MGCoreNumber_Rmat, ::testing::Combine( - ::testing::Values(CoreNumber_Usecase{ - cugraph::k_core_degree_type_t::OUT, size_t{0}, std::numeric_limits::max(), false}), + ::testing::Values(CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, + size_t{0}, + std::numeric_limits::max(), + false, + false}, + CoreNumber_Usecase{cugraph::k_core_degree_type_t::OUT, + size_t{0}, + std::numeric_limits::max(), + true, + false}), ::testing::Values(cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, true, false)))); CUGRAPH_MG_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/cores/mg_k_core_test.cpp b/cpp/tests/cores/mg_k_core_test.cpp index 1a30fff2d5b..100c7fa3bcf 100644 --- a/cpp/tests/cores/mg_k_core_test.cpp +++ b/cpp/tests/cores/mg_k_core_test.cpp @@ -16,6 +16,7 @@ #include "k_core_validate.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" diff --git a/cpp/tests/generators/erdos_renyi_test.cpp b/cpp/tests/generators/erdos_renyi_test.cpp index af38a2796b8..348799e041a 100644 --- a/cpp/tests/generators/erdos_renyi_test.cpp +++ b/cpp/tests/generators/erdos_renyi_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/generators/generate_bipartite_rmat_test.cpp b/cpp/tests/generators/generate_bipartite_rmat_test.cpp index 3fbc5df794d..996d6a34dd1 100644 --- a/cpp/tests/generators/generate_bipartite_rmat_test.cpp +++ b/cpp/tests/generators/generate_bipartite_rmat_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/generators/generate_rmat_test.cpp b/cpp/tests/generators/generate_rmat_test.cpp index d821fd51e07..1abac4289f8 100644 --- a/cpp/tests/generators/generate_rmat_test.cpp +++ b/cpp/tests/generators/generate_rmat_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/generators/generators_test.cpp b/cpp/tests/generators/generators_test.cpp index 97e873b136b..34a95aa5542 100644 --- a/cpp/tests/generators/generators_test.cpp +++ b/cpp/tests/generators/generators_test.cpp @@ -15,7 +15,8 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/check_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include diff --git a/cpp/tests/layout/legacy/force_atlas2_test.cu b/cpp/tests/layout/legacy/force_atlas2_test.cu index fa19d092cb9..6ed33b6bf15 100644 --- a/cpp/tests/layout/legacy/force_atlas2_test.cu +++ b/cpp/tests/layout/legacy/force_atlas2_test.cu @@ -14,7 +14,6 @@ #include "layout/legacy/trust_worthiness.h" #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/linear_assignment/hungarian_test.cu b/cpp/tests/linear_assignment/hungarian_test.cu index 6c812d8f995..7962161a564 100644 --- a/cpp/tests/linear_assignment/hungarian_test.cu +++ b/cpp/tests/linear_assignment/hungarian_test.cu @@ -11,7 +11,7 @@ #include "cuda_profiler_api.h" #include "gtest/gtest.h" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/link_analysis/hits_test.cpp b/cpp/tests/link_analysis/hits_test.cpp index c67259697d9..ad82dc3a1d1 100644 --- a/cpp/tests/link_analysis/hits_test.cpp +++ b/cpp/tests/link_analysis/hits_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -187,13 +187,22 @@ class Tests_Hits : public ::testing::TestWithParam d_authorities(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_hubs.size()) - : std::vector(0); - + std::optional> d_initial_random_hubs{std::nullopt}; if (hits_usecase.check_initial_input) { - raft::update_device( - d_hubs.data(), initial_random_hubs.data(), initial_random_hubs.size(), handle.get_stream()); + raft::random::RngState rng_state(0); + d_initial_random_hubs = rmm::device_uvector(d_hubs.size(), handle.get_stream()); + cugraph::detail::uniform_random_fill(handle.get_stream(), + (*d_initial_random_hubs).data(), + (*d_initial_random_hubs).size(), + weight_t{0.0}, + weight_t{1.0}, + rng_state); + raft::copy(d_hubs.data(), + (*d_initial_random_hubs).data(), + (*d_initial_random_hubs).size(), + handle.get_stream()); + + handle.sync_stream(); // before rng_state goes out-of-scope } if (cugraph::test::g_perf) { @@ -227,14 +236,15 @@ class Tests_Hits : public ::testing::TestWithParam( + auto h_initial_random_hubs = cugraph::test::to_host(handle, *d_initial_random_hubs); + auto reference_result = hits_reference( offsets.data(), indices.data(), unrenumbered_graph_view.number_of_vertices(), unrenumbered_graph_view.compute_number_of_edges(handle), maximum_iterations, - (hits_usecase.check_initial_input) ? std::make_optional(initial_random_hubs.data()) - : std::nullopt, + (hits_usecase.check_initial_input) ? std::make_optional(h_initial_random_hubs.data()) + : std::nullopt, true, epsilon); diff --git a/cpp/tests/link_analysis/mg_hits_test.cpp b/cpp/tests/link_analysis/mg_hits_test.cpp index 31e495ae682..cc835e099c7 100644 --- a/cpp/tests/link_analysis/mg_hits_test.cpp +++ b/cpp/tests/link_analysis/mg_hits_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -89,16 +89,23 @@ class Tests_MGHits : public ::testing::TestWithParam d_mg_authorities( 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(), handle_->get_comms().get_rank()) - : std::vector(0); - + std::optional> d_mg_initial_random_hubs{std::nullopt}; if (hits_usecase.check_initial_input) { - raft::update_device(d_mg_hubs.data(), - initial_random_hubs.data(), - initial_random_hubs.size(), - handle_->get_stream()); + raft::random::RngState rng_state(handle_->get_comms().get_rank()); + d_mg_initial_random_hubs = + rmm::device_uvector(d_mg_hubs.size(), handle_->get_stream()); + cugraph::detail::uniform_random_fill(handle_->get_stream(), + (*d_mg_initial_random_hubs).data(), + (*d_mg_initial_random_hubs).size(), + weight_t{0.0}, + weight_t{1.0}, + rng_state); + raft::copy(d_mg_hubs.data(), + (*d_mg_initial_random_hubs).data(), + (*d_mg_initial_random_hubs).size(), + handle_->get_stream()); + + handle_->sync_stream(); // before rng_state goes out-of-scope } if (cugraph::test::g_perf) { @@ -153,13 +160,6 @@ class Tests_MGHits : public ::testing::TestWithParam d_mg_aggregate_initial_random_hubs(0, handle_->get_stream()); if (hits_usecase.check_initial_input) { - rmm::device_uvector d_mg_initial_random_hubs(initial_random_hubs.size(), - handle_->get_stream()); - raft::update_device(d_mg_initial_random_hubs.data(), - initial_random_hubs.data(), - initial_random_hubs.size(), - handle_->get_stream()); - std::tie(std::ignore, d_mg_aggregate_initial_random_hubs) = cugraph::test::mg_vertex_property_values_to_sg_vertex_property_values( *handle_, @@ -168,8 +168,8 @@ class Tests_MGHits : public ::testing::TestWithParam>{std::nullopt}, std::optional>{std::nullopt}, - raft::device_span(d_mg_initial_random_hubs.data(), - d_mg_initial_random_hubs.size())); + raft::device_span((*d_mg_initial_random_hubs).data(), + (*d_mg_initial_random_hubs).size())); } cugraph::graph_t sg_graph(*handle_); diff --git a/cpp/tests/link_analysis/mg_pagerank_test.cpp b/cpp/tests/link_analysis/mg_pagerank_test.cpp index c8392916872..58533769adf 100644 --- a/cpp/tests/link_analysis/mg_pagerank_test.cpp +++ b/cpp/tests/link_analysis/mg_pagerank_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -114,6 +114,8 @@ class Tests_MGPageRank result_t{0.0}, result_t{1.0}, rng_state); + + handle_->sync_stream(); // before rng_state goes out-of-scope } // 3. run MG PageRank diff --git a/cpp/tests/link_analysis/pagerank_test.cpp b/cpp/tests/link_analysis/pagerank_test.cpp index 40788be6a05..85ff62f893e 100644 --- a/cpp/tests/link_analysis/pagerank_test.cpp +++ b/cpp/tests/link_analysis/pagerank_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -202,6 +202,8 @@ class Tests_PageRank result_t{0.0}, result_t{1.0}, rng_state); + + handle.sync_stream(); // before rng_state goes out-of-scope } result_t constexpr alpha{0.85}; diff --git a/cpp/tests/link_prediction/mg_similarity_test.cpp b/cpp/tests/link_prediction/mg_similarity_test.cpp index a450c5ce2d5..3a71f8ee221 100644 --- a/cpp/tests/link_prediction/mg_similarity_test.cpp +++ b/cpp/tests/link_prediction/mg_similarity_test.cpp @@ -16,10 +16,10 @@ #include "link_prediction/similarity_compare.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -141,8 +141,11 @@ class Tests_MGSimilarity // 3. compare SG & MG results if (similarity_usecase.check_correctness) { - auto [src, dst, wgt] = - cugraph::test::graph_to_host_coo(*handle_, mg_graph_view, mg_edge_weight_view); + auto [src, dst, wgt] = cugraph::test::graph_to_host_coo( + *handle_, + mg_graph_view, + mg_edge_weight_view, + std::optional>(std::nullopt)); d_v1 = cugraph::test::device_gatherv(*handle_, d_v1.data(), d_v1.size()); d_v2 = cugraph::test::device_gatherv(*handle_, d_v2.data(), d_v2.size()); diff --git a/cpp/tests/link_prediction/mg_weighted_similarity_test.cpp b/cpp/tests/link_prediction/mg_weighted_similarity_test.cpp index 92dcb3b9096..3d891484818 100644 --- a/cpp/tests/link_prediction/mg_weighted_similarity_test.cpp +++ b/cpp/tests/link_prediction/mg_weighted_similarity_test.cpp @@ -16,10 +16,10 @@ #include "link_prediction/similarity_compare.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -143,8 +143,11 @@ class Tests_MGSimilarity // 3. compare SG & MG results if (similarity_usecase.check_correctness) { - auto [src, dst, wgt] = - cugraph::test::graph_to_host_coo(*handle_, mg_graph_view, mg_edge_weight_view); + auto [src, dst, wgt] = cugraph::test::graph_to_host_coo( + *handle_, + mg_graph_view, + mg_edge_weight_view, + std::optional>(std::nullopt)); d_v1 = cugraph::test::device_gatherv(*handle_, d_v1.data(), d_v1.size()); d_v2 = cugraph::test::device_gatherv(*handle_, d_v2.data(), d_v2.size()); diff --git a/cpp/tests/link_prediction/similarity_compare.cpp b/cpp/tests/link_prediction/similarity_compare.cpp index d2b1c4d203b..b5da85cd36f 100644 --- a/cpp/tests/link_prediction/similarity_compare.cpp +++ b/cpp/tests/link_prediction/similarity_compare.cpp @@ -16,7 +16,7 @@ #include "link_prediction/similarity_compare.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/check_utilities.hpp" #include #include diff --git a/cpp/tests/link_prediction/similarity_test.cpp b/cpp/tests/link_prediction/similarity_test.cpp deleted file mode 100644 index cd58d400627..00000000000 --- a/cpp/tests/link_prediction/similarity_test.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2022-2024, 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 governin_from_mtxg permissions and - * limitations under the License. - */ -#include "link_prediction/similarity_compare.hpp" -#include "utilities/base_fixture.hpp" -#include "utilities/device_comm_wrapper.hpp" -#include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" -#include "utilities/thrust_wrapper.hpp" - -#include -#include - -#include - -struct Similarity_Usecase { - bool use_weights{false}; - bool check_correctness{true}; - size_t max_seeds{std::numeric_limits::max()}; - size_t max_vertex_pairs_to_check{std::numeric_limits::max()}; -}; - -template -class Tests_Similarity - : public ::testing::TestWithParam> { - public: - Tests_Similarity() {} - - static void SetUpTestCase() {} - static void TearDownTestCase() {} - - virtual void SetUp() {} - virtual void TearDown() {} - - template - void run_current_test(std::tuple const& param, - test_functor_t const& test_functor) - { - constexpr bool renumber = true; - auto [similarity_usecase, input_usecase] = param; - - // 1. initialize handle - - raft::handle_t handle{}; - HighResTimer hr_timer{}; - - // 2. create SG graph - - if (cugraph::test::g_perf) { - RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - hr_timer.start("Construct graph"); - } - - auto [graph, edge_weights, d_renumber_map_labels] = - cugraph::test::construct_graph( - handle, input_usecase, similarity_usecase.use_weights, renumber); - - if (cugraph::test::g_perf) { - RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - hr_timer.stop(); - hr_timer.display_and_clear(std::cout); - } - - // 3. run similarity - - auto graph_view = graph.view(); - auto edge_weight_view = - edge_weights ? std::make_optional((*edge_weights).view()) : std::nullopt; - - if (cugraph::test::g_perf) { - RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - hr_timer.start("Similarity test"); - } - - // - // FIXME: Don't currently have an MG implementation of 2-hop neighbors. - // For now we'll do that on the CPU (really slowly, so keep max_seed - // small) - // - rmm::device_uvector d_v1(0, handle.get_stream()); - rmm::device_uvector d_v2(0, handle.get_stream()); - - { - auto [src, dst, wgt] = cugraph::test::graph_to_host_coo(handle, graph_view, edge_weight_view); - - size_t max_vertices = std::min(static_cast(graph_view.number_of_vertices()), - similarity_usecase.max_seeds); - std::vector h_v1; - std::vector h_v2; - std::vector one_hop_v1; - std::vector one_hop_v2; - - for (size_t seed = 0; seed < max_vertices; ++seed) { - std::for_each(thrust::make_zip_iterator(src.begin(), dst.begin()), - thrust::make_zip_iterator(src.end(), dst.end()), - [&one_hop_v1, &one_hop_v2, seed](auto t) { - auto u = thrust::get<0>(t); - auto v = thrust::get<1>(t); - if (u == seed) { - one_hop_v1.push_back(u); - one_hop_v2.push_back(v); - } - }); - } - - std::for_each(thrust::make_zip_iterator(one_hop_v1.begin(), one_hop_v2.begin()), - thrust::make_zip_iterator(one_hop_v1.end(), one_hop_v2.end()), - [&](auto t1) { - auto seed = thrust::get<0>(t1); - auto neighbor = thrust::get<1>(t1); - std::for_each(thrust::make_zip_iterator(src.begin(), dst.begin()), - thrust::make_zip_iterator(src.end(), dst.end()), - [&](auto t2) { - auto u = thrust::get<0>(t2); - auto v = thrust::get<1>(t2); - if (u == neighbor) { - h_v1.push_back(seed); - h_v2.push_back(v); - } - }); - }); - - std::sort(thrust::make_zip_iterator(h_v1.begin(), h_v2.begin()), - thrust::make_zip_iterator(h_v1.end(), h_v2.end())); - - auto end_iter = std::unique(thrust::make_zip_iterator(h_v1.begin(), h_v2.begin()), - thrust::make_zip_iterator(h_v1.end(), h_v2.end()), - [](auto t1, auto t2) { - return (thrust::get<0>(t1) == thrust::get<0>(t2)) && - (thrust::get<1>(t1) == thrust::get<1>(t2)); - }); - - h_v1.resize( - thrust::distance(thrust::make_zip_iterator(h_v1.begin(), h_v2.begin()), end_iter)); - h_v2.resize(h_v1.size()); - - d_v1.resize(h_v1.size(), handle.get_stream()); - d_v2.resize(h_v2.size(), handle.get_stream()); - - raft::update_device(d_v1.data(), h_v1.data(), h_v1.size(), handle.get_stream()); - raft::update_device(d_v2.data(), h_v2.data(), h_v2.size(), handle.get_stream()); - } - - // FIXME: Need to add some tests that specify actual vertex pairs - // FIXME: Need to a variation that calls call the two hop neighbors function - // FIXME: Debugging state as of EOD 9/28: - // 1) Tested case of no vertex pairs... works great :-) - // 2) Don't have a 2-hop on GPU yet. Perhaps write a 2-hop on CPU - // for now? We could then use that for testing the 2-hop function - // later. - std::tuple, raft::device_span> vertex_pairs{ - {d_v1.data(), d_v1.size()}, {d_v2.data(), d_v2.size()}}; - - auto result_score = test_functor.run( - handle, graph_view, edge_weight_view, vertex_pairs, similarity_usecase.use_weights); - - if (cugraph::test::g_perf) { - RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement - hr_timer.stop(); - hr_timer.display_and_clear(std::cout); - } - - if (similarity_usecase.check_correctness) { - auto [src, dst, wgt] = cugraph::test::graph_to_host_coo(handle, graph_view, edge_weight_view); - - size_t check_size = std::min(d_v1.size(), similarity_usecase.max_vertex_pairs_to_check); - - // - // FIXME: Need to reorder here. thrust::shuffle on the tuples (vertex_pairs_1, - // vertex_pairs_2, result_score) would - // be sufficient. - // - std::vector h_vertex_pair_1(check_size); - std::vector h_vertex_pair_2(check_size); - std::vector h_result_score(check_size); - - raft::update_host( - h_vertex_pair_1.data(), std::get<0>(vertex_pairs).data(), check_size, handle.get_stream()); - raft::update_host( - h_vertex_pair_2.data(), std::get<1>(vertex_pairs).data(), check_size, handle.get_stream()); - raft::update_host( - h_result_score.data(), result_score.data(), check_size, handle.get_stream()); - - similarity_compare(graph_view.number_of_vertices(), - std::tie(src, dst, wgt), - std::tie(h_vertex_pair_1, h_vertex_pair_2), - h_result_score, - test_functor); - } - } -}; - -using Tests_Similarity_File = Tests_Similarity; -using Tests_Similarity_Rmat = Tests_Similarity; - -TEST_P(Tests_Similarity_File, CheckInt32Int32FloatJaccard) -{ - run_current_test( - override_File_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_jaccard_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt32Int32FloatJaccard) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_jaccard_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt32Int64FloatJaccard) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_jaccard_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt64Int64FloatJaccard) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_jaccard_t{}); -} - -TEST_P(Tests_Similarity_File, CheckInt32Int32FloatSorensen) -{ - run_current_test( - override_File_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_sorensen_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt32Int32FloatSorensen) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_sorensen_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt32Int64FloatSorensen) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_sorensen_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt64Int64FloatSorensen) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_sorensen_t{}); -} - -TEST_P(Tests_Similarity_File, CheckInt32Int32FloatOverlap) -{ - run_current_test( - override_File_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_overlap_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt32Int32FloatOverlap) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_overlap_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt32Int64FloatOverlap) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_overlap_t{}); -} - -TEST_P(Tests_Similarity_Rmat, CheckInt64Int64FloatOverlap) -{ - run_current_test( - override_Rmat_Usecase_with_cmd_line_arguments(GetParam()), cugraph::test::test_overlap_t{}); -} - -INSTANTIATE_TEST_SUITE_P( - file_test, - Tests_Similarity_File, - ::testing::Combine( - // enable correctness checks - // Disable weighted computation testing in 22.10 - //::testing::Values(Similarity_Usecase{true, true, 20, 100}, Similarity_Usecase{false, true, 20, - // 100}), - ::testing::Values(Similarity_Usecase{false, true, 20, 100}), - ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"), - cugraph::test::File_Usecase("test/datasets/dolphins.mtx")))); - -INSTANTIATE_TEST_SUITE_P( - rmat_small_test, - Tests_Similarity_Rmat, - ::testing::Combine( - // enable correctness checks - // Disable weighted computation testing in 22.10 - //::testing::Values(Similarity_Usecase{true, true, 20, 100}, Similarity_Usecase{false, true, 20, - // 100}), - ::testing::Values(Similarity_Usecase{false, true, 20, 100}), - ::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, true, false)))); - -INSTANTIATE_TEST_SUITE_P( - file_benchmark_test, /* note that the test filename can be overridden in benchmarking (with - --gtest_filter to select only the file_benchmark_test with a specific - 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_Similarity_File, - ::testing::Combine( - // disable correctness checks - // Disable weighted computation testing in 22.10 - //::testing::Values(Similarity_Usecase{false, false}, Similarity_Usecase{true, false}), - ::testing::Values(Similarity_Usecase{false, false}), - ::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx")))); - -INSTANTIATE_TEST_SUITE_P( - rmat_benchmark_test, /* note that scale & edge factor can be overridden in benchmarking (with - --gtest_filter to select only the rmat_benchmark_test with a specific - 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_Similarity_Rmat, - ::testing::Combine( - // disable correctness checks for large graphs - //::testing::Values(Similarity_Usecase{false, false}, Similarity_Usecase{true, false}), - ::testing::Values(Similarity_Usecase{false, false}), - ::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, true, false)))); - -CUGRAPH_TEST_PROGRAM_MAIN() diff --git a/cpp/tests/link_prediction/similarity_test.cu b/cpp/tests/link_prediction/similarity_test.cu index f5c15c760e2..feeea257597 100644 --- a/cpp/tests/link_prediction/similarity_test.cu +++ b/cpp/tests/link_prediction/similarity_test.cu @@ -13,18 +13,19 @@ * See the License for the specific language governin_from_mtxg permissions and * limitations under the License. */ +#include "link_prediction/similarity_compare.hpp" +#include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" +#include "utilities/device_comm_wrapper.hpp" +#include "utilities/test_graphs.hpp" +#include "utilities/thrust_wrapper.hpp" + #include #include #include #include #include -#include -#include -#include -#include -#include -#include struct Similarity_Usecase { bool use_weights{false}; @@ -166,7 +167,11 @@ class Tests_Similarity } if (similarity_usecase.check_correctness) { - auto [src, dst, wgt] = cugraph::test::graph_to_host_coo(handle, graph_view, edge_weight_view); + auto [src, dst, wgt] = cugraph::test::graph_to_host_coo( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); size_t check_size = similarity_usecase.max_vertex_pairs_to_check ? std::min(v1.size(), *similarity_usecase.max_vertex_pairs_to_check) diff --git a/cpp/tests/link_prediction/weighted_similarity_test.cpp b/cpp/tests/link_prediction/weighted_similarity_test.cpp index 694b0fa625c..570369a0236 100644 --- a/cpp/tests/link_prediction/weighted_similarity_test.cpp +++ b/cpp/tests/link_prediction/weighted_similarity_test.cpp @@ -15,9 +15,9 @@ */ #include "link_prediction/similarity_compare.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -93,7 +93,11 @@ class Tests_Similarity rmm::device_uvector d_v2(0, handle.get_stream()); { - auto [src, dst, wgt] = cugraph::test::graph_to_host_coo(handle, graph_view, edge_weight_view); + auto [src, dst, wgt] = cugraph::test::graph_to_host_coo( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); size_t max_vertices = std::min(static_cast(graph_view.number_of_vertices()), similarity_usecase.max_seeds); @@ -173,7 +177,11 @@ class Tests_Similarity } if (similarity_usecase.check_correctness) { - auto [src, dst, wgt] = cugraph::test::graph_to_host_coo(handle, graph_view, edge_weight_view); + auto [src, dst, wgt] = cugraph::test::graph_to_host_coo( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); size_t check_size = std::min(d_v1.size(), similarity_usecase.max_vertex_pairs_to_check); diff --git a/cpp/tests/prims/mg_count_if_e.cu b/cpp/tests/prims/mg_count_if_e.cu index c3a1f08475f..8ad1a20e585 100644 --- a/cpp/tests/prims/mg_count_if_e.cu +++ b/cpp/tests/prims/mg_count_if_e.cu @@ -16,12 +16,12 @@ #include "prims/count_if_e.cuh" #include "prims/update_edge_src_dst_property.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -105,8 +105,8 @@ class Tests_MGCountIfE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -114,11 +114,12 @@ class Tests_MGCountIfE const int hash_bin_count = 5; - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); if (cugraph::test::g_perf) { @@ -159,14 +160,15 @@ class Tests_MGCountIfE if (handle_->get_comms().get_rank() == 0) { auto sg_graph_view = sg_graph.view(); - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - 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); - auto sg_src_prop = cugraph::test::generate::src_property( + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + 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); + auto sg_src_prop = cugraph::test::generate::src_property( *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( + auto sg_dst_prop = cugraph::test::generate::dst_property( *handle_, sg_graph_view, sg_vertex_prop); auto expected_result = count_if_e( diff --git a/cpp/tests/prims/mg_count_if_v.cu b/cpp/tests/prims/mg_count_if_v.cu index e4e6c9051f3..eb0e8cf9835 100644 --- a/cpp/tests/prims/mg_count_if_v.cu +++ b/cpp/tests/prims/mg_count_if_v.cu @@ -16,10 +16,10 @@ #include "prims/count_if_v.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/prims/mg_extract_transform_e.cu b/cpp/tests/prims/mg_extract_transform_e.cu index ef50a6e025b..48b893f6fea 100644 --- a/cpp/tests/prims/mg_extract_transform_e.cu +++ b/cpp/tests/prims/mg_extract_transform_e.cu @@ -18,12 +18,12 @@ #include "prims/extract_transform_e.cuh" #include "prims/update_edge_src_dst_property.cuh" #include "prims/vertex_frontier.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -183,8 +183,8 @@ class Tests_MGExtractTransformE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -192,11 +192,12 @@ class Tests_MGExtractTransformE const int hash_bin_count = 5; - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *d_mg_renumber_map_labels, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *d_mg_renumber_map_labels, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); if (cugraph::test::g_perf) { @@ -278,9 +279,9 @@ class Tests_MGExtractTransformE auto sg_graph_view = sg_graph.view(); - auto sg_src_prop = cugraph::test::generate::src_property( + auto sg_src_prop = cugraph::test::generate::src_property( *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( + auto sg_dst_prop = cugraph::test::generate::dst_property( *handle_, sg_graph_view, sg_vertex_prop); auto sg_extract_transform_output_buffer = diff --git a/cpp/tests/prims/mg_extract_transform_v_frontier_outgoing_e.cu b/cpp/tests/prims/mg_extract_transform_v_frontier_outgoing_e.cu index 1b90619bbc9..3611a250afd 100644 --- a/cpp/tests/prims/mg_extract_transform_v_frontier_outgoing_e.cu +++ b/cpp/tests/prims/mg_extract_transform_v_frontier_outgoing_e.cu @@ -17,12 +17,12 @@ #include "prims/extract_transform_v_frontier_outgoing_e.cuh" #include "prims/update_edge_src_dst_property.cuh" #include "prims/vertex_frontier.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -183,8 +183,8 @@ class Tests_MGExtractTransformVFrontierOutgoingE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -192,11 +192,12 @@ class Tests_MGExtractTransformVFrontierOutgoingE const int hash_bin_count = 5; - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *d_mg_renumber_map_labels, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *d_mg_renumber_map_labels, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); auto mg_key_buffer = cugraph::allocate_dataframe_buffer( @@ -308,9 +309,9 @@ class Tests_MGExtractTransformVFrontierOutgoingE auto sg_graph_view = sg_graph.view(); - auto sg_src_prop = cugraph::test::generate::src_property( + auto sg_src_prop = cugraph::test::generate::src_property( *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( + auto sg_dst_prop = cugraph::test::generate::dst_property( *handle_, sg_graph_view, sg_vertex_prop); auto sg_key_buffer = cugraph::allocate_dataframe_buffer( diff --git a/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_intersection.cu b/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_intersection.cu index 0a519e30b9c..762da62eeb8 100644 --- a/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_intersection.cu +++ b/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_intersection.cu @@ -17,12 +17,12 @@ #include "prims/per_v_pair_transform_dst_nbr_intersection.cuh" #include "prims/transform_e.cuh" #include "prims/update_edge_src_dst_property.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include @@ -117,8 +117,8 @@ class Tests_MGPerVPairTransformDstNbrIntersection std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } diff --git a/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_weighted_intersection.cu b/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_weighted_intersection.cu index 84186908b1d..de78b42603d 100644 --- a/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_weighted_intersection.cu +++ b/cpp/tests/prims/mg_per_v_pair_transform_dst_nbr_weighted_intersection.cu @@ -15,12 +15,12 @@ */ #include "prims/per_v_pair_transform_dst_nbr_intersection.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -141,8 +141,8 @@ class Tests_MGPerVPairTransformDstNbrIntersection std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } diff --git a/cpp/tests/prims/mg_per_v_random_select_transform_outgoing_e.cu b/cpp/tests/prims/mg_per_v_random_select_transform_outgoing_e.cu index 9c6e46f22dc..2ea8635fe36 100644 --- a/cpp/tests/prims/mg_per_v_random_select_transform_outgoing_e.cu +++ b/cpp/tests/prims/mg_per_v_random_select_transform_outgoing_e.cu @@ -16,12 +16,13 @@ #include "prims/per_v_random_select_transform_outgoing_e.cuh" #include "prims/vertex_frontier.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_kernels.cuh" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -128,8 +129,8 @@ class Tests_MGPerVRandomSelectTransformOutgoingE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -137,11 +138,12 @@ class Tests_MGPerVRandomSelectTransformOutgoingE const int hash_bin_count = 5; - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); raft::random::RngState rng_state(static_cast(handle_->get_comms().get_rank())); diff --git a/cpp/tests/prims/mg_per_v_transform_reduce_dst_key_aggregated_outgoing_e.cu b/cpp/tests/prims/mg_per_v_transform_reduce_dst_key_aggregated_outgoing_e.cu index 89d3205d051..efcfee9fc66 100644 --- a/cpp/tests/prims/mg_per_v_transform_reduce_dst_key_aggregated_outgoing_e.cu +++ b/cpp/tests/prims/mg_per_v_transform_reduce_dst_key_aggregated_outgoing_e.cu @@ -17,13 +17,13 @@ #include "prims/per_v_transform_reduce_dst_key_aggregated_outgoing_e.cuh" #include "prims/reduce_op.cuh" #include "prims/update_edge_src_dst_property.cuh" -#include "property_generator.cuh" #include "result_compare.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -125,8 +125,8 @@ class Tests_MGPerVTransformReduceDstKeyAggregatedOutgoingE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -138,16 +138,18 @@ class Tests_MGPerVTransformReduceDstKeyAggregatedOutgoingE const int initial_value = 4; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); + cugraph::test::generate::initial_value(initial_value); - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, vertex_prop_hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, vertex_prop_hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_vertex_key = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, key_hash_bin_count); - auto mg_dst_key = cugraph::test::generate::dst_property( + auto mg_vertex_key = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, key_hash_bin_count); + auto mg_dst_key = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_key); rmm::device_uvector mg_kv_store_keys(comm_rank == 0 ? key_hash_bin_count : int{0}, @@ -156,8 +158,9 @@ class Tests_MGPerVTransformReduceDstKeyAggregatedOutgoingE handle_->get_thrust_policy(), mg_kv_store_keys.begin(), mg_kv_store_keys.end(), vertex_t{0}); mg_kv_store_keys = cugraph::detail::shuffle_ext_vertices_to_local_gpu_by_vertex_partitioning( *handle_, std::move(mg_kv_store_keys)); - auto mg_kv_store_values = cugraph::test::generate::vertex_property( - *handle_, mg_kv_store_keys, key_prop_hash_bin_count); + auto mg_kv_store_values = + cugraph::test::generate::vertex_property( + *handle_, mg_kv_store_keys, key_prop_hash_bin_count); static_assert(std::is_same_v || std::is_same_v>); @@ -346,29 +349,34 @@ class Tests_MGPerVTransformReduceDstKeyAggregatedOutgoingE auto sg_edge_weight_view = sg_edge_weights ? std::make_optional((*sg_edge_weights).view()) : std::nullopt; - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), - thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), - vertex_prop_hash_bin_count); - auto sg_src_prop = cugraph::test::generate::src_property( - *handle_, sg_graph_view, sg_vertex_prop); - - auto sg_vertex_key = cugraph::test::generate::vertex_property( - *handle_, - thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), - thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), - key_hash_bin_count); - auto sg_dst_key = cugraph::test::generate::dst_property( - *handle_, sg_graph_view, sg_vertex_key); + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), + thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), + vertex_prop_hash_bin_count); + auto sg_src_prop = + cugraph::test::generate::src_property( + *handle_, sg_graph_view, sg_vertex_prop); + + auto sg_vertex_key = + cugraph::test::generate::vertex_property( + *handle_, + thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_first()), + thrust::make_counting_iterator(sg_graph_view.local_vertex_partition_range_last()), + key_hash_bin_count); + auto sg_dst_key = + cugraph::test::generate::dst_property( + *handle_, sg_graph_view, sg_vertex_key); rmm::device_uvector sg_kv_store_keys(key_hash_bin_count, handle_->get_stream()); thrust::sequence(handle_->get_thrust_policy(), sg_kv_store_keys.begin(), sg_kv_store_keys.end(), vertex_t{0}); - auto sg_kv_store_values = cugraph::test::generate::vertex_property( - *handle_, sg_kv_store_keys, key_prop_hash_bin_count); + auto sg_kv_store_values = + cugraph::test::generate::vertex_property( + *handle_, sg_kv_store_keys, key_prop_hash_bin_count); cugraph::kv_store_t sg_kv_store( sg_kv_store_keys.begin(), 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 a459a677569..e3eb56d5a6e 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,13 +17,13 @@ #include "prims/per_v_transform_reduce_incoming_outgoing_e.cuh" #include "prims/reduce_op.cuh" #include "prims/update_edge_src_dst_property.cuh" -#include "property_generator.cuh" #include "result_compare.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -127,8 +127,8 @@ class Tests_MGPerVTransformReduceIncomingOutgoingE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -138,13 +138,14 @@ class Tests_MGPerVTransformReduceIncomingOutgoingE const int initial_value = 4; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); + cugraph::test::generate::initial_value(initial_value); - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); enum class reduction_type_t { PLUS, ELEMWISE_MIN, ELEMWISE_MAX }; @@ -355,15 +356,18 @@ class Tests_MGPerVTransformReduceIncomingOutgoingE if (handle_->get_comms().get_rank() == int{0}) { auto sg_graph_view = sg_graph.view(); - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - 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); - auto sg_src_prop = cugraph::test::generate::src_property( - *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( - *handle_, sg_graph_view, sg_vertex_prop); + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + 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); + auto sg_src_prop = + cugraph::test::generate::src_property( + *handle_, sg_graph_view, sg_vertex_prop); + auto sg_dst_prop = + cugraph::test::generate::dst_property( + *handle_, sg_graph_view, sg_vertex_prop); cugraph::test::vector_result_compare compare{*handle_}; auto global_in_result = cugraph::allocate_dataframe_buffer( diff --git a/cpp/tests/prims/mg_reduce_v.cu b/cpp/tests/prims/mg_reduce_v.cu index 783e17b6d8f..1449e8f9910 100644 --- a/cpp/tests/prims/mg_reduce_v.cu +++ b/cpp/tests/prims/mg_reduce_v.cu @@ -16,13 +16,13 @@ #include "prims/property_op_utils.cuh" #include "prims/reduce_v.cuh" -#include "property_generator.cuh" #include "result_compare.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -106,10 +106,11 @@ class Tests_MGReduceV const int initial_value = 10; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); + cugraph::test::generate::initial_value(initial_value); - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, (*mg_renumber_map), hash_bin_count); + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, (*mg_renumber_map), hash_bin_count); auto property_iter = cugraph::get_dataframe_buffer_begin(mg_vertex_prop); enum class reduction_type_t { PLUS, MINIMUM, MAXIMUM }; @@ -173,11 +174,12 @@ class Tests_MGReduceV if (handle_->get_comms().get_rank() == 0) { auto sg_graph_view = sg_graph.view(); - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - 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); + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + 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); auto sg_property_iter = cugraph::get_dataframe_buffer_begin(sg_vertex_prop); for (auto reduction_type : reduction_types) { diff --git a/cpp/tests/prims/mg_transform_e.cu b/cpp/tests/prims/mg_transform_e.cu index c569636f0e1..92046bdd8f8 100644 --- a/cpp/tests/prims/mg_transform_e.cu +++ b/cpp/tests/prims/mg_transform_e.cu @@ -18,12 +18,11 @@ #include "prims/edge_bucket.cuh" #include "prims/fill_edge_property.cuh" #include "prims/transform_e.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -103,8 +102,8 @@ class Tests_MGTransformE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -114,12 +113,13 @@ class Tests_MGTransformE const int initial_value = 4; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + cugraph::test::generate::initial_value(initial_value); + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); cugraph::edge_bucket_t edge_list( diff --git a/cpp/tests/prims/mg_transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v.cu b/cpp/tests/prims/mg_transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v.cu index 5fa37250e21..71cdf27fda1 100644 --- a/cpp/tests/prims/mg_transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v.cu +++ b/cpp/tests/prims/mg_transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v.cu @@ -14,7 +14,15 @@ * limitations under the License. */ -#include "property_generator.cuh" +#include "prims/transform_e.cuh" +#include "prims/transform_reduce_dst_nbr_intersection_of_e_endpoints_by_v.cuh" +#include "prims/update_edge_src_dst_property.cuh" +#include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" +#include "utilities/device_comm_wrapper.hpp" +#include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" +#include "utilities/test_graphs.hpp" #include #include @@ -37,14 +45,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include @@ -114,8 +114,8 @@ class Tests_MGTransformReduceDstNbrIntersectionOfEEndpointsByV std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -125,13 +125,13 @@ class Tests_MGTransformReduceDstNbrIntersectionOfEEndpointsByV const int initial_value = 4; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); + cugraph::test::generate::initial_value(initial_value); - auto mg_vertex_prop = cugraph::test::generate::vertex_property( + auto mg_vertex_prop = cugraph::test::generate::vertex_property( *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); auto mg_result_buffer = rmm::device_uvector( @@ -185,14 +185,15 @@ class Tests_MGTransformReduceDstNbrIntersectionOfEEndpointsByV if (handle_->get_comms().get_rank() == 0) { auto sg_graph_view = sg_graph.view(); - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - 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); - auto sg_src_prop = cugraph::test::generate::src_property( + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + 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); + auto sg_src_prop = cugraph::test::generate::src_property( *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( + auto sg_dst_prop = cugraph::test::generate::dst_property( *handle_, sg_graph_view, sg_vertex_prop); auto sg_result_buffer = cugraph::allocate_dataframe_buffer( diff --git a/cpp/tests/prims/mg_transform_reduce_e.cu b/cpp/tests/prims/mg_transform_reduce_e.cu index 53f37e83b30..a086571d6e0 100644 --- a/cpp/tests/prims/mg_transform_reduce_e.cu +++ b/cpp/tests/prims/mg_transform_reduce_e.cu @@ -16,13 +16,13 @@ #include "prims/transform_reduce_e.cuh" #include "prims/update_edge_src_dst_property.cuh" -#include "property_generator.cuh" #include "result_compare.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -107,8 +107,8 @@ class Tests_MGTransformReduceE std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -118,12 +118,13 @@ class Tests_MGTransformReduceE const int initial_value = 4; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + cugraph::test::generate::initial_value(initial_value); + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); if (cugraph::test::g_perf) { @@ -169,14 +170,15 @@ class Tests_MGTransformReduceE if (handle_->get_comms().get_rank() == 0) { auto sg_graph_view = sg_graph.view(); - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - 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); - auto sg_src_prop = cugraph::test::generate::src_property( + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + 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); + auto sg_src_prop = cugraph::test::generate::src_property( *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( + auto sg_dst_prop = cugraph::test::generate::dst_property( *handle_, sg_graph_view, sg_vertex_prop); auto expected_result = transform_reduce_e( diff --git a/cpp/tests/prims/mg_transform_reduce_e_by_src_dst_key.cu b/cpp/tests/prims/mg_transform_reduce_e_by_src_dst_key.cu index 457e6b5ab93..a66c70ff586 100644 --- a/cpp/tests/prims/mg_transform_reduce_e_by_src_dst_key.cu +++ b/cpp/tests/prims/mg_transform_reduce_e_by_src_dst_key.cu @@ -14,8 +14,17 @@ * limitations under the License. */ -#include "property_generator.cuh" +#include "prims/reduce_op.cuh" +#include "prims/transform_reduce_e_by_src_dst_key.cuh" +#include "prims/update_edge_src_dst_property.cuh" #include "result_compare.cuh" +#include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" +#include "utilities/device_comm_wrapper.hpp" +#include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" +#include "utilities/test_graphs.hpp" +#include "utilities/thrust_wrapper.hpp" #include #include @@ -42,15 +51,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include @@ -108,8 +108,8 @@ class Tests_MGTransformReduceEBySrcDstKey std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -119,20 +119,22 @@ class Tests_MGTransformReduceEBySrcDstKey const int initial_value = 4; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); + cugraph::test::generate::initial_value(initial_value); - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_vertex_key = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_key = cugraph::test::generate::src_property( + auto mg_vertex_key = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_key = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_key); - auto mg_dst_key = cugraph::test::generate::dst_property( + auto mg_dst_key = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_key); if (cugraph::test::g_perf) { @@ -246,24 +248,26 @@ class Tests_MGTransformReduceEBySrcDstKey if (handle_->get_comms().get_rank() == 0) { auto sg_graph_view = sg_graph.view(); - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - 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); - auto sg_src_prop = cugraph::test::generate::src_property( + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + 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); + auto sg_src_prop = cugraph::test::generate::src_property( *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( + auto sg_dst_prop = cugraph::test::generate::dst_property( *handle_, sg_graph_view, sg_vertex_prop); - auto sg_vertex_key = cugraph::test::generate::vertex_property( - *handle_, - 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); - auto sg_src_key = cugraph::test::generate::src_property( + auto sg_vertex_key = + cugraph::test::generate::vertex_property( + *handle_, + 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); + auto sg_src_key = cugraph::test::generate::src_property( *handle_, sg_graph_view, sg_vertex_key); - auto sg_dst_key = cugraph::test::generate::dst_property( + auto sg_dst_key = cugraph::test::generate::dst_property( *handle_, sg_graph_view, sg_vertex_key); auto [sg_by_src_keys, sg_by_src_values] = transform_reduce_e_by_src_key( diff --git a/cpp/tests/prims/mg_transform_reduce_v.cu b/cpp/tests/prims/mg_transform_reduce_v.cu index c954f31d0f9..c26085a55c4 100644 --- a/cpp/tests/prims/mg_transform_reduce_v.cu +++ b/cpp/tests/prims/mg_transform_reduce_v.cu @@ -15,13 +15,14 @@ */ #include "prims/transform_reduce_v.cuh" -#include "property_generator.cuh" #include "result_compare.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_kernels.cuh" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -114,7 +115,7 @@ class Tests_MGTransformReduceV v_op_t v_op{hash_bin_count}; auto property_initial_value = - cugraph::test::generate::initial_value(initial_value); + cugraph::test::generate::initial_value(initial_value); enum class reduction_type_t { PLUS, MINIMUM, MAXIMUM }; std::array reduction_types = { reduction_type_t::PLUS, reduction_type_t::MINIMUM, reduction_type_t::MAXIMUM}; 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 99161df2cb4..07a0f7e7aab 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,12 +17,12 @@ #include "prims/transform_reduce_v_frontier_outgoing_e_by_dst.cuh" #include "prims/update_edge_src_dst_property.cuh" #include "prims/vertex_frontier.cuh" -#include "property_generator.cuh" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" +#include "utilities/property_generator_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -155,8 +155,8 @@ class Tests_MGTransformReduceVFrontierOutgoingEByDst std::optional> edge_mask{std::nullopt}; if (prims_usecase.edge_masking) { - edge_mask = - cugraph::test::generate::edge_property(*handle_, mg_graph_view, 2); + edge_mask = cugraph::test::generate::edge_property( + *handle_, mg_graph_view, 2); mg_graph_view.attach_edge_mask((*edge_mask).view()); } @@ -164,11 +164,12 @@ class Tests_MGTransformReduceVFrontierOutgoingEByDst const int hash_bin_count = 5; - auto mg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, *mg_renumber_map, hash_bin_count); - auto mg_src_prop = cugraph::test::generate::src_property( + auto mg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, *mg_renumber_map, hash_bin_count); + auto mg_src_prop = cugraph::test::generate::src_property( *handle_, mg_graph_view, mg_vertex_prop); - auto mg_dst_prop = cugraph::test::generate::dst_property( + auto mg_dst_prop = cugraph::test::generate::dst_property( *handle_, mg_graph_view, mg_vertex_prop); auto mg_key_buffer = cugraph::allocate_dataframe_buffer( @@ -314,15 +315,18 @@ class Tests_MGTransformReduceVFrontierOutgoingEByDst auto sg_graph_view = sg_graph.view(); - auto sg_vertex_prop = cugraph::test::generate::vertex_property( - *handle_, - 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); - auto sg_src_prop = cugraph::test::generate::src_property( - *handle_, sg_graph_view, sg_vertex_prop); - auto sg_dst_prop = cugraph::test::generate::dst_property( - *handle_, sg_graph_view, sg_vertex_prop); + auto sg_vertex_prop = + cugraph::test::generate::vertex_property( + *handle_, + 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); + auto sg_src_prop = + cugraph::test::generate::src_property( + *handle_, sg_graph_view, sg_vertex_prop); + auto sg_dst_prop = + cugraph::test::generate::dst_property( + *handle_, sg_graph_view, sg_vertex_prop); auto sg_key_buffer = cugraph::allocate_dataframe_buffer( sg_graph_view.local_vertex_partition_range_size(), handle_->get_stream()); diff --git a/cpp/tests/prims/property_generator.cuh b/cpp/tests/prims/property_generator.cuh deleted file mode 100644 index 0ac1f84c79b..00000000000 --- a/cpp/tests/prims/property_generator.cuh +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2021-2024, 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 "prims/transform_e.cuh" -#include "prims/update_edge_src_dst_property.cuh" - -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -namespace cugraph { -namespace test { - -namespace detail { - -template -__host__ __device__ auto make_type_casted_tuple_from_scalar(T val, std::index_sequence) -{ - return thrust::make_tuple( - static_cast::type>(val)...); -} - -template -__host__ __device__ auto make_property_value(T val) -{ - property_t ret{}; - if constexpr (cugraph::is_thrust_tuple_of_arithmetic::value) { - ret = make_type_casted_tuple_from_scalar( - val, std::make_index_sequence::value>{}); - } else { - ret = static_cast(val); - } - return ret; -} - -template -struct vertex_property_transform { - int32_t mod{}; - - constexpr __device__ property_t operator()(vertex_t v) const - { - static_assert(cugraph::is_thrust_tuple_of_arithmetic::value || - std::is_arithmetic_v); - cuco::detail::MurmurHash3_32 hash_func{}; - return make_property_value(hash_func(v) % mod); - } -}; - -template -struct edge_property_transform { - int32_t mod{}; - - constexpr __device__ property_t operator()( - vertex_t src, vertex_t dst, thrust::nullopt_t, thrust::nullopt_t, thrust::nullopt_t) const - { - static_assert(cugraph::is_thrust_tuple_of_arithmetic::value || - std::is_arithmetic_v); - cuco::detail::MurmurHash3_32 hash_func{}; - return make_property_value(hash_func(src + dst) % mod); - } -}; - -} // namespace detail - -template -struct generate { - private: - using property_buffer_type = - decltype(allocate_dataframe_buffer(size_t{0}, rmm::cuda_stream_view{})); - - public: - static property_t initial_value(int32_t init) - { - return detail::make_property_value(init); - } - - static auto vertex_property(raft::handle_t const& handle, - rmm::device_uvector const& labels, - int32_t hash_bin_count) - { - auto data = cugraph::allocate_dataframe_buffer(labels.size(), handle.get_stream()); - thrust::transform(handle.get_thrust_policy(), - labels.begin(), - labels.end(), - cugraph::get_dataframe_buffer_begin(data), - detail::vertex_property_transform{hash_bin_count}); - return data; - } - - static auto vertex_property(raft::handle_t const& handle, - thrust::counting_iterator begin, - thrust::counting_iterator end, - int32_t hash_bin_count) - { - auto length = thrust::distance(begin, end); - auto data = cugraph::allocate_dataframe_buffer(length, handle.get_stream()); - thrust::transform(handle.get_thrust_policy(), - begin, - end, - cugraph::get_dataframe_buffer_begin(data), - detail::vertex_property_transform{hash_bin_count}); - return data; - } - - template - static auto src_property(raft::handle_t const& handle, - graph_view_type const& graph_view, - property_buffer_type const& property) - { - auto output_property = - cugraph::edge_src_property_t(handle, graph_view); - update_edge_src_property( - handle, graph_view, cugraph::get_dataframe_buffer_begin(property), output_property); - return output_property; - } - - template - static auto dst_property(raft::handle_t const& handle, - graph_view_type const& graph_view, - property_buffer_type const& property) - { - auto output_property = - cugraph::edge_dst_property_t(handle, graph_view); - update_edge_dst_property( - handle, graph_view, cugraph::get_dataframe_buffer_begin(property), output_property); - return output_property; - } - - template - static auto edge_property(raft::handle_t const& handle, - graph_view_type const& graph_view, - int32_t hash_bin_count) - { - auto output_property = cugraph::edge_property_t(handle, graph_view); - cugraph::transform_e(handle, - graph_view, - cugraph::edge_src_dummy_property_t{}.view(), - cugraph::edge_dst_dummy_property_t{}.view(), - cugraph::edge_dummy_property_t{}.view(), - detail::edge_property_transform{hash_bin_count}, - output_property.mutable_view()); - return output_property; - } -}; - -} // namespace test -} // namespace cugraph diff --git a/cpp/tests/sampling/detail/nbr_sampling_utils.cuh b/cpp/tests/sampling/detail/nbr_sampling_utils.cuh index b248723403a..be93990eb9c 100644 --- a/cpp/tests/sampling/detail/nbr_sampling_utils.cuh +++ b/cpp/tests/sampling/detail/nbr_sampling_utils.cuh @@ -21,7 +21,6 @@ #include "utilities/base_fixture.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/sampling/mg_random_walks_test.cpp b/cpp/tests/sampling/mg_random_walks_test.cpp index 046fab141ea..dbafa9ac1f2 100644 --- a/cpp/tests/sampling/mg_random_walks_test.cpp +++ b/cpp/tests/sampling/mg_random_walks_test.cpp @@ -18,7 +18,6 @@ #include "utilities/base_fixture.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/sampling/sg_random_walks_test.cpp b/cpp/tests/sampling/sg_random_walks_test.cpp index b40ac2d66af..6b0ce32fdfe 100644 --- a/cpp/tests/sampling/sg_random_walks_test.cpp +++ b/cpp/tests/sampling/sg_random_walks_test.cpp @@ -17,7 +17,6 @@ #include "sampling/random_walks_check.hpp" #include "utilities/base_fixture.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/coarsen_graph_test.cpp b/cpp/tests/structure/coarsen_graph_test.cpp index e4969334d5a..7c0e22ff24a 100644 --- a/cpp/tests/structure/coarsen_graph_test.cpp +++ b/cpp/tests/structure/coarsen_graph_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include 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 202dcecbc59..0055ee1315e 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 @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/degree_test.cpp b/cpp/tests/structure/degree_test.cpp index 29bb9df50d5..2a899c49f5e 100644 --- a/cpp/tests/structure/degree_test.cpp +++ b/cpp/tests/structure/degree_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/structure/has_edge_and_compute_multiplicity_test.cpp b/cpp/tests/structure/has_edge_and_compute_multiplicity_test.cpp index 7138cee9579..322d7915504 100644 --- a/cpp/tests/structure/has_edge_and_compute_multiplicity_test.cpp +++ b/cpp/tests/structure/has_edge_and_compute_multiplicity_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/induced_subgraph_test.cpp b/cpp/tests/structure/induced_subgraph_test.cpp index 31b1cd055a3..d8f55b65bda 100644 --- a/cpp/tests/structure/induced_subgraph_test.cpp +++ b/cpp/tests/structure/induced_subgraph_test.cpp @@ -15,6 +15,7 @@ */ #include "structure/induced_subgraph_validate.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" #include @@ -190,8 +191,11 @@ class Tests_InducedSubgraph if (induced_subgraph_usecase.check_correctness) { auto h_subgraph_vertices = cugraph::test::to_host(handle, d_subgraph_vertices); - auto [h_offsets, h_indices, h_weights] = - cugraph::test::graph_to_host_csr(handle, graph_view, edge_weight_view); + auto [h_offsets, h_indices, h_weights] = cugraph::test::graph_to_host_csr( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); auto [h_reference_subgraph_edgelist_majors, h_reference_subgraph_edgelist_minors, 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 0fe76d93068..45fac884f49 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 @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/mg_has_edge_and_compute_multiplicity_test.cpp b/cpp/tests/structure/mg_has_edge_and_compute_multiplicity_test.cpp index ad3abbc5d8f..0ee72726294 100644 --- a/cpp/tests/structure/mg_has_edge_and_compute_multiplicity_test.cpp +++ b/cpp/tests/structure/mg_has_edge_and_compute_multiplicity_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/mg_induced_subgraph_test.cu b/cpp/tests/structure/mg_induced_subgraph_test.cu index d1e242b1980..3b32c15bf9f 100644 --- a/cpp/tests/structure/mg_induced_subgraph_test.cu +++ b/cpp/tests/structure/mg_induced_subgraph_test.cu @@ -16,6 +16,7 @@ #include "structure/detail/structure_utils.cuh" #include "structure/induced_subgraph_validate.hpp" #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" diff --git a/cpp/tests/structure/mg_select_random_vertices_test.cpp b/cpp/tests/structure/mg_select_random_vertices_test.cpp index 47440522d32..a33e2ca1813 100644 --- a/cpp/tests/structure/mg_select_random_vertices_test.cpp +++ b/cpp/tests/structure/mg_select_random_vertices_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include diff --git a/cpp/tests/structure/mg_symmetrize_test.cpp b/cpp/tests/structure/mg_symmetrize_test.cpp index 3d1238c5751..7eb387f3915 100644 --- a/cpp/tests/structure/mg_symmetrize_test.cpp +++ b/cpp/tests/structure/mg_symmetrize_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/mg_transpose_storage_test.cpp b/cpp/tests/structure/mg_transpose_storage_test.cpp index f2f735685e6..4cbbe500dd8 100644 --- a/cpp/tests/structure/mg_transpose_storage_test.cpp +++ b/cpp/tests/structure/mg_transpose_storage_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/mg_transpose_test.cpp b/cpp/tests/structure/mg_transpose_test.cpp index 3da44c9159c..80cdcae070a 100644 --- a/cpp/tests/structure/mg_transpose_test.cpp +++ b/cpp/tests/structure/mg_transpose_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/renumbering_test.cpp b/cpp/tests/structure/renumbering_test.cpp index 05b0df4805d..ffb51943660 100644 --- a/cpp/tests/structure/renumbering_test.cpp +++ b/cpp/tests/structure/renumbering_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/structure/symmetrize_test.cpp b/cpp/tests/structure/symmetrize_test.cpp index 5b065272565..383411ccf2b 100644 --- a/cpp/tests/structure/symmetrize_test.cpp +++ b/cpp/tests/structure/symmetrize_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/structure/transpose_storage_test.cpp b/cpp/tests/structure/transpose_storage_test.cpp index 4a4b23f4a63..c4f2523727c 100644 --- a/cpp/tests/structure/transpose_storage_test.cpp +++ b/cpp/tests/structure/transpose_storage_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/structure/transpose_test.cpp b/cpp/tests/structure/transpose_test.cpp index 0bfa6742667..c748926b749 100644 --- a/cpp/tests/structure/transpose_test.cpp +++ b/cpp/tests/structure/transpose_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include diff --git a/cpp/tests/structure/weight_sum_test.cpp b/cpp/tests/structure/weight_sum_test.cpp index 9148f57b8f4..87c31b93734 100644 --- a/cpp/tests/structure/weight_sum_test.cpp +++ b/cpp/tests/structure/weight_sum_test.cpp @@ -15,7 +15,7 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" +#include "utilities/conversion_utilities.hpp" #include #include @@ -134,8 +134,11 @@ class Tests_WeightSum } if (weight_sum_usecase.check_correctness) { - auto [h_offsets, h_indices, h_weights] = - cugraph::test::graph_to_host_csr(handle, graph_view, edge_weight_view); + auto [h_offsets, h_indices, h_weights] = cugraph::test::graph_to_host_csr( + handle, + graph_view, + edge_weight_view, + std::optional>(std::nullopt)); std::vector h_reference_in_weight_sums(graph_view.number_of_vertices()); std::vector h_reference_out_weight_sums(graph_view.number_of_vertices()); diff --git a/cpp/tests/traversal/bfs_test.cpp b/cpp/tests/traversal/bfs_test.cpp index 68aa8dc0cd4..12a6912b581 100644 --- a/cpp/tests/traversal/bfs_test.cpp +++ b/cpp/tests/traversal/bfs_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/extract_bfs_paths_test.cu b/cpp/tests/traversal/extract_bfs_paths_test.cu index e6a5ad6f525..0ff16f2730f 100644 --- a/cpp/tests/traversal/extract_bfs_paths_test.cu +++ b/cpp/tests/traversal/extract_bfs_paths_test.cu @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/k_hop_nbrs_test.cpp b/cpp/tests/traversal/k_hop_nbrs_test.cpp index c2bea204779..4ee00ef4e34 100644 --- a/cpp/tests/traversal/k_hop_nbrs_test.cpp +++ b/cpp/tests/traversal/k_hop_nbrs_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/mg_bfs_test.cpp b/cpp/tests/traversal/mg_bfs_test.cpp index 33fd3319551..bb5d0b317f0 100644 --- a/cpp/tests/traversal/mg_bfs_test.cpp +++ b/cpp/tests/traversal/mg_bfs_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/mg_extract_bfs_paths_test.cu b/cpp/tests/traversal/mg_extract_bfs_paths_test.cu index f51282b639f..6869672d518 100644 --- a/cpp/tests/traversal/mg_extract_bfs_paths_test.cu +++ b/cpp/tests/traversal/mg_extract_bfs_paths_test.cu @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/mg_k_hop_nbrs_test.cpp b/cpp/tests/traversal/mg_k_hop_nbrs_test.cpp index ae4a65cfb53..6c532b68448 100644 --- a/cpp/tests/traversal/mg_k_hop_nbrs_test.cpp +++ b/cpp/tests/traversal/mg_k_hop_nbrs_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/mg_sssp_test.cpp b/cpp/tests/traversal/mg_sssp_test.cpp index 18a36f43da3..467dba384e9 100644 --- a/cpp/tests/traversal/mg_sssp_test.cpp +++ b/cpp/tests/traversal/mg_sssp_test.cpp @@ -15,10 +15,10 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" #include "utilities/mg_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/ms_bfs_test.cu b/cpp/tests/traversal/ms_bfs_test.cu index ffaf1dc18a9..6219b28e6e6 100644 --- a/cpp/tests/traversal/ms_bfs_test.cu +++ b/cpp/tests/traversal/ms_bfs_test.cu @@ -15,7 +15,6 @@ */ #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/traversal/od_shortest_distances_test.cpp b/cpp/tests/traversal/od_shortest_distances_test.cpp index 638124e4ef7..931baff4504 100644 --- a/cpp/tests/traversal/od_shortest_distances_test.cpp +++ b/cpp/tests/traversal/od_shortest_distances_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/traversal/sssp_test.cpp b/cpp/tests/traversal/sssp_test.cpp index 2e5bc09a6a4..2d5f960528e 100644 --- a/cpp/tests/traversal/sssp_test.cpp +++ b/cpp/tests/traversal/sssp_test.cpp @@ -15,8 +15,8 @@ */ #include "utilities/base_fixture.hpp" +#include "utilities/conversion_utilities.hpp" #include "utilities/test_graphs.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/tree/mst_test.cu b/cpp/tests/tree/mst_test.cu index b7b104190cd..e0eb88aac61 100644 --- a/cpp/tests/tree/mst_test.cu +++ b/cpp/tests/tree/mst_test.cu @@ -19,7 +19,6 @@ #include "../src/converters/legacy/COOtoCSR.cuh" #include "utilities/base_fixture.hpp" -#include "utilities/test_utilities.hpp" #include #include diff --git a/cpp/tests/utilities/check_utilities.hpp b/cpp/tests/utilities/check_utilities.hpp new file mode 100644 index 00000000000..68b4ef88dda --- /dev/null +++ b/cpp/tests/utilities/check_utilities.hpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2019-2024, 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 "utilities/conversion_utilities.hpp" + +#include +#include + +#include +#include +#include + +namespace cugraph { +namespace test { + +// check the mapping between v0 & v1 is invertible (one to one and onto) +template +bool check_invertible(raft::host_span v0, raft::host_span v1) +{ + if (v0.size() != v1.size()) return false; + + std::map map{}; + + for (size_t i = 0; i < v0.size(); ++i) { + auto find_it = map.find(v0[i]); + if (find_it == map.end()) { + map[v0[i]] = v1[i]; + } else if (find_it->second != v1[i]) + return false; // one value in v0 is mapped to multiple distinct values in v1, so v0 to v1 is + // not a function + } + + std::map inv_map{}; + for (auto it = map.begin(); it != map.end(); ++it) { + auto find_it = inv_map.find(it->second); + if (find_it == inv_map.end()) { + inv_map[it->second] = it->first; + } else + return false; // multiple distinct values in v0 are mapped to one value in v1 + } + + std::vector inv_v1(v1.size()); + for (size_t i = 0; i < v1.size(); ++i) { + auto find_it = inv_map.find(v1[i]); + if (find_it == inv_map.end()) return false; // elements in v0 are mapped to only a subset of v1 + inv_v1[i] = find_it->second; + } + + return std::equal(v0.begin(), v0.end(), inv_v1.begin()); +} + +template +bool check_invertible(raft::handle_t const& handle, + raft::device_span v0, + raft::device_span v1) +{ + auto v0_copy = to_host(handle, v0); + auto v1_copy = to_host(handle, v1); + + return check_invertible(raft::host_span(v0_copy.data(), v0_copy.size()), + raft::host_span(v1_copy.data(), v1_copy.size())); +} + +template +struct nearly_equal { + const type_t threshold_ratio; + const type_t threshold_magnitude; + + bool operator()(type_t lhs, type_t rhs) const + { + return std::abs(lhs - rhs) < + std::max(std::max(lhs, rhs) * threshold_ratio, threshold_magnitude); + } +}; + +template +struct device_nearly_equal { + const type_t threshold_ratio; + const type_t threshold_magnitude; + + bool __device__ operator()(type_t lhs, type_t rhs) const + { + return std::abs(lhs - rhs) < + thrust::max(thrust::max(lhs, rhs) * threshold_ratio, threshold_magnitude); + } +}; + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/conversion_utilities.hpp b/cpp/tests/utilities/conversion_utilities.hpp new file mode 100644 index 00000000000..cbd08fee806 --- /dev/null +++ b/cpp/tests/utilities/conversion_utilities.hpp @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2019-2024, 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 + +#include +#include + +#include + +#include +#include +#include +#include +#include + +namespace cugraph { +namespace test { + +template +decltype(auto) make_graph(raft::handle_t const& handle, + std::vector const& v_src, + std::vector const& v_dst, + std::optional> const& v_w, + vertex_t num_vertices, + edge_t num_edges) +{ + rmm::device_uvector d_src(num_edges, handle.get_stream()); + rmm::device_uvector d_dst(num_edges, handle.get_stream()); + auto d_w = v_w ? std::make_optional>(num_edges, handle.get_stream()) + : std::nullopt; + + raft::update_device(d_src.data(), v_src.data(), d_src.size(), handle.get_stream()); + raft::update_device(d_dst.data(), v_dst.data(), d_dst.size(), handle.get_stream()); + if (d_w) { + raft::update_device((*d_w).data(), (*v_w).data(), (*d_w).size(), handle.get_stream()); + } + + cugraph::graph_t graph(handle); + std::optional, weight_t>> + edge_weights{std::nullopt}; + std::tie(graph, edge_weights, std::ignore, std::ignore) = + cugraph::create_graph_from_edgelist( + handle, + std::nullopt, + std::move(d_src), + std::move(d_dst), + std::move(d_w), + std::nullopt, + cugraph::graph_properties_t{false, false}, + false); + + return std::make_tuple(std::move(graph), std::move(edge_weights)); +} + +template +std::vector to_host(raft::handle_t const& handle, raft::device_span data) +{ + std::vector h_data(data.size()); + if constexpr (std::is_same_v) { // std::vector stores values in a packed format + auto h_tmp = new bool[data.size()]; + raft::update_host(h_tmp, data.data(), data.size(), handle.get_stream()); + handle.sync_stream(); + std::transform( + h_tmp, h_tmp + data.size(), h_data.begin(), [](uint8_t v) { return static_cast(v); }); + delete[] h_tmp; + } else { + raft::update_host(h_data.data(), data.data(), data.size(), handle.get_stream()); + handle.sync_stream(); + } + return h_data; +} + +template +std::vector to_host(raft::handle_t const& handle, rmm::device_uvector const& data) +{ + return to_host(handle, raft::device_span(data.data(), data.size())); +} + +template +std::optional> to_host(raft::handle_t const& handle, + std::optional> data) +{ + std::optional> h_data{std::nullopt}; + if (data) { h_data = to_host(handle, *data); } + return h_data; +} + +template +std::optional> to_host(raft::handle_t const& handle, + std::optional> const& data) +{ + std::optional> h_data{std::nullopt}; + if (data) { + h_data = to_host(handle, raft::device_span((*data).data(), (*data).size())); + } + return h_data; +} + +template +rmm::device_uvector to_device(raft::handle_t const& handle, raft::host_span data) +{ + rmm::device_uvector d_data(data.size(), handle.get_stream()); + raft::update_device(d_data.data(), data.data(), data.size(), handle.get_stream()); + handle.sync_stream(); + return d_data; +} + +template +rmm::device_uvector to_device(raft::handle_t const& handle, std::vector const& data) +{ + rmm::device_uvector d_data(data.size(), handle.get_stream()); + if constexpr (std::is_same_v) { // std::vector stores values in a packed format + auto h_tmp = new bool[data.size()]; + std::copy(data.begin(), data.end(), h_tmp); + raft::update_device(d_data.data(), h_tmp, h_tmp + data.size(), handle.get_stream()); + handle.sync_stream(); + delete[] h_tmp; + } else { + raft::update_device(d_data.data(), data.data(), data.size(), handle.get_stream()); + handle.sync_stream(); + } + return d_data; +} + +template +std::optional> to_device(raft::handle_t const& handle, + std::optional> data) +{ + std::optional> d_data{std::nullopt}; + if (data) { + d_data = rmm::device_uvector(data->size(), handle.get_stream()); + raft::update_device(d_data->data(), data->data(), data->size(), handle.get_stream()); + handle.sync_stream(); + } + return d_data; +} + +template +std::optional> to_device(raft::handle_t const& handle, + std::optional> const& data) +{ + std::optional> d_data{std::nullopt}; + if (data) { d_data = to_device(handle, *data); } + return d_data; +} + +// If multi-GPU, only the rank 0 GPU holds the valid data +template +std::tuple, std::vector, std::optional>> +graph_to_host_coo( + raft::handle_t const& handle, + cugraph::graph_view_t const& graph_view, + std::optional> edge_weight_view, + std::optional> renumber_map); + +// If multi-GPU, only the rank 0 GPU holds the valid data +template +std::tuple, + rmm::device_uvector, + std::optional>> +graph_to_device_coo( + raft::handle_t const& handle, + cugraph::graph_view_t const& graph_view, + std::optional> edge_weight_view, + std::optional> renumber_map); + +// If multi-GPU, only the rank 0 GPU holds the valid data +template +std::tuple, std::vector, std::optional>> +graph_to_host_csr( + raft::handle_t const& handle, + cugraph::graph_view_t const& graph_view, + std::optional> edge_weight_view, + std::optional> renumber_map); + +// Only the rank 0 GPU holds the valid data +template +std::tuple, + std::optional, + weight_t>>, + std::optional>> +mg_graph_to_sg_graph( + raft::handle_t const& handle, + cugraph::graph_view_t const& graph_view, + std::optional> edge_weight_view, + std::optional> renumber_map, + bool renumber); + +// Only the rank 0 GPU holds the valid data + +template +std::tuple>, rmm::device_uvector> +mg_vertex_property_values_to_sg_vertex_property_values( + raft::handle_t const& handle, + std::optional> + mg_renumber_map, // std::nullopt if the MG graph is not renumbered + std::tuple mg_vertex_partition_range, + std::optional> + sg_renumber_map, // std::nullopt if the SG graph is not renumbered + std::optional> + mg_vertices, // std::nullopt if the entire local vertex partition range is assumed + raft::device_span mg_values); + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/test_utilities_impl.cuh b/cpp/tests/utilities/conversion_utilities_impl.cuh similarity index 96% rename from cpp/tests/utilities/test_utilities_impl.cuh rename to cpp/tests/utilities/conversion_utilities_impl.cuh index a50a1a89663..819bd370541 100644 --- a/cpp/tests/utilities/test_utilities_impl.cuh +++ b/cpp/tests/utilities/conversion_utilities_impl.cuh @@ -16,8 +16,8 @@ #pragma once #include "structure/detail/structure_utils.cuh" +#include "utilities/conversion_utilities.hpp" #include "utilities/device_comm_wrapper.hpp" -#include "utilities/test_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include @@ -46,7 +46,8 @@ std::tuple, std::vector, std::optional const& graph_view, - std::optional> edge_weight_view) + std::optional> edge_weight_view, + std::optional> renumber_map) { rmm::device_uvector d_src(0, handle.get_stream()); rmm::device_uvector d_dst(0, handle.get_stream()); @@ -57,7 +58,7 @@ graph_to_host_coo( graph_view, edge_weight_view, std::optional>{std::nullopt}, - std::optional>{std::nullopt}); + renumber_map); if constexpr (is_multi_gpu) { d_src = cugraph::test::device_gatherv( @@ -105,7 +106,8 @@ std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view) + std::optional> edge_weight_view, + std::optional> renumber_map) { rmm::device_uvector d_src(0, handle.get_stream()); rmm::device_uvector d_dst(0, handle.get_stream()); @@ -116,7 +118,7 @@ graph_to_device_coo( graph_view, edge_weight_view, std::optional>{std::nullopt}, - std::optional>{std::nullopt}); + renumber_map); if constexpr (is_multi_gpu) { d_src = cugraph::test::device_gatherv( @@ -150,7 +152,8 @@ std::tuple, std::vector, std::optional const& graph_view, - std::optional> edge_weight_view) + std::optional> edge_weight_view, + std::optional> renumber_map) { rmm::device_uvector d_src(0, handle.get_stream()); rmm::device_uvector d_dst(0, handle.get_stream()); @@ -161,7 +164,7 @@ graph_to_host_csr( graph_view, edge_weight_view, std::optional>{std::nullopt}, - std::optional>{std::nullopt}); + renumber_map); if constexpr (is_multi_gpu) { d_src = cugraph::test::device_gatherv( @@ -237,7 +240,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber) { rmm::device_uvector d_src(0, handle.get_stream()); @@ -249,7 +252,7 @@ mg_graph_to_sg_graph( graph_view, edge_weight_view, std::optional>{std::nullopt}, - number_map); + renumber_map); d_src = cugraph::test::device_gatherv( handle, raft::device_span{d_src.data(), d_src.size()}); @@ -260,14 +263,14 @@ mg_graph_to_sg_graph( handle, raft::device_span{d_wgt->data(), d_wgt->size()}); rmm::device_uvector vertices(0, handle.get_stream()); - if (number_map) { vertices = cugraph::test::device_gatherv(handle, *number_map); } + if (renumber_map) { vertices = cugraph::test::device_gatherv(handle, *renumber_map); } graph_t sg_graph(handle); std::optional, weight_t>> sg_edge_weights{std::nullopt}; std::optional> sg_number_map; if (handle.get_comms().get_rank() == 0) { - if (!number_map) { + if (!renumber_map) { vertices.resize(graph_view.number_of_vertices(), handle.get_stream()); cugraph::detail::sequence_fill( handle.get_stream(), vertices.data(), vertices.size(), vertex_t{0}); diff --git a/cpp/tests/utilities/test_utilities_mg.cu b/cpp/tests/utilities/conversion_utilities_mg.cu similarity index 84% rename from cpp/tests/utilities/test_utilities_mg.cu rename to cpp/tests/utilities/conversion_utilities_mg.cu index 2d7fb2072e2..04f5bc76046 100644 --- a/cpp/tests/utilities/test_utilities_mg.cu +++ b/cpp/tests/utilities/conversion_utilities_mg.cu @@ -13,7 +13,7 @@ * See the License for the specific language governin_from_mtxg permissions and * limitations under the License. */ -#include "utilities/test_utilities_impl.cuh" +#include "utilities/conversion_utilities_impl.cuh" namespace cugraph { namespace test { @@ -22,73 +22,85 @@ template std::tuple, std::vector, std::optional const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -96,7 +108,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -104,7 +117,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -112,7 +126,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -120,7 +135,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -128,7 +144,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -136,7 +153,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -144,7 +162,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -152,7 +171,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -160,7 +180,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -168,7 +189,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -176,7 +198,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -184,79 +207,92 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple< cugraph::graph_t, @@ -266,7 +302,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -277,7 +313,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -288,7 +324,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -299,7 +335,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -310,7 +346,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -321,7 +357,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -332,7 +368,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -343,7 +379,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -354,7 +390,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -365,7 +401,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -376,7 +412,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple< @@ -387,7 +423,7 @@ mg_graph_to_sg_graph( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, std::optional> edge_weight_view, - std::optional> number_map, + std::optional> renumber_map, bool renumber); template std::tuple>, rmm::device_uvector> diff --git a/cpp/tests/utilities/test_utilities_sg.cu b/cpp/tests/utilities/conversion_utilities_sg.cu similarity index 78% rename from cpp/tests/utilities/test_utilities_sg.cu rename to cpp/tests/utilities/conversion_utilities_sg.cu index 8fa32c7ac63..888b34b7e30 100644 --- a/cpp/tests/utilities/test_utilities_sg.cu +++ b/cpp/tests/utilities/conversion_utilities_sg.cu @@ -13,7 +13,7 @@ * See the License for the specific language governin_from_mtxg permissions and * limitations under the License. */ -#include "utilities/test_utilities_impl.cuh" +#include "utilities/conversion_utilities_impl.cuh" namespace cugraph { namespace test { @@ -22,73 +22,85 @@ template std::tuple, std::vector, std::optional const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -96,7 +108,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -104,7 +117,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -112,7 +126,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -120,7 +135,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -128,7 +144,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -136,7 +153,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -144,7 +162,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -152,7 +171,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -160,7 +180,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -168,7 +189,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -176,7 +198,8 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, rmm::device_uvector, @@ -184,79 +207,92 @@ template std::tuple, graph_to_device_coo( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); template std::tuple, std::vector, std::optional>> graph_to_host_csr( raft::handle_t const& handle, cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); + std::optional> edge_weight_view, + std::optional> renumber_map); } // namespace test } // namespace cugraph diff --git a/cpp/tests/utilities/csv_file_utilities.cu b/cpp/tests/utilities/csv_file_utilities.cu index d801b18cf02..08b1e37af8a 100644 --- a/cpp/tests/utilities/csv_file_utilities.cu +++ b/cpp/tests/utilities/csv_file_utilities.cu @@ -15,7 +15,7 @@ */ #include "detail/graph_partition_utils.cuh" -#include "utilities/test_utilities.hpp" +#include "utilities/csv_file_utilities.hpp" #include #include diff --git a/cpp/tests/utilities/csv_file_utilities.hpp b/cpp/tests/utilities/csv_file_utilities.hpp new file mode 100644 index 00000000000..2e1089dfd97 --- /dev/null +++ b/cpp/tests/utilities/csv_file_utilities.hpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019-2024, 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 + +#include + +#include +#include +#include +#include + +namespace cugraph { +namespace test { + +template +std::tuple, + rmm::device_uvector, + std::optional>, + bool> +read_edgelist_from_csv_file(raft::handle_t const& handle, + std::string const& graph_file_full_path, + bool test_weighted, + bool store_transposed, + bool multi_gpu); + +template +std::tuple, + std::optional< + cugraph::edge_property_t, + weight_t>>, + std::optional>> +read_graph_from_csv_file(raft::handle_t const& handle, + std::string const& graph_file_full_path, + bool test_weighted, + bool renumber); + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/matrix_market_file_utilities.cu b/cpp/tests/utilities/matrix_market_file_utilities.cu index b76e9fdf8cf..302533113ee 100644 --- a/cpp/tests/utilities/matrix_market_file_utilities.cu +++ b/cpp/tests/utilities/matrix_market_file_utilities.cu @@ -15,7 +15,7 @@ */ #include "detail/graph_partition_utils.cuh" -#include "utilities/test_utilities.hpp" +#include "utilities/matrix_market_file_utilities.hpp" #include #include diff --git a/cpp/tests/utilities/matrix_market_file_utilities.hpp b/cpp/tests/utilities/matrix_market_file_utilities.hpp new file mode 100644 index 00000000000..f88fee4da62 --- /dev/null +++ b/cpp/tests/utilities/matrix_market_file_utilities.hpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2019-2024, 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 + +#include + +#include + +#include +#include +#include +#include + +extern "C" { +#include "mmio.h" +} + +namespace cugraph { +namespace test { + +/// Read matrix properties from Matrix Market file +/** Matrix Market file is assumed to be a sparse matrix in coordinate + * format. + * + * @param f File stream for Matrix Market file. + * @param tg Boolean indicating whether to convert matrix to general + * format (from symmetric, Hermitian, or skew symmetric format). + * @param t (Output) MM_typecode with matrix properties. + * @param m (Output) Number of matrix rows. + * @param n (Output) Number of matrix columns. + * @param nnz (Output) Number of non-zero matrix entries. + * @return Zero if properties were read successfully. Otherwise + * non-zero. + */ +template +int mm_properties(FILE* f, int tg, MM_typecode* t, IndexType_* m, IndexType_* n, IndexType_* nnz); + +/// Read Matrix Market file and convert to COO format matrix +/** Matrix Market file is assumed to be a sparse matrix in coordinate + * format. + * + * @param f File stream for Matrix Market file. + * @param tg Boolean indicating whether to convert matrix to general + * format (from symmetric, Hermitian, or skew symmetric format). + * @param nnz Number of non-zero matrix entries. + * @param cooRowInd (Output) Row indices for COO matrix. Should have + * at least nnz entries. + * @param cooColInd (Output) Column indices for COO matrix. Should + * have at least nnz entries. + * @param cooRVal (Output) Real component of COO matrix + * entries. Should have at least nnz entries. Ignored if null + * pointer. + * @param cooIVal (Output) Imaginary component of COO matrix + * entries. Should have at least nnz entries. Ignored if null + * pointer. + * @return Zero if matrix was read successfully. Otherwise non-zero. + */ +template +int mm_to_coo(FILE* f, + int tg, + IndexType_ nnz, + IndexType_* cooRowInd, + IndexType_* cooColInd, + ValueType_* cooRVal, + ValueType_* cooIVal); + +// FIXME: A similar function could be useful for CSC format +// There are functions above that operate coo -> csr and coo->csc +/** + * @tparam + */ +template +std::unique_ptr> generate_graph_csr_from_mm( + bool& directed, std::string mm_file); + +// returns a tuple of (rows, columns, weights, vertices, is_symmetric) +template +std::tuple, + rmm::device_uvector, + std::optional>, + rmm::device_uvector, + bool> +read_edgelist_from_matrix_market_file(raft::handle_t const& handle, + std::string const& graph_file_full_path, + bool test_weighted, + bool store_transposed, + bool multi_gpu); + +// renumber must be true if multi_gpu is true +template +std::tuple, + std::optional< + cugraph::edge_property_t, + weight_t>>, + std::optional>> +read_graph_from_matrix_market_file(raft::handle_t const& handle, + std::string const& graph_file_full_path, + bool test_weighted, + bool renumber); + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/mg_utilities.cpp b/cpp/tests/utilities/mg_utilities.cpp index 86ccdccd49a..6f8fb8c6acd 100644 --- a/cpp/tests/utilities/mg_utilities.cpp +++ b/cpp/tests/utilities/mg_utilities.cpp @@ -13,7 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "utilities/test_utilities.hpp" +#include "utilities/mg_utilities.hpp" + +#include #include #include diff --git a/cpp/tests/utilities/misc_utilities.cpp b/cpp/tests/utilities/misc_utilities.cpp index 842b2fdd7db..f4f815be9e0 100644 --- a/cpp/tests/utilities/misc_utilities.cpp +++ b/cpp/tests/utilities/misc_utilities.cpp @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "utilities/test_utilities.hpp" +#include "utilities/misc_utilities.hpp" #include #include diff --git a/cpp/tests/utilities/misc_utilities.hpp b/cpp/tests/utilities/misc_utilities.hpp new file mode 100644 index 00000000000..4200d5112c5 --- /dev/null +++ b/cpp/tests/utilities/misc_utilities.hpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019-2024, 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 + +namespace cugraph { +namespace test { + +std::string getFileName(const std::string& s); + +// Define RAPIDS_DATASET_ROOT_DIR using a preprocessor variable to +// allow for a build to override the default. This is useful for +// having different builds for specific default dataset locations. +#ifndef RAPIDS_DATASET_ROOT_DIR +#define RAPIDS_DATASET_ROOT_DIR "/datasets" +#endif + +static const std::string& get_rapids_dataset_root_dir() +{ + static std::string rdrd(""); + // Env var always overrides the value of RAPIDS_DATASET_ROOT_DIR + if (rdrd == "") { + const char* envVar = std::getenv("RAPIDS_DATASET_ROOT_DIR"); + rdrd = (envVar != NULL) ? envVar : RAPIDS_DATASET_ROOT_DIR; + } + return rdrd; +} + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/property_generator_kernels.cuh b/cpp/tests/utilities/property_generator_kernels.cuh new file mode 100644 index 00000000000..d8d5cc420fd --- /dev/null +++ b/cpp/tests/utilities/property_generator_kernels.cuh @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2021-2024, 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 "prims/transform_e.cuh" +#include "prims/update_edge_src_dst_property.cuh" +#include "utilities/property_generator_utilities.hpp" + +#include +#include + +#include + +#include +#include + +namespace cugraph { +namespace test { + +namespace detail { + +template +__host__ __device__ auto make_type_casted_tuple_from_scalar(T val, std::index_sequence) +{ + return thrust::make_tuple( + static_cast::type>(val)...); +} + +template +__host__ __device__ auto make_property_value(T val) +{ + property_t ret{}; + if constexpr (cugraph::is_thrust_tuple_of_arithmetic::value) { + ret = make_type_casted_tuple_from_scalar( + val, std::make_index_sequence::value>{}); + } else { + ret = static_cast(val); + } + return ret; +} + +template +struct vertex_property_transform { + int32_t mod{}; + + constexpr __device__ property_t operator()(vertex_t v) const + { + static_assert(cugraph::is_thrust_tuple_of_arithmetic::value || + std::is_arithmetic_v); + cuco::detail::MurmurHash3_32 hash_func{}; + return make_property_value(hash_func(v) % mod); + } +}; + +template +struct edge_property_transform { + int32_t mod{}; + + constexpr __device__ property_t operator()( + vertex_t src, vertex_t dst, thrust::nullopt_t, thrust::nullopt_t, thrust::nullopt_t) const + { + static_assert(cugraph::is_thrust_tuple_of_arithmetic::value || + std::is_arithmetic_v); + cuco::detail::MurmurHash3_32 hash_func{}; + return make_property_value(hash_func(src + dst) % mod); + } +}; + +} // namespace detail + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/property_generator_utilities.hpp b/cpp/tests/utilities/property_generator_utilities.hpp new file mode 100644 index 00000000000..6bd22da1f75 --- /dev/null +++ b/cpp/tests/utilities/property_generator_utilities.hpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021-2024, 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 +#include + +#include + +#include + +#include +#include + +namespace cugraph { +namespace test { + +template +struct generate { + private: + using vertex_type = typename GraphViewType::vertex_type; + + using property_buffer_type = std::decay_t( + size_t{0}, rmm::cuda_stream_view{}))>; + + public: + static property_t initial_value(int32_t init); + + static property_buffer_type vertex_property(raft::handle_t const& handle, + rmm::device_uvector const& labels, + int32_t hash_bin_count); + + static property_buffer_type vertex_property(raft::handle_t const& handle, + thrust::counting_iterator begin, + thrust::counting_iterator end, + int32_t hash_bin_count); + + static cugraph::edge_src_property_t src_property( + raft::handle_t const& handle, + GraphViewType const& graph_view, + property_buffer_type const& property); + + static cugraph::edge_dst_property_t dst_property( + raft::handle_t const& handle, + GraphViewType const& graph_view, + property_buffer_type const& property); + + static cugraph::edge_property_t edge_property( + raft::handle_t const& handle, GraphViewType const& graph_view, int32_t hash_bin_count); +}; + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/property_generator_utilities_impl.cuh b/cpp/tests/utilities/property_generator_utilities_impl.cuh new file mode 100644 index 00000000000..1a6c87700a9 --- /dev/null +++ b/cpp/tests/utilities/property_generator_utilities_impl.cuh @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2021-2024, 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 "prims/transform_e.cuh" +#include "prims/update_edge_src_dst_property.cuh" +#include "utilities/property_generator_kernels.cuh" +#include "utilities/property_generator_utilities.hpp" + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace cugraph { +namespace test { + +template +property_t generate::initial_value(int32_t init) +{ + return detail::make_property_value(init); +} + +template +typename generate::property_buffer_type +generate::vertex_property(raft::handle_t const& handle, + rmm::device_uvector const& labels, + int32_t hash_bin_count) +{ + auto data = cugraph::allocate_dataframe_buffer(labels.size(), handle.get_stream()); + thrust::transform(handle.get_thrust_policy(), + labels.begin(), + labels.end(), + cugraph::get_dataframe_buffer_begin(data), + detail::vertex_property_transform{hash_bin_count}); + return data; +} + +template +typename generate::property_buffer_type +generate::vertex_property(raft::handle_t const& handle, + thrust::counting_iterator begin, + thrust::counting_iterator end, + int32_t hash_bin_count) +{ + auto length = thrust::distance(begin, end); + auto data = cugraph::allocate_dataframe_buffer(length, handle.get_stream()); + thrust::transform(handle.get_thrust_policy(), + begin, + end, + cugraph::get_dataframe_buffer_begin(data), + detail::vertex_property_transform{hash_bin_count}); + return data; +} + +template +cugraph::edge_src_property_t +generate::src_property(raft::handle_t const& handle, + GraphViewType const& graph_view, + property_buffer_type const& property) +{ + auto output_property = + cugraph::edge_src_property_t(handle, graph_view); + update_edge_src_property( + handle, graph_view, cugraph::get_dataframe_buffer_begin(property), output_property); + return output_property; +} + +template +cugraph::edge_dst_property_t +generate::dst_property(raft::handle_t const& handle, + GraphViewType const& graph_view, + property_buffer_type const& property) +{ + auto output_property = + cugraph::edge_dst_property_t(handle, graph_view); + update_edge_dst_property( + handle, graph_view, cugraph::get_dataframe_buffer_begin(property), output_property); + return output_property; +} + +template +cugraph::edge_property_t +generate::edge_property(raft::handle_t const& handle, + GraphViewType const& graph_view, + int32_t hash_bin_count) +{ + auto output_property = cugraph::edge_property_t(handle, graph_view); + cugraph::transform_e(handle, + graph_view, + cugraph::edge_src_dummy_property_t{}.view(), + cugraph::edge_dst_dummy_property_t{}.view(), + cugraph::edge_dummy_property_t{}.view(), + detail::edge_property_transform{hash_bin_count}, + output_property.mutable_view()); + return output_property; +} + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/property_generator_utilities_mg.cu b/cpp/tests/utilities/property_generator_utilities_mg.cu new file mode 100644 index 00000000000..f283050dca8 --- /dev/null +++ b/cpp/tests/utilities/property_generator_utilities_mg.cu @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021-2024, 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 "utilities/property_generator_utilities_impl.cuh" + +namespace cugraph { +namespace test { + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/property_generator_utilities_sg.cu b/cpp/tests/utilities/property_generator_utilities_sg.cu new file mode 100644 index 00000000000..dd1907a9f1d --- /dev/null +++ b/cpp/tests/utilities/property_generator_utilities_sg.cu @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2021-2024, 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 "utilities/property_generator_utilities_impl.cuh" + +namespace cugraph { +namespace test { + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +template struct generate, bool>; +template struct generate, int32_t>; +template struct generate, int64_t>; +template struct generate, + thrust::tuple>; + +} // namespace test +} // namespace cugraph diff --git a/cpp/tests/utilities/test_graphs.hpp b/cpp/tests/utilities/test_graphs.hpp index 9b7ffe74e85..0f3224bfc52 100644 --- a/cpp/tests/utilities/test_graphs.hpp +++ b/cpp/tests/utilities/test_graphs.hpp @@ -15,7 +15,9 @@ */ #pragma once -#include "utilities/test_utilities.hpp" +#include "utilities/csv_file_utilities.hpp" +#include "utilities/matrix_market_file_utilities.hpp" +#include "utilities/misc_utilities.hpp" #include "utilities/thrust_wrapper.hpp" #include diff --git a/cpp/tests/utilities/test_utilities.hpp b/cpp/tests/utilities/test_utilities.hpp deleted file mode 100644 index 8bf606e5753..00000000000 --- a/cpp/tests/utilities/test_utilities.hpp +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Copyright (c) 2019-2024, 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 -#include - -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -extern "C" { -#include "mmio.h" -} - -namespace cugraph { -namespace test { - -std::string getFileName(const std::string& s); - -/// Read matrix properties from Matrix Market file -/** Matrix Market file is assumed to be a sparse matrix in coordinate - * format. - * - * @param f File stream for Matrix Market file. - * @param tg Boolean indicating whether to convert matrix to general - * format (from symmetric, Hermitian, or skew symmetric format). - * @param t (Output) MM_typecode with matrix properties. - * @param m (Output) Number of matrix rows. - * @param n (Output) Number of matrix columns. - * @param nnz (Output) Number of non-zero matrix entries. - * @return Zero if properties were read successfully. Otherwise - * non-zero. - */ -template -int mm_properties(FILE* f, int tg, MM_typecode* t, IndexType_* m, IndexType_* n, IndexType_* nnz); - -/// Read Matrix Market file and convert to COO format matrix -/** Matrix Market file is assumed to be a sparse matrix in coordinate - * format. - * - * @param f File stream for Matrix Market file. - * @param tg Boolean indicating whether to convert matrix to general - * format (from symmetric, Hermitian, or skew symmetric format). - * @param nnz Number of non-zero matrix entries. - * @param cooRowInd (Output) Row indices for COO matrix. Should have - * at least nnz entries. - * @param cooColInd (Output) Column indices for COO matrix. Should - * have at least nnz entries. - * @param cooRVal (Output) Real component of COO matrix - * entries. Should have at least nnz entries. Ignored if null - * pointer. - * @param cooIVal (Output) Imaginary component of COO matrix - * entries. Should have at least nnz entries. Ignored if null - * pointer. - * @return Zero if matrix was read successfully. Otherwise non-zero. - */ -template -int mm_to_coo(FILE* f, - int tg, - IndexType_ nnz, - IndexType_* cooRowInd, - IndexType_* cooColInd, - ValueType_* cooRVal, - ValueType_* cooIVal); - -// FIXME: A similar function could be useful for CSC format -// There are functions above that operate coo -> csr and coo->csc -/** - * @tparam - */ -template -std::unique_ptr> generate_graph_csr_from_mm( - bool& directed, std::string mm_file); - -// Define RAPIDS_DATASET_ROOT_DIR using a preprocessor variable to -// allow for a build to override the default. This is useful for -// having different builds for specific default dataset locations. -#ifndef RAPIDS_DATASET_ROOT_DIR -#define RAPIDS_DATASET_ROOT_DIR "/datasets" -#endif - -static const std::string& get_rapids_dataset_root_dir() -{ - static std::string rdrd(""); - // Env var always overrides the value of RAPIDS_DATASET_ROOT_DIR - if (rdrd == "") { - const char* envVar = std::getenv("RAPIDS_DATASET_ROOT_DIR"); - rdrd = (envVar != NULL) ? envVar : RAPIDS_DATASET_ROOT_DIR; - } - return rdrd; -} - -// returns a tuple of (rows, columns, weights, vertices, is_symmetric) -template -std::tuple, - rmm::device_uvector, - std::optional>, - rmm::device_uvector, - bool> -read_edgelist_from_matrix_market_file(raft::handle_t const& handle, - std::string const& graph_file_full_path, - bool test_weighted, - bool store_transposed, - bool multi_gpu); - -// renumber must be true if multi_gpu is true -template -std::tuple, - std::optional< - cugraph::edge_property_t, - weight_t>>, - std::optional>> -read_graph_from_matrix_market_file(raft::handle_t const& handle, - std::string const& graph_file_full_path, - bool test_weighted, - bool renumber); - -template -std::tuple, - rmm::device_uvector, - std::optional>, - bool> -read_edgelist_from_csv_file(raft::handle_t const& handle, - std::string const& graph_file_full_path, - bool test_weighted, - bool store_transposed, - bool multi_gpu); - -template -std::tuple, - std::optional< - cugraph::edge_property_t, - weight_t>>, - std::optional>> -read_graph_from_csv_file(raft::handle_t const& handle, - std::string const& graph_file_full_path, - bool test_weighted, - bool renumber); - -// alias for easy customization for debug purposes: -// -template -using vector_test_t = rmm::device_uvector; - -template -decltype(auto) make_graph(raft::handle_t const& handle, - std::vector const& v_src, - std::vector const& v_dst, - std::optional> const& v_w, - vertex_t num_vertices, - edge_t num_edges) -{ - vector_test_t d_src(num_edges, handle.get_stream()); - vector_test_t d_dst(num_edges, handle.get_stream()); - auto d_w = v_w ? std::make_optional>(num_edges, handle.get_stream()) - : std::nullopt; - - raft::update_device(d_src.data(), v_src.data(), d_src.size(), handle.get_stream()); - raft::update_device(d_dst.data(), v_dst.data(), d_dst.size(), handle.get_stream()); - if (d_w) { - raft::update_device((*d_w).data(), (*v_w).data(), (*d_w).size(), handle.get_stream()); - } - - cugraph::graph_t graph(handle); - std::optional, weight_t>> - edge_weights{std::nullopt}; - std::tie(graph, edge_weights, std::ignore, std::ignore) = - cugraph::create_graph_from_edgelist( - handle, - std::nullopt, - std::move(d_src), - std::move(d_dst), - std::move(d_w), - std::nullopt, - cugraph::graph_properties_t{false, false}, - false); - - return std::make_tuple(std::move(graph), std::move(edge_weights)); -} - -// compares single GPU CSR graph data: -// (for testing / debugging); -// on first == false, second == brief description of what is different; -// -template -std::pair compare_graphs(raft::handle_t const& handle, - left_graph_t const& lgraph, - right_graph_t const& rgraph) -{ - if constexpr (left_graph_t::is_multi_gpu && right_graph_t::is_multi_gpu) { - // no support for comparing distributed graphs, yet: - // - CUGRAPH_FAIL("Unsupported graph type for comparison."); - return std::make_pair(false, std::string("unsupported")); - } else if constexpr (!std::is_same_v) { - return std::make_pair(false, std::string("type")); - } else { - // both graphs are single GPU: - // - using graph_t = left_graph_t; - - using vertex_t = typename graph_t::vertex_type; - using edge_t = typename graph_t::edge_type; - using weight_t = typename graph_t::weight_type; - - size_t num_vertices = lgraph.number_of_vertices(); - size_t num_edges = lgraph.number_of_edges(); - - { - size_t r_num_vertices = rgraph.number_of_vertices(); - size_t r_num_edges = rgraph.number_of_edges(); - - if (num_vertices != r_num_vertices) return std::make_pair(false, std::string("num_vertices")); - - if (num_edges != r_num_edges) return std::make_pair(false, std::string("num_edges")); - } - - if (lgraph.is_symmetric() != rgraph.is_symmetric()) - return std::make_pair(false, std::string("symmetric")); - - if (lgraph.is_multigraph() != rgraph.is_multigraph()) - return std::make_pair(false, std::string("multigraph")); - - bool is_weighted = lgraph.is_weighted(); - if (is_weighted != rgraph.is_weighted()) return std::make_pair(false, std::string("weighted")); - - auto lgraph_view = lgraph.view(); - auto rgraph_view = rgraph.view(); - - std::vector lv_ro(num_vertices + 1); - std::vector lv_ci(num_edges); - - raft::update_host(lv_ro.data(), - lgraph_view.local_edge_partition_view().offsets().data(), - num_vertices + 1, - handle.get_stream()); - raft::update_host(lv_ci.data(), - lgraph_view.local_edge_partition_view().indices().data(), - num_edges, - handle.get_stream()); - - std::vector rv_ro(num_vertices + 1); - std::vector rv_ci(num_edges); - - raft::update_host(rv_ro.data(), - rgraph_view.local_edge_partition_view().offsets().data(), - num_vertices + 1, - handle.get_stream()); - raft::update_host(rv_ci.data(), - rgraph_view.local_edge_partition_view().indices().data(), - num_edges, - handle.get_stream()); - - auto lv_vs = is_weighted ? std::make_optional>(num_edges) : std::nullopt; - auto rv_vs = is_weighted ? std::make_optional>(num_edges) : std::nullopt; - if (is_weighted) { - raft::update_host((*lv_vs).data(), - (*(lgraph_view.local_edge_partition_view().weights())).data(), - num_edges, - handle.get_stream()); - - raft::update_host((*rv_vs).data(), - (*(rgraph_view.local_edge_partition_view().weights())).data(), - num_edges, - handle.get_stream()); - } - - handle.sync_stream(); - - if (lv_ro != rv_ro) return std::make_pair(false, std::string("offsets")); - - for (size_t i = 0; i < num_vertices; ++i) { - auto first = lv_ro[i]; - auto last = lv_ro[i + 1]; - if (is_weighted) { - std::vector> lv_pairs(last - first); - std::vector> rv_pairs(last - first); - for (edge_t j = first; j < last; ++j) { - lv_pairs[j - first] = std::make_tuple(lv_ci[j], (*lv_vs)[j]); - rv_pairs[j - first] = std::make_tuple(rv_ci[j], (*rv_vs)[j]); - } - std::sort(lv_pairs.begin(), lv_pairs.end()); - std::sort(rv_pairs.begin(), rv_pairs.end()); - if (!std::equal(lv_pairs.begin(), lv_pairs.end(), rv_pairs.begin(), [](auto lhs, auto rhs) { - return std::get<0>(lhs) == std::get<0>(rhs); - })) - return std::make_pair(false, std::string("indices")); - if (!std::equal(lv_pairs.begin(), lv_pairs.end(), rv_pairs.begin(), [](auto lhs, auto rhs) { - return std::get<1>(lhs) == std::get<1>(rhs); - })) - return std::make_pair(false, std::string("values")); - } else { - std::sort(lv_ci.begin() + first, lv_ci.begin() + last); - std::sort(rv_ci.begin() + first, rv_ci.begin() + last); - if (!std::equal(lv_ci.begin() + first, lv_ci.begin() + last, rv_ci.begin() + first)) - return std::make_pair(false, std::string("indices")); - } - } - - if (lgraph_view.local_edge_partition_segment_offsets(0) != - rgraph_view.local_edge_partition_segment_offsets(0)) - return std::make_pair(false, std::string("segment offsets")); - - return std::make_pair(true, std::string{}); - } -} - -// check the mapping between v0 & v1 is invertible (one to one and onto) -template -bool check_invertible(raft::host_span v0, raft::host_span v1) -{ - if (v0.size() != v1.size()) return false; - - std::map map{}; - - for (size_t i = 0; i < v0.size(); ++i) { - auto find_it = map.find(v0[i]); - if (find_it == map.end()) { - map[v0[i]] = v1[i]; - } else if (find_it->second != v1[i]) - return false; // one value in v0 is mapped to multiple distinct values in v1, so v0 to v1 is - // not a function - } - - std::map inv_map{}; - for (auto it = map.begin(); it != map.end(); ++it) { - auto find_it = inv_map.find(it->second); - if (find_it == inv_map.end()) { - inv_map[it->second] = it->first; - } else - return false; // multiple distinct values in v0 are mapped to one value in v1 - } - - std::vector inv_v1(v1.size()); - for (size_t i = 0; i < v1.size(); ++i) { - auto find_it = inv_map.find(v1[i]); - if (find_it == inv_map.end()) return false; // elements in v0 are mapped to only a subset of v1 - inv_v1[i] = find_it->second; - } - - return std::equal(v0.begin(), v0.end(), inv_v1.begin()); -} - -template -std::vector to_host(raft::handle_t const& handle, raft::device_span data) -{ - std::vector h_data(data.size()); - if constexpr (std::is_same_v) { // std::vector stores values in a packed format - auto h_tmp = new bool[data.size()]; - raft::update_host(h_tmp, data.data(), data.size(), handle.get_stream()); - handle.sync_stream(); - std::transform( - h_tmp, h_tmp + data.size(), h_data.begin(), [](uint8_t v) { return static_cast(v); }); - delete[] h_tmp; - } else { - raft::update_host(h_data.data(), data.data(), data.size(), handle.get_stream()); - handle.sync_stream(); - } - return h_data; -} - -template -std::vector to_host(raft::handle_t const& handle, rmm::device_uvector const& data) -{ - return to_host(handle, raft::device_span(data.data(), data.size())); -} - -template -std::optional> to_host(raft::handle_t const& handle, - std::optional> data) -{ - std::optional> h_data{std::nullopt}; - if (data) { h_data = to_host(handle, *data); } - return h_data; -} - -template -std::optional> to_host(raft::handle_t const& handle, - std::optional> const& data) -{ - std::optional> h_data{std::nullopt}; - if (data) { - h_data = to_host(handle, raft::device_span((*data).data(), (*data).size())); - } - return h_data; -} - -template -rmm::device_uvector to_device(raft::handle_t const& handle, raft::host_span data) -{ - rmm::device_uvector d_data(data.size(), handle.get_stream()); - raft::update_device(d_data.data(), data.data(), data.size(), handle.get_stream()); - handle.sync_stream(); - return d_data; -} - -template -rmm::device_uvector to_device(raft::handle_t const& handle, std::vector const& data) -{ - rmm::device_uvector d_data(data.size(), handle.get_stream()); - if constexpr (std::is_same_v) { // std::vector stores values in a packed format - auto h_tmp = new bool[data.size()]; - std::copy(data.begin(), data.end(), h_tmp); - raft::update_device(d_data.data(), h_tmp, h_tmp + data.size(), handle.get_stream()); - handle.sync_stream(); - delete[] h_tmp; - } else { - raft::update_device(d_data.data(), data.data(), data.size(), handle.get_stream()); - handle.sync_stream(); - } - return d_data; -} - -template -std::optional> to_device(raft::handle_t const& handle, - std::optional> data) -{ - std::optional> d_data{std::nullopt}; - if (data) { - d_data = rmm::device_uvector(data->size(), handle.get_stream()); - raft::update_device(d_data->data(), data->data(), data->size(), handle.get_stream()); - handle.sync_stream(); - } - return d_data; -} - -template -std::optional> to_device(raft::handle_t const& handle, - std::optional> const& data) -{ - std::optional> d_data{std::nullopt}; - if (data) { d_data = to_device(handle, *data); } - return d_data; -} - -template -bool check_invertible(raft::handle_t const& handle, - raft::device_span v0, - raft::device_span v1) -{ - auto v0_copy = to_host(handle, v0); - auto v1_copy = to_host(handle, v1); - - return check_invertible(raft::host_span(v0_copy.data(), v0_copy.size()), - raft::host_span(v1_copy.data(), v1_copy.size())); -} - -template -std::vector random_vector(L size, unsigned seed = 0) -{ - std::default_random_engine gen(seed); - std::uniform_real_distribution dist(0.0, 1.0); - std::vector v(size); - std::generate(v.begin(), v.end(), [&] { return dist(gen); }); - return v; -} - -// If multi-GPU, only the rank 0 GPU holds the valid data -template -std::tuple, std::vector, std::optional>> -graph_to_host_coo( - raft::handle_t const& handle, - cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); - -// If multi-GPU, only the rank 0 GPU holds the valid data -template -std::tuple, - rmm::device_uvector, - std::optional>> -graph_to_device_coo( - raft::handle_t const& handle, - cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); - -// If multi-GPU, only the rank 0 GPU holds the valid data -template -std::tuple, std::vector, std::optional>> -graph_to_host_csr( - raft::handle_t const& handle, - cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view); - -// Only the rank 0 GPU holds the valid data -template -std::tuple, - std::optional, - weight_t>>, - std::optional>> -mg_graph_to_sg_graph( - raft::handle_t const& handle, - cugraph::graph_view_t const& graph_view, - std::optional> edge_weight_view, - std::optional> number_map, - bool renumber); - -// Only the rank 0 GPU holds the valid data - -template -std::tuple>, rmm::device_uvector> -mg_vertex_property_values_to_sg_vertex_property_values( - raft::handle_t const& handle, - std::optional> - mg_renumber_map, // std::nullopt if the MG graph is not renumbered - std::tuple mg_vertex_partition_range, - std::optional> - sg_renumber_map, // std::nullopt if the SG graph is not renumbered - std::optional> - mg_vertices, // std::nullopt if the entire local vertex partition range is assumed - raft::device_span mg_values); - -template -struct nearly_equal { - const type_t threshold_ratio; - const type_t threshold_magnitude; - - bool operator()(type_t lhs, type_t rhs) const - { - return std::abs(lhs - rhs) < - std::max(std::max(lhs, rhs) * threshold_ratio, threshold_magnitude); - } -}; - -template -struct device_nearly_equal { - const type_t threshold_ratio; - const type_t threshold_magnitude; - - bool __device__ operator()(type_t lhs, type_t rhs) const - { - return std::abs(lhs - rhs) < - thrust::max(thrust::max(lhs, rhs) * threshold_ratio, threshold_magnitude); - } -}; - -} // namespace test -} // namespace cugraph