Skip to main content

Module runtime_kind

Module runtime_kind 

Source
Expand description

Runtime kind of the host program (async / sync / no-std). Runtime kind of the host program.

Some backend decisions depend not on the device but on how the host program itself is being driven — whether main runs on an asynchronous runtime, a synchronous thread-based runtime, or a restricted no-std environment. This module stores that kind in a process global so backends can read it and adapt their behavior.

The canonical example is tensor readback (into_data): deferring the device→host copy lazily is fine under a sync/threaded runtime (a later blocking read just parks a thread), but under an async runtime the same blocking read parks an executor worker and starves the runtime, so the read must materialize eagerly instead.

Enums§

RuntimeKind
How the host program is being driven.

Functions§

runtime_kind
Return the currently declared kind of runtime the host program runs on.
set_runtime_kind
Declare the kind of runtime the host program is running on.