Eigen::internal::NormalRandomGenerator< T > Class Template Reference

#include <TensorRandom.h>

Public Member Functions

EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NormalRandomGenerator (uint64_t seed=0)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE NormalRandomGenerator (const NormalRandomGenerator &other)
 
template<typename Index >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator() (Index i) const
 
template<typename Packet , typename Index >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp (Index i) const
 

Static Public Attributes

static constexpr bool PacketAccess = true
 

Private Attributes

uint64_t m_state
 

Constructor & Destructor Documentation

◆ NormalRandomGenerator() [1/2]

234  {
235  m_state = PCG_XSH_RS_state(seed);
236 #ifdef EIGEN_USE_SYCL
237  // In SYCL it is not possible to build PCG_XSH_RS_state in one step.
238  // Therefore, we need two steps to initializate the m_state.
239  // IN SYCL, the constructor of the functor is s called on the CPU
240  // and we get the clock seed here from the CPU. However, This seed is
241  // the same for all the thread. As unlike CUDA, the thread.ID, BlockID, etc is not a global function.
242  // and only available on the Operator() function (which is called on the GPU).
243  // Therefore, the thread Id injection is not available at this stage. However when the operator()
244  // is called the thread ID will be available. So inside the operator,
245  // we add the thrreadID, BlockId,... (which is equivalent of i)
246  // to the seed and construct the unique m_state per thead similar to cuda.
247  m_exec_once = false;
248 #endif
249  }
uint64_t m_state
Definition: TensorRandom.h:289
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE uint64_t PCG_XSH_RS_state(uint64_t seed)
Definition: TensorRandom.h:41

References Eigen::internal::NormalRandomGenerator< T >::m_state, and Eigen::internal::PCG_XSH_RS_state().

◆ NormalRandomGenerator() [2/2]

250  {
251  m_state = other.m_state;
252 #ifdef EIGEN_USE_SYCL
253  m_exec_once = other.m_exec_once;
254 #endif
255  }

References Eigen::internal::NormalRandomGenerator< T >::m_state.

Member Function Documentation

◆ operator()()

template<typename T >
template<typename Index >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T Eigen::internal::NormalRandomGenerator< T >::operator() ( Index  i) const
inline
258  {
259 #ifdef EIGEN_USE_SYCL
260  if (!m_exec_once) {
261  // This is the second stage of adding thread Id to the CPU clock seed and build unique seed per thread
262  m_state += (i * 6364136223846793005ULL);
263  m_exec_once = true;
264  }
265 #endif
266  T result = RandomToTypeNormal<T>(&m_state, i);
267  return result;
268  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9

References i, and Eigen::internal::NormalRandomGenerator< T >::m_state.

◆ packetOp()

template<typename T >
template<typename Packet , typename Index >
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet Eigen::internal::NormalRandomGenerator< T >::packetOp ( Index  i) const
inline
271  {
272  const int packetSize = internal::unpacket_traits<Packet>::size;
273  EIGEN_ALIGN_MAX T values[packetSize];
274 #ifdef EIGEN_USE_SYCL
275  if (!m_exec_once) {
276  // This is the second stage of adding thread Id to the CPU clock seed and build unique seed per thread
277  m_state += (i * 6364136223846793005ULL);
278  m_exec_once = true;
279  }
280 #endif
282  for (int j = 0; j < packetSize; ++j) {
283  values[j] = RandomToTypeNormal<T>(&m_state, i);
284  }
285  return internal::pload<Packet>(values);
286  }
#define EIGEN_ALIGN_MAX
Definition: ConfigureVectorization.h:146
#define EIGEN_UNROLL_LOOP
Definition: Macros.h:1298
@ size
Definition: GenericPacketMath.h:139
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References EIGEN_ALIGN_MAX, EIGEN_UNROLL_LOOP, i, j, and Eigen::internal::NormalRandomGenerator< T >::m_state.

Member Data Documentation

◆ m_state

◆ PacketAccess

template<typename T >
constexpr bool Eigen::internal::NormalRandomGenerator< T >::PacketAccess = true
staticconstexpr

The documentation for this class was generated from the following file: