Skip to content

Commit

Permalink
Import sycl::bit_cast into the Kokkos namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
masterleinad committed May 10, 2023
1 parent c62a42e commit 1bc1a51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/Kokkos_BitManipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ inline constexpr bool is_standard_unsigned_integer_type_v =
namespace Kokkos {

//<editor-fold desc="[bit.cast], bit_cast">
// FIXME_SYCL intel/llvm has unqualified calls to bit_cast which are ambiguous
// if we declare our own bit_cast function
#ifdef KOKKOS_ENABLE_SYCL
using sycl::bit_cast;
#else
template <class To, class From>
KOKKOS_FUNCTION std::enable_if_t<sizeof(To) == sizeof(From) &&
std::is_trivially_copyable_v<To> &&
Expand All @@ -110,6 +115,7 @@ bit_cast(From const& from) noexcept {
memcpy(&to, &from, sizeof(To));
return to;
}
#endif
//</editor-fold>

//<editor-fold desc="[bit.byteswap], byteswap">
Expand Down
3 changes: 3 additions & 0 deletions core/unit_test/TestBitManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ constexpr X test_bit_cast(...) {
return {};
}

// FIXME_SYCL The SYCL implementation is unconstrained
#ifndef KOKKOS_ENABLE_SYCL
namespace TypesNotTheSameSize {
struct To {
char a;
Expand Down Expand Up @@ -532,6 +534,7 @@ struct From {
};
static_assert(test_bit_cast<To, From>().did_not_match());
} // namespace FromNotTriviallyCopyable
#endif

namespace ReturnTypeIllFormed {
struct From {
Expand Down

0 comments on commit 1bc1a51

Please sign in to comment.