-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for Kokkos::Array #6372
Fixes for Kokkos::Array #6372
Conversation
Code looks fine, compilers are being silly about |
@PhilMiller sigh. I had addressed that for clang, but not gcc. Anyway, fixed. |
You've still got some CUDA and HIP build failures in Jenkins. |
Testing fix now... |
The OpenMPTarget failure is noise. The CUDA-Clang failure seems to be from the compiler thinking that |
core/unit_test/TestArrayOps.hpp
Outdated
#if defined(__clang__) | ||
if constexpr (std::is_integral_v<__int128>) { | ||
auto i128 = static_cast<__int128>(index); | ||
ASSERT_EQ(a[i128], a[index]); | ||
ASSERT_EQ(ca[i128], a[index]); | ||
|
||
auto u128 = static_cast<unsigned __int128>(index); | ||
ASSERT_EQ(a[u128], a[index]); | ||
ASSERT_EQ(ca[u128], a[index]); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use or test __int128
anywhere else in Kokkos
. Why do you care about it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to have a complete set of is_integral
tests, as that is what the functions are currently templated on. This is a publicly available class, so it should work with compilers that consider __int128
to be an integral type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just drop it. __int128
isn't portable anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@@ -199,7 +199,7 @@ struct Array<T, KOKKOS_INVALID_INDEX, Array<>::contiguous> { | |||
using const_pointer = std::add_const_t<T>*; | |||
|
|||
KOKKOS_INLINE_FUNCTION constexpr size_type size() const { return m_size; } | |||
KOKKOS_INLINE_FUNCTION constexpr bool empty() const { return 0 != m_size; } | |||
KOKKOS_INLINE_FUNCTION constexpr bool empty() const { return 0 == m_size; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that this didn't cause any problem elsewhere. Was it just never used or never tested before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely never tested before. Calling empty()
only makes sense in either generic code or with data structures whose size is determined at run time. The latter is only true for the Proxy
partial specialisations of Kokkos::Array
.
I suspect no one uses Kokkos::Array<T, KOKKOS_INVALID_INDEX, Proxy>
directly. As I state in Issue #6355, it has very unusual semantics (unlike Kokkos::Array<T, N>
) as it is non-owning with weird (and untested until now) semantics for assignment.
Until now, I thought clang considered |
0a13e4a
to
f957041
Compare
core/unit_test/TestArrayOps.hpp
Outdated
#if defined(__clang__) | ||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wchar-subscripts" | ||
#endif | ||
|
||
#if defined(__GNUC__) && !defined(__clang__) | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wchar-subscripts" | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we bother with accesses with all integral types known to men?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to eventually change it to is_convertible_v<T, size_t>
(which is closer to how std::array
works). Because it has been around a long time, I don't feel comfortable making that change w/o a full set of tests to make sure nothing is missing or generates other warnings.
std::array
just uses size_t
. I'm assuming the is_integral
was used in Array
to eliminate compiler warnings that the implicit conversion sometimes generates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could array_element_access
test be wrapped into a type-parametrized test?
https://github.com/google/googletest/blob/main/docs/advanced.md#type-parameterized-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I couldn't resist and tried to rewrite it on my own. Consider cz4rs@be291da, which would produce following test output:
Note: Google Test filter = *ArrayOpsTest*
[==========] Running 24 tests from 12 test suites.
[----------] Global test environment set-up.
[----------] 2 tests from serial/ArrayOpsTest/0, where TypeParam = signed char
[ RUN ] serial/ArrayOpsTest/0.array_element_access
[ OK ] serial/ArrayOpsTest/0.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/0.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/0.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/0 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/1, where TypeParam = unsigned char
[ RUN ] serial/ArrayOpsTest/1.array_element_access
[ OK ] serial/ArrayOpsTest/1.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/1.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/1.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/1 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/2, where TypeParam = short
[ RUN ] serial/ArrayOpsTest/2.array_element_access
[ OK ] serial/ArrayOpsTest/2.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/2.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/2.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/2 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/3, where TypeParam = unsigned short
[ RUN ] serial/ArrayOpsTest/3.array_element_access
[ OK ] serial/ArrayOpsTest/3.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/3.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/3.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/3 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/4, where TypeParam = int
[ RUN ] serial/ArrayOpsTest/4.array_element_access
[ OK ] serial/ArrayOpsTest/4.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/4.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/4.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/4 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/5, where TypeParam = unsigned int
[ RUN ] serial/ArrayOpsTest/5.array_element_access
[ OK ] serial/ArrayOpsTest/5.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/5.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/5.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/5 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/6, where TypeParam = long
[ RUN ] serial/ArrayOpsTest/6.array_element_access
[ OK ] serial/ArrayOpsTest/6.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/6.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/6.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/6 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/7, where TypeParam = unsigned long
[ RUN ] serial/ArrayOpsTest/7.array_element_access
[ OK ] serial/ArrayOpsTest/7.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/7.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/7.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/7 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/8, where TypeParam = long long
[ RUN ] serial/ArrayOpsTest/8.array_element_access
[ OK ] serial/ArrayOpsTest/8.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/8.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/8.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/8 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/9, where TypeParam = unsigned long long
[ RUN ] serial/ArrayOpsTest/9.array_element_access
[ OK ] serial/ArrayOpsTest/9.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/9.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/9.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/9 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/10, where TypeParam = (anonymous namespace)::Enum
[ RUN ] serial/ArrayOpsTest/10.array_element_access
[ OK ] serial/ArrayOpsTest/10.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/10.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/10.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/10 (0 ms total)
[----------] 2 tests from serial/ArrayOpsTest/11, where TypeParam = (anonymous namespace)::EnumShort
[ RUN ] serial/ArrayOpsTest/11.array_element_access
[ OK ] serial/ArrayOpsTest/11.array_element_access (0 ms)
[ RUN ] serial/ArrayOpsTest/11.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/11.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/11 (0 ms total)
[----------] Global test environment tear-down
[==========] 24 tests from 12 test suites ran. (0 ms total)
[ PASSED ] 24 tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting...
The error messages look fine as well (as they show what TypeParam
is on the FAILED line:
[----------] 2 tests from serial/ArrayOpsTest/0, where TypeParam = signed char
[ RUN ] serial/ArrayOpsTest/0.array_element_access
/Users/nliber/git/github.com/kokkos/kokkos-array/core/unit_test/TestArrayOps.hpp:48: Failure
Expected: (a[cast_index]) != (a[index]), actual: 5 vs 5
[ FAILED ] serial/ArrayOpsTest/0.array_element_access, where TypeParam = signed char (0 ms)
[ RUN ] serial/ArrayOpsTest/0.array_contiguous_element_access
[ OK ] serial/ArrayOpsTest/0.array_contiguous_element_access (0 ms)
[----------] 2 tests from serial/ArrayOpsTest/0 (0 ms total)
That was my concern with using C++ templates for these tests (if you don't get the template parameter name when the test fails, it is hard to track down what actually broke), but this looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, some of the GoogleTest macros involved with the type parameterized tests don't work across our compiler suite. Reverting...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I've never tried to do full CI run :| In that case I think this test is good as it is.
pointer(0), as this eliminates some compiler warnings
(left unsigned char and signed char, as uint8_t and int8_t are sometimes aliases for them) Changed EnumBool to EnumShort as it is slightly more realistic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Timeouts HIP builds and SYCL build |
Make sure you update the 4.2 changelog |
(Part of issue #6355)
This P/R contains fixes for
Kokkos::Array<T, KOKKOS_INVALID_INDEX, Kokkos::Array<>::contiguous>::empty()
Kokkos::Array<T, KOKKOS_INVALID_INDEX, Kokkos::Array<>::strided>::empty()
Kokkos::Array<T, KOKKOS_INVALID_INDEX, Kokkos::Array<>::strided>::operator=(...)
As well as unit tests for the above and the rest of
Kokkos::Array
.Added 2023-Aug-23:
Changed the return value for
Kokkos::Array<T, 0>::data()
frompointer(0)
tonullptr
. Technically this wasn't a bug, but it did trigger warnings under some builds.