|
| 1 | +// @HEADER |
| 2 | +// ***************************************************************************** |
| 3 | +// MueLu: A package for multigrid based preconditioning |
| 4 | +// |
| 5 | +// Copyright 2012 NTESS and the MueLu contributors. |
| 6 | +// SPDX-License-Identifier: BSD-3-Clause |
| 7 | +// ***************************************************************************** |
| 8 | +// @HEADER |
| 9 | + |
| 10 | +#include <Teuchos_UnitTestHarness.hpp> |
| 11 | +#include <Teuchos_Array.hpp> |
| 12 | + |
| 13 | +#include <MueLu_config.hpp> |
| 14 | + |
| 15 | +#include <MueLu_TestHelpers.hpp> |
| 16 | +#include <MueLu_Version.hpp> |
| 17 | + |
| 18 | +#include <MueLu_KokkosTuningInterface.hpp> |
| 19 | + |
| 20 | + |
| 21 | +namespace MueLuTests { |
| 22 | + |
| 23 | +TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(KokkosTuningInterface, Basic, Scalar, LocalOrdinal, GlobalOrdinal, Node) { |
| 24 | +#include <MueLu_UseShortNames.hpp> |
| 25 | + MUELU_TESTING_SET_OSTREAM; |
| 26 | + MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); |
| 27 | + out << "version: " << MueLu::Version() << std::endl; |
| 28 | + RCP<const Teuchos::Comm<int> > comm = TestHelpers::Parameters::getDefaultComm(); |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + // Driver parameters (like you'd actually use) |
| 33 | + Teuchos::ParameterList baseList; |
| 34 | + Teuchos::ParameterList & pL = baseList.sublist("kokkos tuning: muelu parameter mapping"); |
| 35 | + Teuchos::Array<std::string> input_vars(1); input_vars[0] = "Parameter List Item"; |
| 36 | + Teuchos::Array<int> i_range{1,6,1}; |
| 37 | + Teuchos::Array<double> d_range{5.0,50.0,5.0}; |
| 38 | + pL.set("input variables",input_vars); |
| 39 | + pL.sublist("param0").set("muelu parameter","smoother: params||chebyshev: degree"); |
| 40 | + pL.sublist("param0").set("discrete range",i_range); |
| 41 | + pL.sublist("param0").set("initial guess",(int) 1); |
| 42 | + pL.sublist("param1").set("muelu parameter","smoother: params||chebyshev: ratio eigenvalue"); |
| 43 | + pL.sublist("param1").set("continuous range",d_range); |
| 44 | + pL.sublist("param1").set("initial guess",(double) 10.0); |
| 45 | + |
| 46 | + |
| 47 | + // Actually make the interface |
| 48 | + MueLu::KokkosTuningInterface interface(comm); |
| 49 | + interface.SetParameterList(baseList); |
| 50 | + |
| 51 | + // Call the tuner |
| 52 | + size_t kokkos_context_id; |
| 53 | + Kokkos::Tools::Experimental::begin_context(kokkos_context_id); |
| 54 | + Teuchos::ParameterList outputList; |
| 55 | + interface.SetMueLuParameters(kokkos_context_id,outputList); |
| 56 | + Kokkos::Tools::Experimental::end_context(kokkos_context_id); |
| 57 | + |
| 58 | + // Check that the output has the varables set to something |
| 59 | + TEST_EQUALITY(outputList.isSublist("smoother: params"),true); |
| 60 | + TEST_EQUALITY(outputList.sublist("smoother: params").isParameter("chebyshev: degree"),true); |
| 61 | + TEST_EQUALITY(outputList.sublist("smoother: params").isParameter("chebyshev: ratio eigenvalue"),true); |
| 62 | + |
| 63 | + |
| 64 | +} |
| 65 | + |
| 66 | + |
| 67 | +TEUCHOS_UNIT_TEST_TEMPLATE_4_DECL(KokkosTuningInterface, Advanced, Scalar, LocalOrdinal, GlobalOrdinal, Node) { |
| 68 | +#include <MueLu_UseShortNames.hpp> |
| 69 | + MUELU_TESTING_SET_OSTREAM; |
| 70 | + MUELU_TESTING_LIMIT_SCOPE(Scalar, GlobalOrdinal, Node); |
| 71 | + out << "version: " << MueLu::Version() << std::endl; |
| 72 | + |
| 73 | + RCP<const Teuchos::Comm<int> > comm = TestHelpers::Parameters::getDefaultComm(); |
| 74 | + |
| 75 | + RCP<MueLu::KokkosTuningInterface> interface = rcp(new MueLu::KokkosTuningInterface(comm)); |
| 76 | + |
| 77 | + TEST_INEQUALITY(interface, Teuchos::null); |
| 78 | +} |
| 79 | + |
| 80 | + |
| 81 | +#define MUELU_ETI_GROUP(Scalar, LO, GO, Node) \ |
| 82 | + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(KokkosTuningInterface, Basic, Scalar, LO, GO, Node) \ |
| 83 | + TEUCHOS_UNIT_TEST_TEMPLATE_4_INSTANT(KokkosTuningInterface, Advanced, Scalar, LO, GO, Node) |
| 84 | + |
| 85 | + |
| 86 | +#include <MueLu_ETI_4arg.hpp> |
| 87 | + |
| 88 | +} // namespace MueLuTests |
0 commit comments