Debian Codegraph @

packages/muelu/test/unit_tests_kokkos/MueLu_TestHelpers_Common_kokkos.hpp

raw
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 #ifndef MUELU_TEST_HELPERS_COMMON_KOKKOS_HPP
11 #define MUELU_TEST_HELPERS_COMMON_KOKKOS_HPP
12
13 #if 1
14 #define MUELU_DEBUGGER_MACRO \
15 out << "debug: scalar = " << typeid(GO).name() << std::endl; \
16 out << "debug: node = " << typeid(NO).name() << std::endl; \
17 if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) \
18 out << "debug: linAlgebra = Epetra" << std::endl; \
19 else \
20 out << "debug: linAlgebra = Tpetra" << std::endl;
21 #else
22 #define MUELU_DEBUGGER_MACRO
23 #endif
24
25 #define TYPE_EQUAL(TYPE1, TYPE2) \
26 (typeid(TYPE1).name() == typeid(TYPE2).name())
27
28 #ifdef HAVE_MUELU_EPETRA
29
30 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || \
31 (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
32 // <double,int,int,EpetraNode>: run Epetra, do not run Tpetra
33 #define MUELU_TESTING_LIMIT_SCOPE(SC, GO, NO) \
34 MUELU_DEBUGGER_MACRO \
35 if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) { \
36 if (!TYPE_EQUAL(SC, double)) { \
37 out << "Skipping Epetra for SC != double" << std::endl; \
38 return; \
39 } \
40 if (!TYPE_EQUAL(GO, int)) { \
41 out << "Skipping Epetra for GO != int" << std::endl; \
42 return; \
43 } \
44 if (!TYPE_EQUAL(NO, Xpetra::EpetraNode)) { \
45 out << "Skipping Epetra for NO != EpetraNode" << std::endl; \
46 return; \
47 } \
48 } else if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseTpetra) { \
49 if (TYPE_EQUAL(SC, double) && TYPE_EQUAL(GO, int) && TYPE_EQUAL(NO, Xpetra::EpetraNode)) { \
50 out << "Skipping Tpetra for <double, int, EpetraNode>" << std::endl; \
51 return; \
52 } \
53 }
54
55 #define MUELU_TESTING_LIMIT_EPETRA_SCOPE_TPETRA_IS_DEFAULT(SC, GO, NO) \
56 { \
57 out << "Skipping as we cannot run Epetra and Tpetra for the same combination of template args" << std::endl; \
58 return; \
59 }
60
61 #else
62
63 #define MUELU_TESTING_LIMIT_SCOPE(SC, GO, NO) \
64 MUELU_DEBUGGER_MACRO \
65 if (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra) { \
66 if (!TYPE_EQUAL(SC, double)) { \
67 out << "Skipping Epetra for SC != double" << std::endl; \
68 return; \
69 } \
70 if (!TYPE_EQUAL(GO, int)) { \
71 out << "Skipping Epetra for GO != int" << std::endl; \
72 return; \
73 } \
74 if (!TYPE_EQUAL(NO, Xpetra::EpetraNode)) { \
75 out << "Skipping Epetra for NO != EpetraNode" << std::endl; \
76 return; \
77 } \
78 }
79
80 // If linAlgebra==Tpetra, but the test also requires Epetra, this macro will cause the test
81 // to return early if SC!=double, GO!={int}, or NO!=Serial.
82 #define MUELU_TESTING_LIMIT_EPETRA_SCOPE_TPETRA_IS_DEFAULT(SC, GO, NO) \
83 if (!TYPE_EQUAL(SC, double)) { \
84 out << "Skipping Epetra for SC != double" << std::endl; \
85 return; \
86 } \
87 if (!TYPE_EQUAL(GO, int)) { \
88 out << "Skipping Epetra for GO != int" << std::endl; \
89 return; \
90 } \
91 if (!TYPE_EQUAL(NO, Xpetra::EpetraNode)) { \
92 out << "Skipping Epetra for NO != EpetraNode" << std::endl; \
93 return; \
94 }
95 #endif
96
97 #else // HAVE_MUELU_EPETRA
98
99 #define MUELU_TESTING_LIMIT_SCOPE(SC, GO, NO)
100 #define MUELU_TESTING_LIMIT_EPETRA_SCOPE_TPETRA_IS_DEFAULT(SC, GO, NO)
101
102 #endif // HAVE_MUELU_EPETRA
103
104 // Macro to set MueLu's internal oh-so FancyOStream to be the same as the one used by Teuchos' unit testing framework.
105 // This prevents MueLu's output from intermingling with with the unit test pass/fail summary lines.
106 #define MUELU_TESTING_SET_OSTREAM \
107 MueLu::VerboseObject::SetMueLuOStream(Teuchos::fancyOStream(out.getOStream()));
108
109 #define MUELU_TESTING_DO_NOT_TEST(lib, packagesNotEnabled) \
110 if (TestHelpers_kokkos::Parameters::getLib() == lib) { \
111 out << "Skipping test for " << (TestHelpers_kokkos::Parameters::getLib() == Xpetra::UseEpetra ? "Epetra" : "Tpetra") << " because some required packages are not enabled (" << packagesNotEnabled << ")." << std::endl; \
112 return; \
113 }
114
115 #endif // ifndef MUELU_TEST_HELPERS_COMMON_KOKKOS_HPP