Skip to main content

Mojo struct

GPUInfo

@register_passable struct GPUInfo

Comprehensive information about a GPU architecture.

This struct contains detailed specifications about GPU capabilities, including compute units, memory, thread organization, and performance characteristics.

Fields

  • name (StringSlice[StaticConstantOrigin]): The model name of the GPU.
  • vendor (Vendor): The vendor/manufacturer of the GPU (e.g., NVIDIA, AMD).
  • api (StringSlice[StaticConstantOrigin]): The graphics/compute API supported by the GPU (e.g., CUDA, ROCm).
  • arch_name (StringSlice[StaticConstantOrigin]): The architecture name of the GPU (e.g., sm_80, gfx942).
  • compute (SIMD[float32, 1]): Compute capability version number for NVIDIA GPUs.
  • version (StringSlice[StaticConstantOrigin]): Version string of the GPU architecture.
  • sm_count (Int): Number of streaming multiprocessors (SMs) on the GPU.
  • warp_size (Int): Number of threads in a warp/wavefront.
  • threads_per_sm (Int): Maximum number of threads per streaming multiprocessor.
  • shared_memory_per_multiprocessor (Int): Size of shared memory available per multiprocessor in bytes.
  • max_registers_per_block (Int): Maximum number of registers that can be allocated to a thread block.
  • max_thread_block_size (Int): Maximum number of threads allowed in a thread block.

Implemented traits

AnyType, Movable, Stringable, UnknownDestructibility, Writable

Aliases

__del__is_trivial

alias __del__is_trivial = True

__moveinit__is_trivial

alias __moveinit__is_trivial = True

Methods

__lt__

__lt__(self, other: Self) -> Bool

Compares if this GPU has lower compute capability than another.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if this GPU has lower compute capability, False otherwise.

__le__

__le__(self, other: Self) -> Bool

Compares if this GPU has lower or equal compute capability.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if this GPU has lower or equal compute capability.

__eq__

__eq__(self, other: Self) -> Bool

Checks if two GPUInfo instances represent the same GPU model.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if both instances represent the same GPU model.

__ne__

__ne__(self, other: Self) -> Bool

Checks if two GPUInfo instances represent different GPU models.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if instances represent different GPU models.

__gt__

__gt__(self, other: Self) -> Bool

Compares if this GPU has higher compute capability than another.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if this GPU has higher compute capability, False otherwise.

__ge__

__ge__(self, other: Self) -> Bool

Compares if this GPU has higher or equal compute capability.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if this GPU has higher or equal compute capability.

__is__

__is__(self, other: Self) -> Bool

Identity comparison operator for GPUInfo instances.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if both instances represent the same GPU model.

__isnot__

__isnot__(self, other: Self) -> Bool

Negative identity comparison operator for GPUInfo instances.

Args:

  • other (Self): Another GPUInfo instance to compare against.

Returns:

Bool: True if instances represent different GPU models.

target

target(self) -> target

Gets the MLIR target configuration for this GPU.

Returns:

target: MLIR target configuration for the GPU.

from_target

static from_target[target: target]() -> Self

Creates a GPUInfo instance from an MLIR target.

Parameters:

  • target (target): MLIR target configuration.

Returns:

Self: GPU info corresponding to the target.

from_name

static from_name[name: StringSlice[StaticConstantOrigin]]() -> Self

Creates a GPUInfo instance from a GPU architecture name.

Parameters:

  • name (StringSlice): GPU architecture name (e.g., "sm_80", "gfx942").

Returns:

Self: GPU info corresponding to the architecture name.

write_to

write_to(self, mut writer: T)

Writes GPU information to a writer.

Outputs all GPU specifications and capabilities to the provided writer in a human-readable format.

Args:

  • writer (T): A Writer instance to output the GPU information.

__str__

__str__(self) -> String

Returns a string representation of the GPU information.

Converts all GPU specifications and capabilities to a human-readable string format.

Returns:

String: String containing all GPU information.

Was this page helpful?