Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
Eigen::gpu::DeviceScalar< Scalar_ > Class Template Reference

#include <contrib/Eigen/src/GPU/DeviceScalar.h>

Detailed Description

template<typename Scalar_>
class Eigen::gpu::DeviceScalar< Scalar_ >

RAII wrapper for a scalar in GPU device memory.

Public Member Functions

 DeviceScalar (const DeviceScalar &o)
 
 DeviceScalar (cudaStream_t stream=nullptr)
 
Scalar get () const
 
 operator Scalar () const
 
DeviceScalar & operator= (const DeviceScalar &o)
 

Constructor & Destructor Documentation

◆ DeviceScalar() [1/2]

template<typename Scalar_>
Eigen::gpu::DeviceScalar< Scalar_ >::DeviceScalar ( cudaStream_t stream = nullptr)
inlineexplicit

Allocate an uninitialized device scalar. Contents are undefined until written, e.g. by cuBLAS dot/nrm2 under POINTER_MODE_DEVICE.

◆ DeviceScalar() [2/2]

template<typename Scalar_>
Eigen::gpu::DeviceScalar< Scalar_ >::DeviceScalar ( const DeviceScalar< Scalar_ > & o)
inline

Deep copy: a device-to-device cudaMemcpyAsync on the source's stream, no host round trip. Provided so that generic code returning a DeviceScalar by value from a const reference (numext::real in Eigen's iterative solver templates) compiles; explicit code should move instead.

Member Function Documentation

◆ get()

template<typename Scalar_>
Scalar Eigen::gpu::DeviceScalar< Scalar_ >::get ( ) const
inline

Download from device, synchronizing the stream.

◆ operator Scalar()

template<typename Scalar_>
Eigen::gpu::DeviceScalar< Scalar_ >::operator Scalar ( ) const
inline

Implicit conversion, enabling Scalar alpha = deviceScalar and if (deviceScalar < threshold). Triggers a sync.

◆ operator=()

template<typename Scalar_>
DeviceScalar & Eigen::gpu::DeviceScalar< Scalar_ >::operator= ( const DeviceScalar< Scalar_ > & o)
inline

Copy assignment adopts the source's stream. Copy construction followed by a move releases the previous buffer instead of writing into it: a write on the source's stream could race with reads still queued on this scalar's old stream.


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