ClikaRT::StreamOrDevice
class
Header: ClikaRT/compute/stream_or_device.h
A placement argument that accepts either a Stream or a Device, the public "where should this run / where does this live" parameter. A Stream names a lane exactly and is used as given; passing a device's default stream is the explicit opt-in to synchronous execution. A Device names only placement: an operation given a bare device follows the work it reads (a pending input's lane) and otherwise runs on the calling thread's current lane on that device, the ambient placement's stream when a placement scope set one there, otherwise the thread's own asynchronous lane. It is never the device's default stream. Construct it implicitly from either; resolve() collapses it to the concrete Stream a bare device stands for right now. A default-constructed value is unspecified; resolve() then consults the calling thread's ambient placement (see ClikaRT/compute/placement.h) and, when none is set, takes the current lane on the supplied fallback device.
A value type: it holds a copyable Stream handle and/or a Device, so it crosses the ABI by layout; resolve_impl is its one library entry (the placement law lives in the runtime).
Member functions
StreamOrDevice()
StreamOrDevice() noexcept=default
Declared in ClikaRT/compute/stream_or_device.h, line 33
StreamOrDevice(Stream)
StreamOrDevice(Stream stream)
Wrap a specific stream; ops issue onto it, stream-ordered. An explicit stream always wins: a device's default stream passed here runs the work synchronously on the calling thread, on purpose.
Declared in ClikaRT/compute/stream_or_device.h, line 37
StreamOrDevice(Device)
StreamOrDevice(Device device) noexcept
Wrap a device; the work is placed on it and follows its inputs, landing on the calling thread's current lane there when nothing is pending. Never the device's default stream.
Declared in ClikaRT/compute/stream_or_device.h, line 41
has_stream()
bool has_stream() const noexcept
True if an explicit stream was given.
Declared in ClikaRT/compute/stream_or_device.h, line 45
has_device()
bool has_device() const noexcept
True if a bare device (no stream) was given.
Declared in ClikaRT/compute/stream_or_device.h, line 47
is_unspecified()
bool is_unspecified() const noexcept
True if neither a stream nor a device was given.
Declared in ClikaRT/compute/stream_or_device.h, line 49
stream()
const Stream& stream() const
The explicit stream. Call only when has_stream() is true.
Declared in ClikaRT/compute/stream_or_device.h, line 52
device_or()
Device device_or(Device fallback = Device::cpu()) const
The device this placement names: the stream's device, the bare device, or fallback when unspecified.
Declared in ClikaRT/compute/stream_or_device.h, line 56
resolve()
Stream resolve(Device fallback = Device::cpu()) const
Collapse to a concrete Stream: the placement law. A given stream is returned as is (an explicit stream always wins, a device's default stream included: that is the synchronous opt-in). A given device resolves to the calling thread's current lane on it: the ambient placement's stream when a placement scope set one on that device, otherwise the thread's own asynchronous lane there. Unspecified consults the calling thread's ambient placement (ClikaRT/compute/placement.h) first and, when none is set, takes the current lane on fallback. Never a device's default stream on its own. Fails only when the resolved device cannot lease a lane at all (its backend is not loadable, or does not serve the device).
Declared in ClikaRT/compute/stream_or_device.h, line 78