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).

info

Implements methods for querying the host target info.

You can import these APIs from the sys package. For example:

from std.sys import CompilationTarget

print(CompilationTarget.is_x86())

comptime values​

is_amd_gpu​

comptime is_amd_gpu[subarch: StringSpan[ImmStaticOrigin] = StringSpan("<any>")] = fn_literal

Checks whether the current compilation target is an AMD GPU.

Equivalent to CompilationTarget.current().is_amd_gpu().

Parameters​

is_apple_gpu​

comptime is_apple_gpu[subarch: StringSpan[ImmStaticOrigin] = StringSpan("<any>")] = fn_literal

Checks whether the current compilation target is an Apple GPU.

Equivalent to CompilationTarget.current().is_apple_gpu().

Parameters​

is_gpu​

comptime is_gpu = fn_literal

Returns True if the target triple is GPU and False otherwise.

Equivalent to CompilationTarget.current().is_gpu().

is_nvidia_gpu​

comptime is_nvidia_gpu[subarch: StringSpan[ImmStaticOrigin] = StringSpan("<any>")] = fn_literal

Checks whether the current compilation target is an NVIDIA GPU.

Equivalent to CompilationTarget.current().is_nvidia_gpu().

Parameters​

Structs​

  • ​CompilationTarget: A struct that provides information about a target architecture.
  • ​Endian: A byte order: the order in which a multi-byte value's bytes are stored.

Functions​

  • ​align_of: Returns the align of (in bytes) of the type.
  • ​bit_width_of: Returns the size of (in bits) of the type.
  • ​has_accelerator: Returns True if the host system has an accelerator and False otherwise.
  • ​has_amd_gpu_accelerator: Returns True if the host system has an AMD GPU and False otherwise.
  • ​has_amd_rdna_gpu_accelerator: Returns True if the host system has an AMD RDNA GPU and False otherwise.
  • ​has_apple_gpu_accelerator: Returns True if the host system has a Metal GPU and False otherwise.
  • ​has_nvidia_gpu_accelerator: Returns True if the host system has an NVIDIA GPU and False otherwise.
  • ​is_32bit: Returns True if the maximum integral value is 32 bit.
  • ​is_64bit: Returns True if the maximum integral value is 64 bit.
  • ​is_apple_m5: Returns True if the target is an Apple M5 GPU and False otherwise.
  • ​is_big_endian: Returns True if the target's endianness is big and False otherwise.
  • ​is_little_endian: Returns True if the target's endianness is little and False otherwise.
  • ​is_triple: Returns True if the target triple of the compiler matches the input and False otherwise.
  • ​num_logical_cores: Returns the number of hardware threads, including hyperthreads across all CPU sockets.
  • ​num_performance_cores: Returns the number of physical performance cores across all CPU sockets. If not known, returns the total number of physical cores.
  • ​num_physical_cores: Returns the number of physical cores across all CPU sockets.
  • ​platform_map: Helper for defining a compile time value depending on the current compilation target, raising a compilation error if trying to access the value on an unsupported target.
  • ​simd_bit_width: Returns the vector size (in bits) of the specified target.
  • ​simd_byte_width: Returns the vector size (in bytes) of the specified target.
  • ​simd_width_of: Returns the vector size of the type on the host system.
  • ​size_of: Returns the size of (in bytes) of the type.
  • ​stdlib_plugin: Returns the stdlib plugin name for the specified target.