Skip to content

[ESIMD] Fix is_esimd_arithmetic_type internal problem. #4826

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
Oct 27, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ struct is_esimd_arithmetic_type : std::false_type {};

template <class Ty>
struct is_esimd_arithmetic_type<
Ty, __esimd_void_t<decltype(std::declval<Ty>() + std::declval<Ty>()),
Ty, __esimd_void_t<std::enable_if_t<std::is_arithmetic_v<Ty>>,
decltype(std::declval<Ty>() + std::declval<Ty>()),
decltype(std::declval<Ty>() - std::declval<Ty>()),
decltype(std::declval<Ty>() * std::declval<Ty>()),
decltype(std::declval<Ty>() / std::declval<Ty>())>>
: std::conditional_t<std::is_arithmetic_v<Ty>, std::true_type,
std::false_type> {};
: std::true_type {};

template <typename Ty>
static inline constexpr bool is_esimd_arithmetic_type_v =
Expand Down
31 changes: 31 additions & 0 deletions sycl/test/esimd/regression/is_esimd_arithmetic_type.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s
// expected-no-diagnostics

// Check that is_esimd_arithmetic_type works as expected on simd and simd_view
// types.

#include <sycl/ext/intel/experimental/esimd.hpp>

using namespace sycl::ext::intel::experimental::esimd;

constexpr bool foo0() {
return __SEIEED::is_esimd_arithmetic_type_v<simd<int, 8>>;
}

constexpr bool foo1() {
return __SEIEED::is_esimd_arithmetic_type_v<
simd_view<simd<int, 8>, region1d_t<int, 8, 1>>>;
}

SYCL_EXTERNAL void foo() SYCL_ESIMD_FUNCTION {
static_assert(!foo0() && !foo1(), "");
}

// This models original user code where compilation failure occurred.
// Similar code exists in operators.cpp, but somehow presence of '^='
// operation (commented out below) hid the problem and compiler did not fail.
SYCL_EXTERNAL auto foo2(simd<char, 8> x, simd<char, 8> x1,
simd<char, 8> y) SYCL_ESIMD_FUNCTION {
//{ auto k = x1 ^= x1; }
{ auto v = x ^ y; }
}