Skip to main content
Log in

Mojo module

id

This module includes grid-related aliases and functions. Most of these are generic, a few are specific to NVIDIA GPUs.

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

from gpu import block_idx, block_dim, thread_idx
from gpu import block_idx, block_dim, thread_idx

Aliases

  • block_dim = {}: Contains the dimensions of the block as x, y, and z values (for example, block_dim.y)
  • block_idx = {}: Contains the block index in the grid, as x, y, and z values.
  • cluster_dim = {}: Contains the dimensions of the cluster, as x, y, and z values.
  • cluster_idx = {}: Contains the cluster index in the grid, as x, y, and z values.
  • global_idx = {}: Contains the global offset of the kernel launch, as x, y, and z values.
  • grid_dim = {}: Provides accessors for getting the x, y, and z dimensions of a grid.
  • thread_idx = {}: Contains the thread index in the block, as x, y, and z values.

Functions

  • block_rank_in_cluster: Gets the unique identifier for the current thread block (CTA) in the cluster across all dimensions. Equivalent to %cluster_ctarank in CUDA.
  • lane_id: Returns the lane ID of the current thread.
  • sm_id: Returns the Streaming Multiprocessor (SM) ID of the current thread. Returns: The SM ID of the the current thread.