Skip to content

Commit

Permalink
make C++ tests run faster (fewer tests) (#1989)
Browse files Browse the repository at this point in the history
Modified the most expensive C++ tests to run fewer tests.  Closes #1555 

Added an option (like in the rmat tests) to run a specific test file if the developer wants to manually run larger tests.  For example:

```tests/COARSEN_GRAPH_TEST --gtest_filter=file_ben* --test_file_name=test/datasets/ljournal-2008.mtx```

The smaller graphs *should* be small enough to test things.  Once we add C++ code coverage we should be able to verify this.

On my local workstation this reduced the time spent executing the C++ tests by about 25 minutes.

Authors:
  - Chuck Hastings (https://github.com/ChuckHastings)

Approvers:
  - Kumar Aatish (https://github.com/kaatish)
  - Seunghwa Kang (https://github.com/seunghwak)

URL: #1989
  • Loading branch information
ChuckHastings authored Jan 5, 2022
1 parent 1f99607 commit c49f049
Show file tree
Hide file tree
Showing 6 changed files with 418 additions and 206 deletions.
46 changes: 27 additions & 19 deletions cpp/tests/link_analysis/hits_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -142,9 +142,10 @@ class Tests_Hits : public ::testing::TestWithParam<std::tuple<Hits_Usecase, inpu
virtual void TearDown() {}

template <typename vertex_t, typename edge_t, typename weight_t>
void run_current_test(Hits_Usecase const& hits_usecase, input_usecase_t const& input_usecase)
void run_current_test(std::tuple<Hits_Usecase const&, input_usecase_t const&> const& param)
{
constexpr bool renumber = true;
constexpr bool renumber = true;
auto [hits_usecase, input_usecase] = param;

// 1. initialize handle

Expand Down Expand Up @@ -270,31 +271,28 @@ class Tests_Hits : public ::testing::TestWithParam<std::tuple<Hits_Usecase, inpu
using Tests_Hits_File = Tests_Hits<cugraph::test::File_Usecase>;
using Tests_Hits_Rmat = Tests_Hits<cugraph::test::Rmat_Usecase>;

TEST_P(Tests_Hits_File, CheckInt32Int32FloatFloat)
TEST_P(Tests_Hits_File, CheckInt32Int32Float)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float>(std::get<0>(param), std::get<1>(param));
run_current_test<int32_t, int32_t, float>(
override_File_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_Hits_Rmat, CheckInt32Int32FloatFloat)
TEST_P(Tests_Hits_Rmat, CheckInt32Int32Float)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_Hits_Rmat, CheckInt32Int64FloatFloat)
TEST_P(Tests_Hits_Rmat, CheckInt32Int64Float)
{
auto param = GetParam();
run_current_test<int32_t, int64_t, float>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_Hits_Rmat, CheckInt64Int64FloatFloat)
TEST_P(Tests_Hits_Rmat, CheckInt64Int64Float)
{
auto param = GetParam();
run_current_test<int64_t, int64_t, float>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

INSTANTIATE_TEST_SUITE_P(
Expand All @@ -304,9 +302,7 @@ INSTANTIATE_TEST_SUITE_P(
// enable correctness checks
::testing::Values(Hits_Usecase{true, false}, Hits_Usecase{true, true}),
::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"),
cugraph::test::File_Usecase("test/datasets/web-Google.mtx"),
cugraph::test::File_Usecase("test/datasets/ljournal-2008.mtx"),
cugraph::test::File_Usecase("test/datasets/webbase-1M.mtx"))));
cugraph::test::File_Usecase("test/datasets/dolphins.mtx"))));

INSTANTIATE_TEST_SUITE_P(rmat_small_test,
Tests_Hits_Rmat,
Expand All @@ -316,6 +312,18 @@ INSTANTIATE_TEST_SUITE_P(rmat_small_test,
::testing::Values(cugraph::test::Rmat_Usecase(
10, 16, 0.57, 0.19, 0.19, 0, false, 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_Hits_File,
::testing::Combine(
// disable correctness checks
::testing::Values(Hits_Usecase{false, false}, Hits_Usecase{false, true}),
::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
Expand All @@ -326,6 +334,6 @@ INSTANTIATE_TEST_SUITE_P(
// disable correctness checks for large graphs
::testing::Combine(
::testing::Values(Hits_Usecase{false, false}, Hits_Usecase{false, true}),
::testing::Values(cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, false, false))));
::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, false, false))));

CUGRAPH_TEST_PROGRAM_MAIN()
44 changes: 27 additions & 17 deletions cpp/tests/link_analysis/pagerank_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -147,10 +147,10 @@ class Tests_PageRank
virtual void TearDown() {}

template <typename vertex_t, typename edge_t, typename weight_t, typename result_t>
void run_current_test(PageRank_Usecase const& pagerank_usecase,
input_usecase_t const& input_usecase)
void run_current_test(std::tuple<PageRank_Usecase const&, input_usecase_t const&> const& param)
{
constexpr bool renumber = true;
constexpr bool renumber = true;
auto [pagerank_usecase, input_usecase] = param;

raft::handle_t handle{};
HighResClock hr_clock{};
Expand Down Expand Up @@ -407,29 +407,26 @@ using Tests_PageRank_Rmat = Tests_PageRank<cugraph::test::Rmat_Usecase>;
// FIXME: add tests for type combinations
TEST_P(Tests_PageRank_File, CheckInt32Int32FloatFloat)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float, float>(std::get<0>(param), std::get<1>(param));
run_current_test<int32_t, int32_t, float, float>(
override_File_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_PageRank_Rmat, CheckInt32Int32FloatFloat)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float, float>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_PageRank_Rmat, CheckInt32Int64FloatFloat)
TEST_P(Tests_PageRank_File, CheckInt32Int64FloatFloat)
{
auto param = GetParam();
run_current_test<int32_t, int64_t, float, float>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_File_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_PageRank_Rmat, CheckInt64Int64FloatFloat)
{
auto param = GetParam();
run_current_test<int64_t, int64_t, float, float>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

INSTANTIATE_TEST_SUITE_P(
Expand All @@ -442,9 +439,7 @@ INSTANTIATE_TEST_SUITE_P(
PageRank_Usecase{0.0, true},
PageRank_Usecase{0.5, true}),
::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"),
cugraph::test::File_Usecase("test/datasets/web-Google.mtx"),
cugraph::test::File_Usecase("test/datasets/ljournal-2008.mtx"),
cugraph::test::File_Usecase("test/datasets/webbase-1M.mtx"))));
cugraph::test::File_Usecase("test/datasets/dolphins.mtx"))));

INSTANTIATE_TEST_SUITE_P(
rmat_small_test,
Expand All @@ -457,6 +452,21 @@ INSTANTIATE_TEST_SUITE_P(
PageRank_Usecase{0.5, true}),
::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, false, 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_PageRank_File,
::testing::Combine(
// disable correctness checks
::testing::Values(PageRank_Usecase{0.0, false, false},
PageRank_Usecase{0.5, false, false},
PageRank_Usecase{0.0, true, false},
PageRank_Usecase{0.5, true, 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
Expand All @@ -470,6 +480,6 @@ INSTANTIATE_TEST_SUITE_P(
PageRank_Usecase{0.5, false, false},
PageRank_Usecase{0.0, true, false},
PageRank_Usecase{0.5, true, false}),
::testing::Values(cugraph::test::Rmat_Usecase(20, 32, 0.57, 0.19, 0.19, 0, false, false))));
::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, false, false))));

CUGRAPH_TEST_PROGRAM_MAIN()
50 changes: 27 additions & 23 deletions cpp/tests/structure/coarsen_graph_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -239,10 +239,11 @@ class Tests_CoarsenGraph
virtual void TearDown() {}

template <typename vertex_t, typename edge_t, typename weight_t, bool store_transposed>
void run_current_test(CoarsenGraph_Usecase const& coarsen_graph_usecase,
input_usecase_t const& input_usecase)
void run_current_test(
std::tuple<CoarsenGraph_Usecase const&, input_usecase_t const&> const& param)
{
constexpr bool renumber = true;
constexpr bool renumber = true;
auto [coarsen_graph_usecase, input_usecase] = param;

raft::handle_t handle{};
HighResClock hr_clock{};
Expand Down Expand Up @@ -371,56 +372,50 @@ using Tests_CoarsenGraph_Rmat = Tests_CoarsenGraph<cugraph::test::Rmat_Usecase>;

TEST_P(Tests_CoarsenGraph_File, CheckInt32Int32FloatTransposeFalse)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float, false>(std::get<0>(param), std::get<1>(param));
run_current_test<int32_t, int32_t, float, false>(
override_File_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_CoarsenGraph_File, CheckInt32Int32FloatTransposeTrue)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float, true>(std::get<0>(param), std::get<1>(param));
run_current_test<int32_t, int32_t, float, true>(
override_File_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_CoarsenGraph_Rmat, CheckInt32Int32FloatTransposeFalse)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float, false>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_CoarsenGraph_Rmat, CheckInt32Int32FloatTransposeTrue)
{
auto param = GetParam();
run_current_test<int32_t, int32_t, float, true>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_CoarsenGraph_Rmat, CheckInt32Int64FloatTransposeFalse)
{
auto param = GetParam();
run_current_test<int32_t, int64_t, float, false>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_CoarsenGraph_Rmat, CheckInt32Int64FloatTransposeTrue)
{
auto param = GetParam();
run_current_test<int32_t, int64_t, float, true>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_CoarsenGraph_Rmat, CheckInt64Int64FloatTransposeFalse)
{
auto param = GetParam();
run_current_test<int64_t, int64_t, float, false>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

TEST_P(Tests_CoarsenGraph_Rmat, CheckInt64Int64FloatTransposeTrue)
{
auto param = GetParam();
run_current_test<int64_t, int64_t, float, true>(
std::get<0>(param), override_Rmat_Usecase_with_cmd_line_arguments(std::get<1>(param)));
override_Rmat_Usecase_with_cmd_line_arguments(GetParam()));
}

INSTANTIATE_TEST_SUITE_P(
Expand All @@ -430,9 +425,7 @@ INSTANTIATE_TEST_SUITE_P(
// enable correctness check
::testing::Values(CoarsenGraph_Usecase{0.2, false}, CoarsenGraph_Usecase{0.2, true}),
::testing::Values(cugraph::test::File_Usecase("test/datasets/karate.mtx"),
cugraph::test::File_Usecase("test/datasets/web-Google.mtx"),
cugraph::test::File_Usecase("test/datasets/ljournal-2008.mtx"),
cugraph::test::File_Usecase("test/datasets/webbase-1M.mtx"))));
cugraph::test::File_Usecase("test/datasets/dolphins.mtx"))));

INSTANTIATE_TEST_SUITE_P(
rmat_small_test,
Expand All @@ -442,6 +435,17 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(CoarsenGraph_Usecase{0.2, false}, CoarsenGraph_Usecase{0.2, true}),
::testing::Values(cugraph::test::Rmat_Usecase(10, 16, 0.57, 0.19, 0.19, 0, false, 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_CoarsenGraph_File,
::testing::Combine(::testing::Values(CoarsenGraph_Usecase{0.2, false, false},
CoarsenGraph_Usecase{0.2, true, 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
Expand Down
Loading

0 comments on commit c49f049

Please sign in to comment.