Mojo module
id
This module provides GPU thread and block indexing functionality.
It defines aliases and functions for accessing GPU grid, block, thread and cluster dimensions and indices. These are essential primitives for GPU programming that allow code to determine its position and dimensions within the GPU execution hierarchy.
Most functionality is architecture-agnostic, with some NVIDIA-specific features clearly marked. The module is designed to work seamlessly across different GPU architectures while providing optimal performance through hardware-specific optimizations where applicable.
Aliases
-
block_dim = _BlockDim()
: Contains the dimensions of the block asx
,y
, andz
values (for example,block_dim.y
) -
block_id_in_cluster = _Cluster_BlockIdx()
: Contains the block id of the threadblock within a cluster, asx
,y
, andz
values. -
block_idx = _BlockIdx()
: Contains the block index in the grid, asx
,y
, andz
values. -
cluster_dim = _ClusterDim()
: Contains the dimensions of the cluster, asx
,y
, andz
values. -
cluster_idx = _ClusterIdx()
: Contains the cluster index in the grid, asx
,y
, andz
values. -
global_idx = _GridIdx()
: Contains the global offset of the kernel launch, asx
,y
, andz
values. -
grid_dim = _GridDim()
: Provides accessors for getting thex
,y
, andz
dimensions of a grid. -
thread_idx = _ThreadIdx()
: Contains the thread index in the block, asx
,y
, andz
values.
Functions
-
lane_id
: Returns the lane ID of the current thread within its warp. -
sm_id
: Returns the Streaming Multiprocessor (SM) ID of the current thread. -
warp_id
: Returns the warp ID of the current thread within its block. The warp ID is a unique identifier for each warp within a block, ranging from 0 to BLOCK_SIZE/WARP_SIZE-1. This ID is commonly used for warp-level programming and synchronization within a block.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!