Skip to content

Commit

Permalink
Add the Experimental:: builtin variant (just defer to regular bit_cast)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed May 4, 2023
1 parent 71ee48f commit ddf55c1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/Kokkos_BitManipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,15 @@ KOKKOS_IMPL_HOST_FUNCTION

namespace Kokkos::Experimental {

template <class To, class From>
KOKKOS_FUNCTION std::enable_if_t<sizeof(To) == sizeof(From) &&
std::is_trivially_copyable_v<To> &&
std::is_trivially_copyable_v<From>,
To>
bit_cast_builtin(From const& from) noexcept {
return bit_cast<To>(from); // no benefit to call the _builtin variant
}

template <class T>
KOKKOS_FUNCTION std::enable_if_t<std::is_integral_v<T>, T> byteswap_builtin(
T x) noexcept {
Expand Down

0 comments on commit ddf55c1

Please sign in to comment.