cuda::experimental::stf::exec_place_guard#

class exec_place_guard#

RAII guard that activates an execution place and restores the previous one on destruction.

This class provides a scoped mechanism for temporarily switching the active execution place. When constructed, it activates the given execution place (e.g., sets the current CUDA device). When destroyed, it restores the previous execution place that was active before construction.

The guard is non-copyable and non-movable to ensure proper RAII semantics.

Example usage:

// Assume current device is 0
{
  exec_place_guard guard(exec_place::device(1));
  // Device 1 is now active
  // ... perform operations on device 1 ...
}
// Device 0 is restored

Note

This class only accepts exec_place objects. Implicit conversions from other types (such as data_place) are explicitly disabled to prevent accidental misuse.

Public Functions

inline explicit exec_place_guard(exec_place place)#

Constructs the guard and activates the given execution place.

Parameters:

place – The execution place to activate. Must be an exec_place object; implicit conversions from other types are disabled.

inline ~exec_place_guard()#

Destructor that restores the previous execution place.

exec_place_guard(const exec_place_guard&) = delete#
exec_place_guard &operator=(const exec_place_guard&) = delete#
exec_place_guard(exec_place_guard&&) = delete#
exec_place_guard &operator=(exec_place_guard&&) = delete#
template<typename T, typename = ::std::enable_if_t<!::std::is_same_v<::std::decay_t<T>, exec_place> && !::std::is_base_of_v<exec_place, ::std::decay_t<T>>>>
inline exec_place_guard(
T&&
)#