cuda::experimental::stf::exec_place
Defined in include/cuda/experimental/__stf/places/places.cuh
-
class exec_place
Indicates where a computation takes place (CPU, dev0, dev1, …)
Currently data and computation are together
(devid == int(data_place))
.Subclassed by cuda::experimental::stf::exec_place_cuda_stream, cuda::experimental::stf::exec_place_grid, cuda::experimental::stf::exec_place_host
Public Functions
-
exec_place() = default
-
inline exec_place(const data_place &affine)
-
inline bool operator==(const exec_place &rhs) const
-
inline bool operator!=(const exec_place &rhs) const
-
inline ::std::string to_string() const
Returns a string representation of the execution place object.
- Returns
std::string
-
inline const data_place &affine_data_place() const
Returns the
data_place
naturally associated with this execution place.
-
inline void set_affine_data_place(data_place place)
-
inline stream_pool &get_stream_pool(async_resources_handle &async_resources, bool for_computation) const
-
inline decorated_stream getStream(async_resources_handle &async_resources, bool for_computation) const
-
inline exec_place activate(backend_ctx_untyped &state) const
Set computation to run on this place.
- Returns
exec_place
The previous execution place. Seedeactivate
below.
-
inline void deactivate(backend_ctx_untyped &state, const exec_place &p) const
Undoes the effect of
activate
.Call with the previous
exec_place
object retured byactivate
.Warning
Undefined behavior if you don’t pass the result of
activate
.
-
inline bool is_device() const
-
inline bool is_grid() const
-
inline size_t size() const
-
inline exec_place_grid as_grid() const
-
inline size_t grid_dim(int axid_is) const
-
template<typename Fun>
inline auto operator->*(Fun &&fun) const Execute lambda on this place.
This method accepts a functor, saves the current CUDA device, changes it to the current execution place, invokes the lambda, and finally sets the current device back to the previous one. The last step is taken even if the lambda throws an exception.
- Template Parameters
Fun – A callable entity type
- Parameters
fun – Input functor that will be forwarded and executed
- Returns
auto the result of the executed functor.
Public Static Functions
-
static inline exec_place device(int devid)
-
static inline exec_place_cuda_stream cuda_stream(cudaStream_t stream)
-
static inline exec_place_cuda_stream cuda_stream(const decorated_stream &dstream)
-
static inline exec_place current_device()
Returns the currently active device.
- Returns
-
static inline exec_place_grid all_devices()
-
static inline exec_place_grid n_devices(size_t n, dim4 dims)
-
static inline exec_place_grid n_devices(size_t n)
-
static inline exec_place_grid repeat(const exec_place &e, size_t cnt)
Public Static Attributes
-
static const exec_place_host host = {}
-
static const exec_place device_auto = {data_place::device_auto}
-
class impl
Subclassed by cuda::experimental::stf::exec_place_cuda_stream::impl, cuda::experimental::stf::exec_place_grid::impl, cuda::experimental::stf::exec_place_host::impl
Public Functions
-
impl() = default
-
virtual ~impl() = default
-
inline explicit impl(data_place place)
-
inline virtual exec_place activate(backend_ctx_untyped&) const
-
inline virtual void deactivate(backend_ctx_untyped&, const exec_place &prev) const
-
inline virtual const data_place &affine_data_place() const
-
inline ::std::string to_string() const
-
inline virtual bool is_device() const
-
inline virtual bool is_grid() const
-
inline virtual size_t size() const
-
inline virtual void set_affine_data_place(data_place place)
-
inline virtual stream_pool &get_stream_pool(async_resources_handle &async_resources, bool for_computation) const
-
inline decorated_stream getStream(async_resources_handle &async_resources, bool for_computation) const
Protected Functions
-
inline explicit impl(int devid)
Protected Attributes
-
data_place affine = data_place::invalid
Friends
- friend class exec_place
-
impl() = default
-
class iterator
an iterator class which goes over all subplaces in an exec place.
This is a trivial singleton unless we have a grid of places.
Public Functions
-
inline exec_place operator*()
Implementation deferred because we need the definition of exec_place_grid.
-
inline exec_place operator*()
-
exec_place() = default