Utility types#
Double buffer#
- 
template<class T>
 class double_buffer#
- This class provides an convenient way to do double buffering. - It tracks two versions of the buffer (“current” and “alternate”), which can be accessed with functions of the same name. You can also swap the buffers. - Public Functions - 
__host__ __device__ inline double_buffer()#
- Constructs an empty double buffer object, initializing the buffer pointers to nullptr. 
 - 
__host__ __device__ inline double_buffer(T *current, T *alternate)#
- Contructs a double buffer object using the supplied buffer pointers. - Parameters:
- current – Pointer to the buffer to designate as “current” (in use). 
- alternate – Pointer to the buffer to designate as “alternate” (not in use) 
 
 
 - 
__host__ __device__ inline void swap()#
- Swaps the current and alternate buffers. 
 
- 
__host__ __device__ inline double_buffer()#
Future value#
- 
template<typename T, typename Iter = T*>
 class future_value#
- Allows passing values that are not yet known at launch time as parameters to device algorithms. - Note - It is the users responsibility to ensure that value is available when the algorithm executes. This can be guaranteed with stream dependencies or explicit external synchronization. - int* intermediate_result = nullptr; hipMalloc(reinterpret_cast<void**>(&intermediate_result), sizeof(intermediate_result)); hipLaunchKernelGGL(compute_intermediate, blocks, threads, 0, stream, arg1, arg2, intermediate_result); const auto initial_value = rocprim::future_value<int>{intermediate_result}; rocprim::exclusive_scan(temporary_storage, storage_size, input, output, initial_value, size); hipFree(intermediate_result) - Template Parameters:
- T – 
- Iter – 
 
 - Public Types - Public Functions - 
__host__ __device__ inline explicit future_value(const Iter iter)#
- Constructs a future value. - Parameters:
- iter – An iterator that will point to the value when it becomes available. 
 
 
Key-value pair#
- 
template<class Key_, class Value_>
 struct key_value_pair#
- Convenience struct that allows you to store key-value pairs as a composite entity. - Public Functions - 
__host__ __device__ inline key_value_pair(const key_type key, const value_type value)#
- Constructs a key-value pair using the supplied values. 
 - 
__host__ __device__ inline bool operator!=(const key_value_pair &kvb)#
- Returns true if the given key-value pair is not equal to this one. Otherwise returns false. 
 
- 
__host__ __device__ inline key_value_pair(const key_type key, const value_type value)#
Tuple#
- 
template<class ...Types>
 class tuple#
- Fixed-size collection of heterogeneous values. - See also - std::tuple - Template Parameters:
- Types... – the types (zero or more) of the elements that the tuple stores. 
- Pre:
- For all types in - Types… following operations should not throw exceptions: construction, copy and move assignment, and swapping.
 
 - Public Functions - 
__host__ __device__ inline constexpr tuple() noexcept#
- Default constructor. Performs value-initialization of all elements. - This overload only participates in overload resolution if: - std::is_default_constructible<Ti>::valueis- truefor all- i.
 
 - 
__host__ __device__ inline explicit tuple(const Types&... values)#
- Direct constructor. Initializes each element of the tuple with the corresponding input value. - This overload only participates in overload resolution if: - std::is_copy_constructible<Ti>::valueis- truefor all- i.
 
 - 
template<class ...UTypes>
 __host__ __device__ inline explicit tuple(UTypes&&... values) noexcept#
- Converting constructor. Initializes each element of the tuple with the corresponding value in - rocprim::detail::custom_forward<UTypes>(values).- This overload only participates in overload resolution if: - sizeof...(Types) == sizeof...(UTypes),
- sizeof...(Types) >= 1, and
- std::is_constructible<Ti, Ui&&>::valueis- truefor all- i.
 
 - 
template<class ...UTypes>
 __host__ __device__ inline tuple(const tuple<UTypes...> &other) noexcept#
- Converting copy constructor. Initializes each element of the tuple with the corresponding value from - other.- This overload only participates in overload resolution if: - sizeof...(Types) == sizeof...(UTypes),
- sizeof...(Types) >= 1, and
- std::is_constructible<Ti, Ui&&>::valueis- truefor all- i.
 
 - 
template<class ...UTypes>
 __host__ __device__ inline tuple(tuple<UTypes...> &&other) noexcept#
- Converting move constructor. Initializes each element of the tuple with the corresponding value from - other.- This overload only participates in overload resolution if: - sizeof...(Types) == sizeof...(UTypes),
- sizeof...(Types) >= 1, and
- std::is_constructible<Ti, Ui&&>::valueis- truefor all- i.
 
 - 
__host__ __device__ inline ~tuple() noexcept = default#
- Implicitly-defined destructor. 
 - 
tuple &operator=(const tuple &other) noexcept#
- Copy assignment operator. - Parameters:
- other – tuple to replace the contents of this tuple 
 
 - 
tuple &operator=(tuple &&other) noexcept#
- Move assignment operator. - Parameters:
- other – tuple to replace the contents of this tuple 
 
 - 
template<class ...UTypes>
 tuple &operator=(const tuple<UTypes...> &other) noexcept#
- For all - i, assigns- rocprim::get<i>(other)to- rocprim::get<i>(*this).- Parameters:
- other – tuple to replace the contents of this tuple 
 
 
- 
template<class T>
 class tuple_size#
- Provides access to the number of elements in a tuple as a compile-time constant expression. - tuple_size<T>is undefined for types- Tthat are not tuples.
- 
template<size_t I, class T>
 struct tuple_element#
- Provides compile-time indexed access to the types of the elements of the tuple. - tuple_element<I, T>is undefined for types- Tthat are not tuples.
Uninitialized Array#
- 
template<typename T, unsigned int Count, size_t Alignment = alignof(T)>
 class uninitialized_array#
- Provides indexed & typed access to uninitialized memory. To be used with - ROCPRIM_SHARED_MEMORY- Note - This class should be used to ensure that writes to the uninitialized memory block occur only via placement new. - Note - This class is non-copyable. - Note - The recommended pattern for usage is to first fill the array via calls to - emplace, then read-only via- get_unsafe_array(). Writing to the array reference returned by- get_unsafe_array()should be avoided, if possible.- Note - The value of - AlignmentMUST be a valid alignment for- T.- Template Parameters:
- T – The item type which is provided via the accessors. 
- Count – The number of T items to store. 
- Alignment – The alignment of the backing storage, in bytes. 
 
 - Public Functions - 
__host__ __device__ uninitialized_array(uninitialized_array&&) = default#
- Default move constructor. 
 - 
__host__ __device__ uninitialized_array &operator=(uninitialized_array&&) = default#
- Default move assignment. 
 - 
template<typename ...Args>
 __host__ __device__ inline T &emplace(const unsigned int index, Args&&... args)#
- Constructs a value in-place at the specified array index. - Note - This function calls the constructor of - Twith the specified arguments. If an instance of- T&is passed, the copy constructor is called, whereas in the case of a- T&&, the move constructor is called.- Note - If an object is created at the same index more than once, the old object’s destructor is not called. If - Tis not trivially destructible, the behaviour is undefined.- Template Parameters:
- Args – The types of the argument values. 
- Parameters:
- index – The index in the array where the new object is constructed. 
- args – The arguments to call the constructor with. 
 
- Returns:
- A reference to the newly constructed element.