Skip to content
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

[SYCL] Add value_type alias to sycl::vec class #12960

Merged
merged 7 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion sycl/include/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ template <typename T, typename Enable = void> struct RelConverter {
template <typename T> class TryToGetElementType {
static T check(...);
template <typename A> static typename A::element_type check(const A &);
template <typename A> static typename A::value_type check(const A &);
template <typename A, typename = std::enable_if_t<!std::is_same_v<
typename A::element_type, typename A::value_type>>>
static typename A::value_type check(const A &);

public:
using type = decltype(check(T()));
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ template <typename Type, int NumElements> class vec {

public:
using element_type = DataT;
using value_type = DataT;
using rel_t = detail::rel_t<DataT>;

#ifdef __SYCL_DEVICE_ONLY__
#if defined(__INTEL_PREVIEW_BREAKING_CHANGES)
using vector_t =
Expand Down
11 changes: 11 additions & 0 deletions sycl/test/regression/vec_value_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %clangxx -fsycl -fsyntax-only %s
#include <sycl/sycl.hpp>
#include <type_traits>
using namespace std;
lbushi25 marked this conversation as resolved.
Show resolved Hide resolved
int main() {
static_assert(is_same_v<sycl::vec<int, 1>::value_type, int>);
static_assert(is_same_v<sycl::vec<float, 2>::value_type, float>);
static_assert(is_same_v<sycl::vec<double, 3>::value_type, double>);
static_assert(is_same_v<sycl::vec<sycl::half, 4>::value_type, sycl::half>);
return 0;
}
Loading