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
FuncAttribute
struct FuncAttribute
Implements CUDA's CUfunction_attribute enum for GPU kernel function attributes.
This struct represents function attributes that can be set or queried for GPU kernels, following NVIDIA's CUDA driver API conventions. Each attribute consists of a type (represented by the Attribute enum) and an associated value.
The struct provides factory methods for creating common attribute configurations, such as cache mode settings and shared memory allocations.
Fieldsβ
- βattribute (
Attribute): The type of function attribute. - βvalue (
Int32): The value associated with this attribute.
Implemented traitsβ
AnyType,
Copyable,
Deinitable,
Equatable,
ImplicitlyCopyable,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime membersβ
NULLβ
comptime NULL = FuncAttribute(Attribute(Int32(-1)), Int32(-1))
A null/invalid function attribute constant.
Methodsβ
__eq__β
def __eq__(self, other: Self) -> Bool
Checks if two FuncAttribute instances are equal.
Args:
- βother (
Self): The FuncAttribute to compare with.
Returns:
Bool: True if both the attribute type and value are equal, False otherwise.
__ne__β
def __ne__(self, other: Self) -> Bool
Checks if two FuncAttribute instances are not equal.
Args:
- βother (
Self): TheFuncAttributeto compare with.
Returns:
Bool: True if either the attribute type or value differs, False otherwise.
CACHE_MODE_CAβ
static def CACHE_MODE_CA(val: Bool) -> Self
Creates a CACHE_MODE_CA function attribute.
Indicates whether the function has been compiled with user specified
option CacheMode.L1_CACHE_DISABLED set.
Args:
- βval (
Bool): Boolean value indicating if L1 cache is disabled.
Returns:
Self: A FuncAttribute instance with CACHE_MODE_CA attribute type.
MAX_DYNAMIC_SHARED_SIZE_BYTESβ
static def MAX_DYNAMIC_SHARED_SIZE_BYTES(val: UInt32) -> Self
Creates a MAX_DYNAMIC_SHARED_SIZE_BYTES function attribute.
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, the launch will fail.
Args:
- βval (
UInt32): Maximum dynamic shared memory size in bytes.
Returns:
Self: A FuncAttribute instance with MAX_DYNAMIC_SHARED_SIZE_BYTES attribute type.
PREFERRED_SHARED_MEMORY_CARVEOUTβ
static def PREFERRED_SHARED_MEMORY_CARVEOUT(val: Int32) -> Self
Creates a PREFERRED_SHARED_MEMORY_CARVEOUT function attribute.
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.
Args:
- βval (
Int32): Shared memory carveout preference as a percentage (0-100).
Returns:
Self: A FuncAttribute instance with PREFERRED_SHARED_MEMORY_CARVEOUT attribute type.