From b68381f6e6bda5cb549aca70e3e5065bc02f3339 Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Wed, 13 Dec 2023 07:32:48 -0800 Subject: [PATCH] add tests --- cpp/tests/CMakeLists.txt | 4 + cpp/tests/community/ktruss_test.cpp | 129 ++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 cpp/tests/community/ktruss_test.cpp diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 6530a25d178..3d2f51f7df8 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -550,6 +550,10 @@ if(BUILD_CUGRAPH_MG_TESTS) # - MG TRIANGLE COUNT tests ------------------------------------------------------------------- ConfigureTestMG(MG_TRIANGLE_COUNT_TEST community/mg_triangle_count_test.cpp) + ############################################################################################### + # - Ktruss tests -------------------------------------------------------------------------- + ConfigureTest(KTRUSS_TEST community/ktruss_test.cpp) + ############################################################################################### # - MG INDUCED SUBGRAPH tests ----------------------------------------------------------------- ConfigureTestMG(MG_INDUCED_SUBGRAPH_TEST structure/mg_induced_subgraph_test.cu) diff --git a/cpp/tests/community/ktruss_test.cpp b/cpp/tests/community/ktruss_test.cpp new file mode 100644 index 00000000000..51d7f949f4c --- /dev/null +++ b/cpp/tests/community/ktruss_test.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governin_from_mtxg permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + + +struct Ktruss_Usecase { + int32_t k{10}; + bool check_correctness{true}; +}; + +template +class Tests_Ktruss + : public ::testing::TestWithParam> { + public: + Tests_Ktruss() {} + + static void SetUpTestCase() {} + static void TearDownTestCase() {} + + virtual void SetUp() {} + virtual void TearDown() {} + + template + void run_current_test( + std::tuple const& param) + { + constexpr bool renumber = false; + + using weight_t = float; + + auto [ktruss_usecase, input_usecase] = param; + + raft::handle_t handle{}; + HighResTimer hr_timer{}; + + if (cugraph::test::g_perf) { + RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement + hr_timer.start("MG Construct graph"); + } + + cugraph::graph_t graph(handle); + std::optional> d_renumber_map_labels{std::nullopt}; + std::tie(graph, std::ignore, d_renumber_map_labels) = + cugraph::test::construct_graph( + handle, input_usecase, false, renumber, false, true); + + if (cugraph::test::g_perf) { + RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement + hr_timer.stop(); + hr_timer.display_and_clear(std::cout); + } + + auto graph_view = graph.view(); + + if (cugraph::test::g_perf) { + RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement + hr_timer.start("Ktruss"); + } + + cugraph::ktruss( + handle, + graph_view, + ktruss_usecase.k, + false); + + if (cugraph::test::g_perf) { + RAFT_CUDA_TRY(cudaDeviceSynchronize()); // for consistent performance measurement + hr_timer.stop(); + hr_timer.display_and_clear(std::cout); + } + + } +}; + +using Tests_Ktruss_File = Tests_Ktruss; + +// FIXME: add tests for type combinations +TEST_P(Tests_Ktruss_File, CheckInt32Int32) +{ + run_current_test(override_File_Usecase_with_cmd_line_arguments(GetParam())); +} + + +INSTANTIATE_TEST_SUITE_P( + file_test, + Tests_Ktruss_File, + ::testing::Combine( + // enable correctness checks + ::testing::Values(Ktruss_Usecase{2}), + ::testing::Values(cugraph::test::File_Usecase("/home/nfs/jnke/debug_jaccard/cugraph/datasets/dummy.mtx")))); + +CUGRAPH_TEST_PROGRAM_MAIN()