13 #ifndef ZOLTAN2_TESTHELPERS_HPP
14 #define ZOLTAN2_TESTHELPERS_HPP
16 #include <Teuchos_UnitTestHarness.hpp>
20 #include <Tpetra_Map.hpp>
25 #define STR_VALUE(path) #path
26 #define PATH_NAME(path) STR_VALUE(path)
67 #include <TpetraCore_config.h>
71 typedef Tpetra::Map<>::local_ordinal_type
zlno_t;
72 typedef Tpetra::Map<>::global_ordinal_type
zgno_t;
74 using Teuchos::compareArrays;
76 #ifdef HAVE_TPETRA_DOUBLE
78 #define HAVE_EPETRA_SCALAR_TYPE
83 #if defined HAVE_TPETRA_INT_INT
84 #if defined HAVE_EPETRA_SCALAR_TYPE
85 #define HAVE_EPETRA_DATA_TYPES
89 #ifndef HAVE_ZOLTAN2_EPETRA
90 #undef HAVE_EPETRA_SCALAR_TYPE
91 #undef HAVE_EPETRA_DATA_TYPES
96 #define MEMORY_CHECK(iPrint, msg) \
98 long kb = Zoltan2::getProcessKilobytes(); \
99 std::cout.width(10); \
100 std::cout.fill('*'); \
101 std::cout << kb << " KB, " << msg << std::endl; \
102 std::cout.width(0); \
103 std::cout.fill(' '); \
106 #define Z2_TEST(TEST) \
108 Teuchos::RCP<Teuchos::FancyOStream> fout = \
109 Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout)); \
111 bool success = true; \
115 out << "Test failed."; \
118 throw std::runtime_error(#TEST " FAIL"); \
122 #define Z2_TEST_THROW(code, ExceptType) Z2_TEST(TEST_THROW(code, ExceptType))
123 #define Z2_TEST_NOTHROW(code) Z2_TEST(TEST_NOTHROW(code))
124 #define Z2_TEST_EQUALITY(val1, val2) Z2_TEST(TEST_EQUALITY(val1, val2))
125 #define Z2_TEST_INEQUALITY(val1, val2) Z2_TEST(TEST_INEQUALITY(val1, val2))
126 #define Z2_TEST_ASSERT(expr) Z2_TEST(TEST_ASSERT(expr))
127 #define Z2_TEST_EQUALITY_CONST(val1, val2) \
128 Z2_TEST(TEST_EQUALITY_CONST(val1, val2))
129 #define Z2_TEST_INEQUALITY_CONST(val1, val2) \
130 Z2_TEST(TEST_INEQUALITY_CONST(val1, val2))
131 #define Z2_TEST_COMPARE(val1, comp, val2) \
132 Z2_TEST(TEST_COMPARE(val1, comp, val2))
133 #define Z2_TEST_COMPARE_ARRAYS(val1, val2) \
134 Z2_TEST(TEST_COMPARE_ARRAYS(val1, val2))
135 #define Z2_TEST_COMPARE_FLOATING_ARRAYS(val1, val2, tol) \
136 Z2_TEST(TEST_COMPARE_FLOATING_ARRAYS(val1, val2, tol))
137 #define Z2_TEST_FLOATING_EQUALITY(val1, val2, tol) \
138 Z2_TEST(TEST_FLOATING_EQUALITY(val1, val2, tol))
141 if (Tpetra::getDefaultComm()->getRank() == 0) {
142 printf(
"%s \n", message.c_str());
146 template <
typename DeviceType,
typename HostType>
148 const HostType &hostView) {
150 for (
int dim = 0; dim <= 2; ++dim) {
154 const auto mirrorDevice = Kokkos::create_mirror_view(deviceView);
155 Kokkos::deep_copy(mirrorDevice, deviceView);
161 #define Z2_TEST_DEVICE_HOST_VIEWS(deviceView, hostView) \
164 for (int dim = 0; dim <= 2; ++dim) { \
165 Z2_TEST_EQUALITY(deviceView.extent(dim), hostView.extent(dim)); \
168 const auto mirrorDevice = Kokkos::create_mirror_view(deviceView); \
169 Kokkos::deep_copy(mirrorDevice, deviceView); \
171 Z2_TEST_COMPARE_ARRAYS(hostView, mirrorDevice); \
void PrintFromRoot(const std::string &message)
#define Z2_TEST_COMPARE_ARRAYS(val1, val2)
void TestDeviceHostView(const DeviceType &deviceView, const HostType &hostView)
#define Z2_TEST_EQUALITY(val1, val2)
Tpetra::Map::local_ordinal_type zlno_t
A gathering of useful namespace methods.
Tpetra::Map::node_type znode_t
Tpetra::Map::global_ordinal_type zgno_t
std::string zoltanTestDirectory(".")
std::string testDataFilePath(".")