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

Mojo function

load

def load[dtype: DType, //, width: Int = Int(1), *, read_only: Bool = False, prefetch_size: Optional[Int] = None, cache_policy: CacheOperation = CacheOperation.ALWAYS, eviction_policy: CacheEviction = CacheEviction.EVICT_NORMAL, alignment: Int = Int((get_alignof Scalar[dtype], _current_target())) if is_nvidia_gpu() else Int(1)](ptr: Pointer[Scalar[dtype]]) -> SIMD[dtype, width]

Loads data from global memory into a SIMD vector.

Provides a high-level interface for vectorized memory loads with configurable cache behavior and memory access patterns.

Parameters:

  • ​dtype (DType): The data type to load.
  • ​width (Int): Vector width (number of elements to load).
  • ​read_only (Bool): If True, marks the load as read-only for cache optimization.
  • ​prefetch_size (Optional[Int]): Optional L2 cache prefetch size (64, 128, or 256 bytes).
  • ​cache_policy (CacheOperation): Cache operation policy for the load.
  • ​eviction_policy (CacheEviction): Cache eviction policy.
  • ​alignment (Int): Memory alignment in bytes.

Args:

Returns:

SIMD[dtype, width]: SIMD vector containing the loaded data.

def load[OffsetType: Indexer, dtype: DType, //, width: Int = Int(1), *, read_only: Bool = False, prefetch_size: Optional[Int] = None, cache_policy: CacheOperation = CacheOperation.ALWAYS, eviction_policy: CacheEviction = CacheEviction.EVICT_NORMAL, alignment: Int = Int((get_alignof Scalar[dtype], _current_target())) if is_nvidia_gpu() else Int(1)](ptr: Pointer[Scalar[dtype]], offset: OffsetType) -> SIMD[dtype, width]

Loads data from global memory with an offset into a SIMD vector.

Provides a high-level interface for vectorized memory loads with configurable cache behavior and memory access patterns, supporting offset-based addressing.

Parameters:

  • ​OffsetType (Indexer): Type of the offset value.
  • ​dtype (DType): The data type to load.
  • ​width (Int): Vector width (number of elements to load).
  • ​read_only (Bool): If True, marks the load as read-only for cache optimization.
  • ​prefetch_size (Optional[Int]): Optional L2 cache prefetch size (64, 128, or 256 bytes).
  • ​cache_policy (CacheOperation): Cache operation policy for the load.
  • ​eviction_policy (CacheEviction): Cache eviction policy.
  • ​alignment (Int): Memory alignment in bytes.

Args:

  • ​ptr (Pointer[Scalar[dtype]]): Base pointer to global memory.
  • ​offset (OffsetType): Offset from base pointer in elements.

Returns:

SIMD[dtype, width]: SIMD vector containing the loaded data.

Was this page helpful?