Skip to content

[SYCL] Fix c++14 mode compilation after #6343 #6497

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

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 35 additions & 23 deletions sycl/include/sycl/ext/oneapi/reduction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

#pragma once

#if __cplusplus >= 201703L
// Entire feature is dependent on C++17.

#include <sycl/accessor.hpp>
#include <sycl/atomic.hpp>
#include <sycl/atomic_ref.hpp>
Expand All @@ -23,6 +20,41 @@

#include <tuple>

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace ext {
namespace oneapi {
namespace detail {

/// Base non-template class which is a base class for all reduction
/// implementation classes. It is needed to detect the reduction classes.
class reduction_impl_base {};

/// Predicate returning true if all template type parameters except the last one
/// are reductions.
template <typename FirstT, typename... RestT> struct AreAllButLastReductions {
static constexpr bool value =
std::is_base_of<reduction_impl_base,
std::remove_reference_t<FirstT>>::value &&
AreAllButLastReductions<RestT...>::value;
};

/// Helper specialization of AreAllButLastReductions for one element only.
/// Returns true if the template parameter is not a reduction.
template <typename T> struct AreAllButLastReductions<T> {
static constexpr bool value =
!std::is_base_of<reduction_impl_base, std::remove_reference_t<T>>::value;
};
} // namespace detail
} // namespace oneapi
} // namespace ext
} // namespace sycl
} // __SYCL_INLINE_NAMESPACE(cl)

#if __cplusplus >= 201703L
// Entire feature is dependent on C++17. We still have to make the trait above
// available as queue shortcuts use them unconditionally, including on
// non-reduction path.
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
namespace ext {
Expand Down Expand Up @@ -456,10 +488,6 @@ class reducer<
marray<T, Extent> MValue;
};

/// Base non-template class which is a base class for all reduction
/// implementation classes. It is needed to detect the reduction classes.
class reduction_impl_base {};

/// Templated class for common functionality of all reduction implementation
/// classes.
template <typename T, class BinaryOperation> class reduction_impl_common {
Expand Down Expand Up @@ -713,22 +741,6 @@ class reduction_impl_algo : public reduction_impl_common<T, BinaryOperation> {
/// User's accessor/USM pointer to where the reduction must be written.
RedOutVar MRedOut;
};

/// Predicate returning true if all template type parameters except the last one
/// are reductions.
template <typename FirstT, typename... RestT> struct AreAllButLastReductions {
static constexpr bool value =
std::is_base_of<reduction_impl_base,
std::remove_reference_t<FirstT>>::value &&
AreAllButLastReductions<RestT...>::value;
};

/// Helper specialization of AreAllButLastReductions for one element only.
/// Returns true if the template parameter is not a reduction.
template <typename T> struct AreAllButLastReductions<T> {
static constexpr bool value =
!std::is_base_of<reduction_impl_base, std::remove_reference_t<T>>::value;
};
/// This class encapsulates the reduction variable/accessor,
/// the reduction operator and an optional operator identity.
template <typename T, class BinaryOperation, int Dims, size_t Extent,
Expand Down