For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo module
range
Mojo Range context manager (MXTOOLS-190).
Range wraps the KGEN_CompilerRT_Range{Begin,End,IsEnabled} FFI bridge from
KGEN/lib/CompilerRT/RangeBridge.cpp. Use it as a context manager to emit a
libkineto activity span: __enter__ opens the span and __exit__ closes it.
The follow-up mo.profile.range MLIR op (tracked in MXTOOLS-190) will lower to
this struct.
Range mirrors std.runtime.tracing.Trace: the span is opened in __enter__
and closed in __exit__ rather than in __init__/__del__. This sidesteps
Mojo's ASAP destruction β a var span = Range(...) whose handle is never read
again would otherwise be destroyed immediately after construction, closing the
span before any work inside it ran. The with statement keeps the object alive
for the full block, so begin/end pair with block entry/exit.
Off-cost matches the C++ M::Profiling::RangeScope: one relaxed atomic load
through the FFI when the profiler is disabled. The _began flag is captured at
__enter__ so a disable() racing with the scope cannot leave a libkineto
span begun without a matching end (mirrors the C++ RAII discipline).
Structsβ
- β
Range: A libkineto activity span recorded via the CompilerRT bridge.
Functionsβ
- β
is_enabled: Reports whether the libkineto profiler is currently enabled.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!