Skip to content

Commit

Permalink
reviewer feedback, including overlooked #undef
Browse files Browse the repository at this point in the history
  • Loading branch information
cperkinsintel committed Feb 27, 2024
1 parent 725d175 commit 0c76797
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions sycl/include/sycl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,18 +905,18 @@ template <typename Type, int NumElements> class vec {
// Implement operator [] in the same way for host and device.
// TODO: change host side implementation when underlying type for host side
// will be changed to std::array.
// NOTE: aliasing on bfloat16 may lead to problems if aggressively optimized.
// specializing with noinline to avoid as workaround.
// NOTE: aliasing the incompatible types of bfloat16 may lead to problems if
// aggressively optimized. Specializing with noinline to avoid as workaround.

template <typename T = DataT>
typename std::enable_if<!std::is_same<T, sycl::ext::oneapi::bfloat16>::value,
typename std::enable_if<!std::is_same_v<T, sycl::ext::oneapi::bfloat16>,
const DataT &>::type
operator[](int i) const {
return reinterpret_cast<const DataT *>(&m_Data)[i];
}

template <typename T = DataT>
typename std::enable_if<!std::is_same<T, sycl::ext::oneapi::bfloat16>::value,
typename std::enable_if<!std::is_same_v<T, sycl::ext::oneapi::bfloat16>,
DataT &>::type
operator[](int i) {
return reinterpret_cast<DataT *>(&m_Data)[i];
Expand All @@ -929,19 +929,23 @@ template <typename Type, int NumElements> class vec {
#endif

template <typename T = DataT>
__SYCL_NOINLINE_BF16 typename std::enable_if<
std::is_same<T, sycl::ext::oneapi::bfloat16>::value, const DataT &>::type
operator[](int i) const {
__SYCL_NOINLINE_BF16
typename std::enable_if<std::is_same_v<T, sycl::ext::oneapi::bfloat16>,
const DataT &>::type
operator[](int i) const {
return reinterpret_cast<const DataT *>(&m_Data)[i];
}

template <typename T = DataT>
__SYCL_NOINLINE_BF16 typename std::enable_if<
std::is_same<T, sycl::ext::oneapi::bfloat16>::value, DataT &>::type
operator[](int i) {
__SYCL_NOINLINE_BF16
typename std::enable_if<std::is_same_v<T, sycl::ext::oneapi::bfloat16>,
DataT &>::type
operator[](int i) {
return reinterpret_cast<DataT *>(&m_Data)[i];
}

#undef __SYCL_NOINLINE_BF16

// Begin hi/lo, even/odd, xyzw, and rgba swizzles.
private:
// Indexer used in the swizzles.def
Expand Down

0 comments on commit 0c76797

Please sign in to comment.