Skip to content

Commit

Permalink
implement half shuffle via 32 bit impl
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Nov 30, 2024
1 parent 56c0661 commit 2aa59e2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions hip/components/cooperative_groups.hip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,27 @@ class enable_extended_shuffle : public Group {

#undef GKO_ENABLE_SHUFFLE_OPERATION

// hip does not support 16bit shuffle directly
#define GKO_ENABLE_SHUFFLE_OPERATION_HALF(_name, SelectorType) \
__device__ __forceinline__ __half _name(const __half& var, \
SelectorType selector) const \
{ \
uint32 u; \
memcpy(&u, &var, sizeof(__half)); \
u = static_cast<const Group*>(this)->_name(u, selector); \
__half result; \
memcpy(&result, &u, sizeof(__half)); \
return result; \
}

GKO_ENABLE_SHUFFLE_OPERATION_HALF(shfl, int32)
GKO_ENABLE_SHUFFLE_OPERATION_HALF(shfl_up, uint32)
GKO_ENABLE_SHUFFLE_OPERATION_HALF(shfl_down, uint32)
GKO_ENABLE_SHUFFLE_OPERATION_HALF(shfl_xor, int32)

#undef GKO_ENABLE_SHUFFLE_OPERATION_HALF


private:
template <typename ShuffleOperator, typename ValueType,
typename SelectorType>
Expand Down

0 comments on commit 2aa59e2

Please sign in to comment.