Container for a single object of type T in device memory. More...
#include <device_scalar.hpp>
Public Types | |
| using | value_type = typename device_uvector<T>::value_type |
| T, the type of the scalar element. | |
| using | size_type = typename device_uvector<T>::size_type |
| The type used for the size. | |
| using | reference = typename device_uvector<T>::reference |
| value_type& | |
| using | const_reference = typename device_uvector<T>::const_reference |
| const value_type& | |
| using | pointer |
| The type of the pointer returned by data(). | |
| using | const_pointer = typename device_uvector<T>::const_pointer |
Public Member Functions | |
| device_scalar (device_scalar &&) noexcept=default | |
| Default move constructor. | |
| device_scalar & | operator= (device_scalar &&) noexcept=default |
| Default move assignment operator. | |
| device_scalar (device_scalar const &)=delete | |
| Copy ctor is deleted as it doesn't allow a stream argument. | |
| device_scalar & | operator= (device_scalar const &)=delete |
| Copy assignment is deleted as it doesn't allow a stream argument. | |
| device_scalar ()=delete | |
| Default constructor is deleted as it doesn't allow a stream argument. | |
| device_scalar (cuda::stream_ref stream, cuda::mr::any_resource< cuda::mr::device_accessible > mr=mr::get_current_device_resource_ref()) | |
| Construct a new uninitialized device_scalar. | |
| device_scalar (value_type const &initial_value, cuda::stream_ref stream, cuda::mr::any_resource< cuda::mr::device_accessible > mr=mr::get_current_device_resource_ref()) | |
| Construct a new device_scalar with an initial value. | |
| device_scalar (value_type const &&, cuda::stream_ref stream, cuda::mr::any_resource< cuda::mr::device_accessible > mr=mr::get_current_device_resource_ref())=delete | |
| device_scalar (device_scalar const &other, cuda::stream_ref stream, cuda::mr::any_resource< cuda::mr::device_accessible > mr=mr::get_current_device_resource_ref()) | |
| Construct a new device_scalar by deep copying the contents of another device_scalar, using the specified stream and memory resource. | |
| value_type | value (cuda::stream_ref stream) const |
| Copies the value from device to host, synchronizes, and returns the value. | |
| void | set_value_async (value_type const &value, cuda::stream_ref stream) |
| Sets the value of the device_scalar to the value of v. | |
| void | set_value_async (value_type const &&, cuda::stream_ref)=delete |
| void | set_value_to_zero_async (cuda::stream_ref stream) |
| Sets the value of the device_scalar to zero on the specified stream. | |
| pointer | data () noexcept |
| Returns pointer to object in device memory. | |
| const_pointer | data () const noexcept |
| Returns const pointer to object in device memory. | |
| constexpr size_type | size () const noexcept |
| The size of the scalar: always 1. | |
| cuda::stream_ref | stream () const noexcept |
| Stream associated with the device memory allocation. | |
| void | set_stream (cuda::stream_ref stream) noexcept |
| Sets the stream to be used for deallocation. | |
Container for a single object of type T in device memory.
T must be trivially copyable.
| T | The object's type |
| using rmm::device_scalar< T >::const_pointer = typename device_uvector<T>::const_pointer |
The type of the iterator returned by data() const
| using rmm::device_scalar< T >::pointer |
The type of the pointer returned by data().
|
inlineexplicit |
Construct a new uninitialized device_scalar.
Does not synchronize the stream.
| rmm::bad_alloc | if allocating the device memory fails. |
| stream | Stream on which to perform asynchronous allocation. |
| mr | Optional, resource with which to allocate. |
|
inlineexplicit |
Construct a new device_scalar with an initial value.
Does not synchronize the stream.
| rmm::bad_alloc | if allocating the device memory for initial_value fails. |
| rmm::bad_alloc | If the provided memory resource cannot allocate with alignment to satisfy the alignment requirements of the value type. |
| rmm::cuda_error | if copying initial_value to device memory fails. |
| initial_value | The initial value of the object in device memory. |
| stream | Optional, stream on which to perform allocation and copy. |
| mr | Optional, resource with which to allocate. |
|
inline |
Construct a new device_scalar by deep copying the contents of another device_scalar, using the specified stream and memory resource.
| rmm::bad_alloc | If creating the new allocation fails. |
| rmm::cuda_error | if copying from other fails. |
| other | The device_scalar whose contents will be copied |
| stream | The stream to use for the allocation and copy |
| mr | The resource to use for allocating the new device_scalar |
|
inlinenodiscardnoexcept |
Returns const pointer to object in device memory.
|
inlinenodiscardnoexcept |
Returns pointer to object in device memory.
|
defaultnoexcept |
Default move assignment operator.
|
inlinenoexcept |
Sets the stream to be used for deallocation.
| stream | Stream to be used for deallocation |
|
inline |
Sets the value of the device_scalar to the value of v.
This function does not synchronize stream before returning. Therefore, the object referenced by v should not be destroyed or modified until stream has been synchronized. Otherwise, behavior is undefined.
Example:
| rmm::cuda_error | if copying value to device memory fails. |
| value | The host value which will be copied to device |
| stream | CUDA stream on which to perform the copy |
|
inline |
Sets the value of the device_scalar to zero on the specified stream.
This function does not synchronize stream before returning.
| stream | CUDA stream on which to perform the copy |
|
inlinenodiscardconstexprnoexcept |
The size of the scalar: always 1.
|
inlinenodiscardnoexcept |
Stream associated with the device memory allocation.
|
inlinenodiscard |
Copies the value from device to host, synchronizes, and returns the value.
Synchronizes stream after copying the data from device to host.
| rmm::cuda_error | If the copy fails. |
| rmm::cuda_error | If synchronizing stream fails. |
| stream | CUDA stream on which to perform the copy and synchronize. |