IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

load_volatile

load_volatile[dtype: DType, //, memory: Bool = True](ptr: UnsafePointer[Scalar[dtype], address_space=ptr.address_space]) -> Scalar[dtype]

Performs a volatile load operation that cannot be optimized away.

This function guarantees that the load operation will be performed exactly as specified, without being reordered or optimized away by the compiler.

Note:

  • Only supported on NVIDIA GPUs.
  • Maps directly to PTX ld.volatile instruction.
  • Prevents compiler optimization of the load operation.
  • Useful for memory-mapped I/O or synchronization primitives.
  • May have performance implications compared to regular loads.

Parameters:

  • dtype (DType): The data type to load.
  • memory (Bool): Whether to include memory side effects in constraints (default: True).

Args:

Returns:

Scalar[dtype]: The loaded value.