rocPRIM
Public Types | Public Member Functions | List of all members
future_value< T, Iter > Class Template Reference

Allows passing values that are not yet known at launch time as paramters to device algorithms. More...

#include <future_value.hpp>

Public Types

using value_type = T
 The type of the value this future will store.
 
using iterator_type = Iter
 An iterator type that can point at the value_type.
 

Public Member Functions

ROCPRIM_HOST_DEVICE future_value (const Iter iter)
 Constructs a future value. More...
 
ROCPRIM_HOST_DEVICE operator T ()
 Returns the value by dereferencing the iterator that the constructor was passed. More...
 
ROCPRIM_HOST_DEVICE operator T () const
 Returns the value by dereferencing the iterator that the constructor was passed. More...
 

Detailed Description

template<typename T, typename Iter = T*>
class future_value< T, Iter >

Allows passing values that are not yet known at launch time as paramters 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, itermediate_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

Constructor & Destructor Documentation

◆ future_value()

template<typename T , typename Iter = T*>
ROCPRIM_HOST_DEVICE future_value< T, Iter >::future_value ( const Iter  iter)
inlineexplicit

Constructs a future value.

Parameters
iter- An iterator that will point to the value when it becomes available.

Member Function Documentation

◆ operator T() [1/2]

template<typename T , typename Iter = T*>
ROCPRIM_HOST_DEVICE future_value< T, Iter >::operator T ( )
inline

Returns the value by dereferencing the iterator that the constructor was passed.

Note
The value must be available at the point this is called.

◆ operator T() [2/2]

template<typename T , typename Iter = T*>
ROCPRIM_HOST_DEVICE future_value< T, Iter >::operator T ( ) const
inline

Returns the value by dereferencing the iterator that the constructor was passed.

Note
The value must be available at the point this is called.

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