From b6940a62b43c8608c4f0c58c88af2972b8310fd3 Mon Sep 17 00:00:00 2001 From: Christian Glusa Date: Tue, 23 Jan 2024 09:21:58 -0700 Subject: [PATCH] MueLu: Add H2D count specifically for aggregation --- .../test/unit_tests_kokkos/Regression.cpp | 60 ++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/packages/muelu/test/unit_tests_kokkos/Regression.cpp b/packages/muelu/test/unit_tests_kokkos/Regression.cpp index 6591f052a579..88d060ce7fca 100644 --- a/packages/muelu/test/unit_tests_kokkos/Regression.cpp +++ b/packages/muelu/test/unit_tests_kokkos/Regression.cpp @@ -57,6 +57,8 @@ #include #include #include +#include +#include #include @@ -137,8 +139,62 @@ TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(Regression, H2D, Scalar, LocalOrdinal, GlobalO } // H2D -#define MUELU_ETI_GROUP(Scalar, LO, GO, Node) \ - TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Regression, H2D, Scalar, LO, GO, Node) +TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(Regression, Aggregration, Scalar, LocalOrdinal, GlobalOrdinal, Node) { +#include + MUELU_TESTING_SET_OSTREAM; + MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); + out << "version: " << MueLu::Version() << std::endl; + RCP > comm = TestHelpers_kokkos::Parameters::getDefaultComm(); + Teuchos::RCP stacked_timer = rcp(new Teuchos::StackedTimer("H2D")); + Teuchos::TimeMonitor::setStackedTimer(stacked_timer); + + // Make a Matrix with multiple degrees of freedom per node + GlobalOrdinal nx = 20, ny = 20; + + // Describes the initial layout of matrix rows across processors. + Teuchos::ParameterList galeriList; + galeriList.set("nx", nx); + galeriList.set("ny", ny); + + using test_factory = TestHelpers_kokkos::TestFactory; + Teuchos::CommandLineProcessor clp(false); + Galeri::Xpetra::Parameters matrixParameters(clp, 8748); // manage parameters of the test case + Xpetra::Parameters xpetraParameters(clp); // manage parameters of xpetra + + RCP A = TestHelpers_kokkos::TestFactory::Build2DPoisson(nx, ny); + + Tpetra::Details::DeepCopyCounter::reset(); + Tpetra::Details::DeepCopyCounter::start(); + + Level aLevel; + TestHelpers_kokkos::TestFactory::createSingleLevelHierarchy(aLevel); + aLevel.Request("A"); + aLevel.Set("A", A); + + RCP dropFact = rcp(new CoalesceDropFactory_kokkos()); + RCP aggFact = rcp(new UncoupledAggregationFactory_kokkos()); + aggFact->SetFactory("Graph", dropFact); + aLevel.Request(*aggFact); + aggFact->Build(aLevel); + + Tpetra::Details::DeepCopyCounter::stop(); + + if (Node::is_cpu) { + TEST_EQUALITY(Tpetra::Details::DeepCopyCounter::get_count_different_space(), 0); + } else { + TEST_EQUALITY(Tpetra::Details::DeepCopyCounter::get_count_different_space(), 23); + } + + stacked_timer->stopBaseTimer(); + Teuchos::StackedTimer::OutputOptions options; + options.output_fraction = options.output_histogram = options.output_minmax = true; + stacked_timer->report(out, comm, options); + +} // Aggregration + +#define MUELU_ETI_GROUP(Scalar, LO, GO, Node) \ + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Regression, H2D, Scalar, LO, GO, Node) \ + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(Regression, Aggregration, Scalar, LO, GO, Node) #include