Skip to content
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
7 changes: 7 additions & 0 deletions sycl/include/syclcompat/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ inline double cast_ints_to_double(int high32, int low32) {
template <typename T> inline T reverse_bits(T a) {
static_assert(std::is_unsigned<T>::value && std::is_integral<T>::value,
"unsigned integer required");
#if defined(__NVPTX__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you if constexpr(std::is_same_v<T, unsigned> here? Theoretically this API accepts e.g. unsigned short, unsigned char and I guess the PTX wouldn't work for that.

Of course, the ptx for those cases could be defined too, so that'd be an alternative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I've dealt with this using sizeof

if constexpr (sizeof(T) == 4) {
unsigned result;
asm volatile("brev.b32 %0, %1;" : "=r"(result) : "r"(a));
return result;
}
#endif // __NVPTX__
if (!a)
return 0;
T mask = 0;
Expand Down
Loading