Skip to content
Closed
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
15 changes: 9 additions & 6 deletions sycl/include/CL/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ using is_ulongn = typename is_contained<
// ugenlong: unsigned long int, ulongn
template <typename T>
using is_ugenlong =
std::integral_constant<bool, is_contained<T, type_list<cl_ulong>>::value ||
is_ulongn<T>::value>;
std::integral_constant<bool,
is_contained<T, type_list<unsigned long, cl_ulong>>::value ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the comment above, cl_ulong is not ugenlong.

Also I think we should update the logic of ALL traits that are not relying on fixed size types.
We probably don't see these issues now, but we might hit them on some other platforms.
This can be validated by the cross-compilation for the triples, which defines sizes of char != 1, short != 2 and int != 4.

Copy link
Contributor

@v-klochkov v-klochkov Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This though does not relate to Melanie's fix. At least it is some older issue, right?
How about fixing that cl_ulong issue and 'update the logic of ALL traits' separately?

is_ulongn<T>::value>;

// longn: long2, long3, long4, long8, long16
template <typename T>
Expand All @@ -249,8 +250,8 @@ using is_longn = typename is_contained<
// genlong: long int, longn
template <typename T>
using is_genlong =
std::integral_constant<bool, is_contained<T, type_list<cl_long>>::value ||
is_longn<T>::value>;
std::integral_constant<bool,
is_contained<T, type_list<long, cl_long>>::value || is_longn<T>::value>;

// ulonglongn: ulonglong2, ulonglong3, ulonglong4,ulonglong8, ulonglong16
template <typename T>
Expand Down Expand Up @@ -314,7 +315,8 @@ using is_ugeninteger = std::integral_constant<
template <typename T>
using is_sgeninteger = typename is_contained<
T, type_list<cl_char, cl_schar, cl_uchar, cl_short, cl_ushort, cl_int,
cl_uint, cl_long, cl_ulong, longlong, ulonglong>>::type;
cl_uint, cl_long, cl_ulong, long, unsigned long,
longlong, ulonglong>>::type;

// vgeninteger: charn, scharn, ucharn, shortn, ushortn, intn, uintn, longn,
// ulongn, longlongn, ulonglongn
Expand All @@ -329,7 +331,8 @@ using is_vgeninteger = std::integral_constant<
// sigeninteger: char, signed char, short, int, long int, , long long int
template <typename T>
using is_sigeninteger = typename is_contained<
T, type_list<cl_char, cl_schar, cl_short, cl_int, cl_long, longlong>>::type;
T, type_list<cl_char, cl_schar, cl_short, cl_int, cl_long, long,
longlong>>::type;

// sugeninteger: unsigned char, unsigned short, unsigned int, unsigned long
// int, unsigned long long int
Expand Down
31 changes: 31 additions & 0 deletions sycl/test/basic_tests/generic_type_traits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ using d_t = double;

struct v {};

void check_many(void)
{
{
unsigned y = 1;
auto x = cl::sycl::nan(y);
}
{
unsigned long y = 1;
auto x = cl::sycl::nan(y);
}
{
long int y = 1;
auto x = cl::sycl::any(y);
}
{
int y = 1;
auto x = cl::sycl::any(y);
}
}

int main() {
// is_floatn
static_assert(d::is_floatn<s::cl_float4>::value == true, "");
Expand Down Expand Up @@ -54,6 +74,17 @@ int main() {

static_assert(d::is_ugenint<s::cl_uint3>::value == true, "");

static_assert(d::is_ugenlong<unsigned long>::value, "");
static_assert(d::is_genlong<long>::value, "");

static_assert(d::is_sgeninteger<int>::value, "");
static_assert(d::is_sgeninteger<long int>::value, "");
static_assert(d::is_sgeninteger<long long int>::value, "");

static_assert(d::is_sigeninteger<int>::value, "");
static_assert(d::is_sigeninteger<long int>::value, "");
static_assert(d::is_sigeninteger<long long int>::value, "");

// TODO add checks for the following type traits
/*
is_doublen
Expand Down