19 #include <rmm/cuda_stream_view.hpp>
20 #include <rmm/device_uvector.hpp>
21 #include <rmm/mr/device/device_memory_resource.hpp>
24 #include <type_traits>
38 static_assert(std::is_trivially_copyable<T>::value,
"Scalar type must be trivially copyable");
40 using value_type =
typename device_uvector<T>::value_type;
41 using reference =
typename device_uvector<T>::reference;
42 using const_reference =
typename device_uvector<T>::const_reference;
43 using pointer =
typename device_uvector<T>::pointer;
44 using const_pointer =
typename device_uvector<T>::const_pointer;
46 RMM_EXEC_CHECK_DISABLE
49 RMM_EXEC_CHECK_DISABLE
107 value_type
const& initial_value,
130 : _storage{other._storage,
stream, mr}
152 return _storage.front_element(
stream);
217 _storage.set_element_to_zero_async(value_type{0},
stream);
228 [[nodiscard]] pointer
data() noexcept {
return static_cast<pointer
>(_storage.data()); }
238 [[nodiscard]] const_pointer
data() const noexcept
240 return static_cast<const_pointer
>(_storage.data());
device_scalar(device_scalar const &other, cuda_stream_view stream, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct a new device_scalar by deep copying the contents of another device_scalar,...
Definition: device_scalar.hpp:127
Management of per-device device_memory_resources.
void set_stream(cuda_stream_view stream) noexcept
Sets the stream to be used for deallocation.
Definition: device_scalar.hpp:251
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:34
An uninitialized vector of elements in device memory.
Definition: device_uvector.hpp:69
device_scalar & operator=(device_scalar const &)=delete
Copy assignment is deleted as it doesn't allow a stream argument.
device_scalar(cuda_stream_view stream, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct a new uninitialized device_scalar.
Definition: device_scalar.hpp:83
pointer data() noexcept
Returns pointer to object in device memory.
Definition: device_scalar.hpp:228
const_pointer data() const noexcept
Returns const pointer to object in device memory.
Definition: device_scalar.hpp:238
device_scalar()=delete
Default constructor is deleted as it doesn't allow a stream argument.
void set_value_async(value_type const &value, cuda_stream_view stream)
Sets the value of the device_scalar to the value of v.
Definition: device_scalar.hpp:192
void set_value_to_zero_async(cuda_stream_view stream)
Sets the value of the device_scalar to zero on the specified stream.
Definition: device_scalar.hpp:215
Container for a single object of type T in device memory.
Definition: device_scalar.hpp:36
value_type value(cuda_stream_view stream) const
Copies the value from device to host, synchronizes, and returns the value.
Definition: device_scalar.hpp:150
cuda_stream_view stream() const noexcept
Returns stream most recently specified for allocation/deallocation.
Definition: device_scalar.hpp:246
Base class for all libcudf device memory allocation.
Definition: device_memory_resource.hpp:82
device_scalar(device_scalar const &)=delete
Copy ctor is deleted as it doesn't allow a stream argument.
device_scalar(value_type const &initial_value, cuda_stream_view stream, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
Construct a new device_scalar with an initial value.
Definition: device_scalar.hpp:106