Skip to content
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
26 changes: 26 additions & 0 deletions projects/rocrand/library/include/rocrand/rocrand_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@
#define ROCRAND_DEPRECATED(msg)
#endif

// This is an accessor macro for HIP vector types (eg. int2, float4, etc.).
// Prior to HIP 7.0, individual elements could be accessed through the
// data member:
//
// int2 vec;
// vec.data[0] = 1;
//
// Beginning with HIP 7.0, the data member is hidden, and individual
// elements must be accessed like this:
//
// int2 vec;
// vec[0] = 1;
//
// You can use the macro like this:
//
// int2 vec;
// ROCRAND_HIPVEC_ACCESS(vec)[0];
//
#if defined(__HIP_PLATFORM_AMD__)
#if HIP_VERSION_MAJOR < 7
#define ROCRAND_HIPVEC_ACCESS(x) x.data
#else
#define ROCRAND_HIPVEC_ACCESS(x) x
#endif
#endif

namespace rocrand_device {
namespace detail {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class philox4x32_10_engine
__forceinline__ __device__ __host__ unsigned int next()
{
#if defined(__HIP_PLATFORM_AMD__)
unsigned int ret = m_state.result.data[m_state.substate];
unsigned int ret = ROCRAND_HIPVEC_ACCESS(m_state.result)[m_state.substate];
#else
unsigned int ret = (&m_state.result.x)[m_state.substate];
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class threefry_engine2_base
__forceinline__ __device__ __host__ value next()
{
#if defined(__HIP_PLATFORM_AMD__)
value ret = m_state.result.data[m_state.substate];
value ret = ROCRAND_HIPVEC_ACCESS(m_state.result)[m_state.substate];
#else
value ret = (&m_state.result.x)[m_state.substate];
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class threefry_engine4_base
__forceinline__ __device__ __host__ value next()
{
#if defined(__HIP_PLATFORM_AMD__)
value ret = m_state.result.data[m_state.substate];
value ret = ROCRAND_HIPVEC_ACCESS(m_state.result)[m_state.substate];
#else
value ret = (&m_state.result.x)[m_state.substate];
#endif
Expand Down