Skip to content

Commit

Permalink
Suppress deprecated warnings via pragma push/pop in the tests (kokkos…
Browse files Browse the repository at this point in the history
…#6999)

* Introduce `KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_{PUSH,POP} macros

to suppress diagnostics when appropriate

* Suppress all deprecated warnings I can see in tests

* Update EDG diag suppress to fix the Intel Compiler Classic

and provide a fallback empty definition for the macros
  • Loading branch information
dalg24 committed May 13, 2024
1 parent 1d9d0df commit df018d9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions containers/unit_tests/TestVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <Kokkos_Macros.hpp>
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
#include <Kokkos_Vector.hpp>

namespace Test {
Expand Down
25 changes: 25 additions & 0 deletions core/src/Kokkos_Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,31 @@ static constexpr bool kokkos_omp_on_host() { return false; }
#define KOKKOS_IMPL_WARNING(desc) KOKKOS_IMPL_DO_PRAGMA(message(#desc))
#endif

// clang-format off
#if defined(__EDG__)
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH() \
_Pragma("warning push") \
_Pragma("warning disable 1478")
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP() \
_Pragma("warning pop")
#elif defined(__GNUC__) || defined(__clang__)
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH() \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP() \
_Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH() \
_Pragma("warning(push)") \
_Pragma("warning(disable: 4996)")
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP() \
_Pragma("warning(pop)")
#else
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
#define KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP()
#endif
// clang-format on

#define KOKKOS_ATTRIBUTE_NODISCARD [[nodiscard]]

#if (defined(KOKKOS_COMPILER_GNU) || defined(KOKKOS_COMPILER_CLANG) || \
Expand Down
2 changes: 2 additions & 0 deletions core/unit_test/TestArrayOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ TEST(TEST_CATEGORY, array_zero_data_nullptr) {
}

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
TEST(TEST_CATEGORY, array_contiguous_capacity) {
using A =
Kokkos::Array<int, KOKKOS_INVALID_INDEX, Kokkos::Array<>::contiguous>;
Expand Down Expand Up @@ -390,6 +391,7 @@ TEST(TEST_CATEGORY, array_strided_assignment) {
ASSERT_EQ(e.max_size(), std::size(ee) / eStride);
ASSERT_EQ(e[0], ee[0]);
}
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP()
#endif

} // namespace
2 changes: 2 additions & 0 deletions core/unit_test/incremental/Test01_execspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ struct TestIncrExecSpace {
ASSERT_GT(concurrency, 0);

#ifdef KOKKOS_ENABLE_DEPRECATED_CODE_4
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
int in_parallel = ExecSpace::in_parallel();
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP()
ASSERT_FALSE(in_parallel);
#endif

Expand Down
2 changes: 2 additions & 0 deletions simd/unit_tests/include/SIMDTesting_Ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class absolutes {
auto on_host(T const& a) const {
if constexpr (std::is_signed_v<typename T::value_type>) {
#if defined(KOKKOS_ENABLE_DEPRECATED_CODE_4)
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_PUSH()
return Kokkos::Experimental::abs(a);
KOKKOS_IMPL_DISABLE_DEPRECATED_WARNINGS_POP()
#else
return Kokkos::abs(a);
#endif
Expand Down

0 comments on commit df018d9

Please sign in to comment.