Skip to content

Commit

Permalink
SYCL: Use sycl::bit_cast from oneAPI 2024.0.0 on (kokkos#6300)
Browse files Browse the repository at this point in the history
* SYCL: Use sycl::bit_cast from oneAPI 2024.0.0 on

* Avoid importing sycl::bit_cast into Kokkos namespace
  • Loading branch information
masterleinad committed Aug 1, 2023
1 parent 78e8a32 commit 23870b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions core/src/Kokkos_BitManipulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ 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
#if defined(KOKKOS_ENABLE_SYCL) && defined(__INTEL_LLVM_COMPILER) && \
__INTEL_LLVM_COMPILER < 20240000
using sycl::detail::bit_cast;
#else
template <class To, class From>
Expand All @@ -111,9 +110,14 @@ KOKKOS_FUNCTION std::enable_if_t<sizeof(To) == sizeof(From) &&
std::is_trivially_copyable_v<From>,
To>
bit_cast(From const& from) noexcept {
#if defined(KOKKOS_ENABLE_SYCL) && defined(__INTEL_LLVM_COMPILER) && \
__INTEL_LLVM_COMPILER >= 20240000
return sycl::bit_cast<To>(from);
#else
To to;
memcpy(&to, &from, sizeof(To));
return to;
#endif
}
#endif
//</editor-fold>
Expand Down
4 changes: 2 additions & 2 deletions core/unit_test/TestBitManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ constexpr X test_bit_cast(...) {
return {};
}

// FIXME_SYCL The SYCL implementation is unconstrained
#ifndef KOKKOS_ENABLE_SYCL
#if !defined(KOKKOS_ENABLE_SYCL) || \
(defined(__INTEL_LLVM_COMPILER) && __INTEL_LLVM_COMPILER >= 20240000)
namespace TypesNotTheSameSize {
struct To {
char a;
Expand Down

0 comments on commit 23870b3

Please sign in to comment.