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 struct
Attribute
struct Attribute
Represents GPU kernel function attributes.
This struct defines constants for various function attributes that can be queried or set for GPU kernels. These attributes provide information about resource requirements and execution constraints of kernel functions.
Fieldsβ
- βcode (
Int32): The numeric code representing the attribute type.
Implemented traitsβ
AnyType,
Copyable,
Deinitable,
Equatable,
ImplicitlyCopyable,
Movable,
RegisterPassable,
TrivialRegisterPassable,
Writable
comptime membersβ
BINARY_VERSIONβ
comptime BINARY_VERSION = Attribute(Int32(6))
The binary architecture version for which the function was compiled. This value is the major binary version * 10 + the minor binary version, so a binary version 1.3 function would return the value 13. Note that this will return a value of 10 for legacy cubins that do not have a properly- encoded binary architecture version..
CACHE_MODE_CAβ
comptime CACHE_MODE_CA = Attribute(Int32(7))
The attribute to indicate whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set .
CLUSTER_SCHEDULING_POLICY_PREFERENCEβ
comptime CLUSTER_SCHEDULING_POLICY_PREFERENCE = Attribute(Int32(15))
The block scheduling policy of a function. The value type is CUclusterSchedulingPolicy / cudaClusterSchedulingPolicy.
CLUSTER_SIZE_MUST_BE_SETβ
comptime CLUSTER_SIZE_MUST_BE_SET = Attribute(Int32(10))
If this attribute is set, the kernel must launch with a valid cluster size specified.
CONST_SIZE_BYTESβ
comptime CONST_SIZE_BYTES = Attribute(Int32(2))
The size in bytes of user-allocated constant memory required by this function.
LOCAL_SIZE_BYTESβ
comptime LOCAL_SIZE_BYTES = Attribute(Int32(3))
The size in bytes of local memory used by each thread of this function.
MAX_DYNAMIC_SHARED_SIZE_BYTESβ
comptime MAX_DYNAMIC_SHARED_SIZE_BYTES = Attribute(Int32(8))
The maximum size in bytes of dynamically-allocated shared memory that can be used by this function. If the user-specified dynamic shared memory size is larger than this value.
MAX_THREADS_PER_BLOCKβ
comptime MAX_THREADS_PER_BLOCK = Attribute(Int32(0))
The maximum number of threads per block, beyond which a launch of the function would fail. This number depends on both the function and the device on which the function is currently loaded.
NON_PORTABLE_CLUSTER_SIZE_ALLOWEDβ
comptime NON_PORTABLE_CLUSTER_SIZE_ALLOWED = Attribute(Int32(14))
Whether the function can be launched with non-portable cluster size. 1 is allowed, 0 is disallowed. A non-portable cluster size may only function on the specific SKUs the program is tested on. The launch might fail if the program is run on a different hardware platform.CUDA API provides cudaOccupancyMaxActiveClusters to assist with checking whether the desired size can be launched on the current device.Portable Cluster SizeA portable cluster size is guaranteed to be functional on all compute capabilities higher than the target compute capability. The portable cluster size for sm_90 is 8 blocks per cluster.
NUM_REGSβ
comptime NUM_REGS = Attribute(Int32(4))
The number of registers used by each thread of this function.
PREFERRED_SHARED_MEMORY_CARVEOUTβ
comptime PREFERRED_SHARED_MEMORY_CARVEOUT = Attribute(Int32(9))
On devices where the L1 cache and shared memory use the same hardware resources, this sets the shared memory carveout preference, in percent of the total shared memory.
PTX_VERSIONβ
comptime PTX_VERSION = Attribute(Int32(5))
The PTX virtual architecture version for which the function was compiled. This value is the major PTX version * 10 + the minor PTX version, so a PTX version 1.3 function would return the value 13. Note that this may return the undefined value of 0 for cubins compiled prior to CUDA 3.0..
REQUIRED_CLUSTER_DEPTHβ
comptime REQUIRED_CLUSTER_DEPTH = Attribute(Int32(13))
The required cluster depth in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions is otherwise checked at launch time.
REQUIRED_CLUSTER_HEIGHTβ
comptime REQUIRED_CLUSTER_HEIGHT = Attribute(Int32(12))
The required cluster height in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions is otherwise checked at launch time.
REQUIRED_CLUSTER_WIDTHβ
comptime REQUIRED_CLUSTER_WIDTH = Attribute(Int32(11))
The required cluster width in blocks. The values must either all be 0 or all be positive. The validity of the cluster dimensions is otherwise checked at launch time.
SHARED_SIZE_BYTESβ
comptime SHARED_SIZE_BYTES = Attribute(Int32(1))
The size in bytes of statically-allocated shared memory required by this function. This does not include dynamically-allocated shared memory requested by the user at runtime.
Methodsβ
__eq__β
def __eq__(self, other: Self) -> Bool
Checks if two Attribute instances are equal.
Args:
- βother (
Self): The Attribute to compare with.
Returns:
Bool: True if both attributes have the same code, False otherwise.
__ne__β
def __ne__(self, other: Self) -> Bool
Checks if two Attribute instances are not equal.
Args:
- βother (
Self): The Attribute to compare with.
Returns:
Bool: True if the attributes have different codes, False otherwise.
write_toβ
def write_to(self, mut writer: T)
Writes a string representation of the Attribute to the provided writer.
This method converts the `Attribute` enum value to its corresponding string name
and writes it to the provided writer object.Args:
- βwriter (
T): A Writer object that will receive the string representation.