cuda::experimental::stf::exec_place_host#

class exec_place_host : public cuda::experimental::stf::exec_place#

Designates execution that is to run on the host.

Public Functions

inline ::std::shared_ptr<impl> make()#
inline bool operator==(const exec_place &rhs) const#
inline bool operator!=(const exec_place &rhs) const#
inline bool operator<(const exec_place &rhs) const#
inline bool operator>(const exec_place &rhs) const#
inline bool operator<=(const exec_place &rhs) const#
inline bool operator>=(const exec_place &rhs) const#
inline size_t hash() const#

Compute a hash value for this execution place.

Used by std::hash specialization for unordered containers.

inline iterator begin()#
inline iterator end()#
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(bool for_computation) const#
inline decorated_stream getStream(bool for_computation) const#

Get a decorated stream from the stream pool associated to this execution place.

inline cudaStream_t create_stream() const#

Create a stream valid for execution on this place.

Call only when the place is already activated (e.g. inside exec_place_guard). For getting a stream from the pool, use getStream() / pick_stream() instead.

Returns:

A CUDA stream valid for this execution place

inline cudaStream_t pick_stream(bool for_computation = true) const#
inline const ::std::shared_ptr<impl> &get_impl() const#
inline exec_place activate() const#

Set computation to run on this place.

Returns:

exec_place The previous execution place. See deactivate below.

inline void deactivate(const exec_place &p) const#

Undoes the effect of activate.

Call with the previous exec_place object returned by activate.

Warning

Undefined behavior if you don’t pass the result of activate.

inline bool is_host() const#
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#
inline dim4 grid_dims() const#
template<typename ...Args>
auto partition_by_scope(Args&&... args)#
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_host host()#
static inline exec_place device_auto()#
static inline exec_place device(int devid)#
static inline exec_place green_ctx(
const green_ctx_view &gc_view,
bool use_green_ctx_data_place = false
)#

Create a green context execution place.

Parameters:
  • gc_view – The green context view

  • use_green_ctx_data_place – If true, use a green context data place as the affine data place. If false (default), use a regular device data place instead.

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:

exec_place

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)#

Creates a grid by replicating an execution place multiple times.

class impl : public cuda::experimental::stf::exec_place::impl#

Public Functions

inline impl()#
inline virtual exec_place activate() const override#
inline virtual void deactivate(const exec_place &p) const override#
inline virtual const data_place affine_data_place() const override#
inline virtual stream_pool &get_stream_pool(
bool for_computation
) const override#

Get the stream pool for this execution place.

The base implementation returns pool_compute or pool_data stored directly on the impl.

inline ::std::string to_string() const#
inline virtual bool is_host() 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 bool operator==(const impl &rhs) const#
inline bool operator!=(const impl &rhs) const#
inline virtual size_t hash() const#
inline virtual bool operator<(const impl &rhs) const#
inline cudaStream_t create_stream() const#

Create a stream valid for execution on this place.

Expected to be called with this exec place already activated (e.g. from stream_pool::next(place) which uses exec_place_guard). Creates a new stream in the current context via cudaStreamCreateWithFlags(…, cudaStreamNonBlocking). The caller (e.g. stream_pool::next) builds a decorated_stream from the result.

Public Static Attributes

static constexpr size_t pool_size = 4#
static constexpr size_t data_pool_size = 4#