Mojo struct
FuncAttribute
@register_passable(trivial)
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.
Aliases
NULL = FuncAttribute(Attribute(__init__[__mlir_type.!pop.int_literal](-1)), __init__[__mlir_type.!pop.int_literal](-1))
: A null/invalid function attribute constant.
Fields
- attribute (
Attribute
): The type of function attribute. - value (
SIMD[int32, 1]
): The value associated with this attribute.
Implemented traits
AnyType
,
CollectionElement
,
Copyable
,
EqualityComparable
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
Methods
__init__
__init__(*, other: Self) -> Self
Explicitly construct a deep copy of the provided value.
Args:
- other (
Self
): The value to copy.
__eq__
__eq__(self, other: Self) -> Bool
Checks if two FuncAttribute
instances are equal.
Args:
- other (
Self
): The FuncAttribute to compare with.
Returns:
True if both the attribute type and value are equal, False otherwise.
__ne__
__ne__(self, other: Self) -> Bool
Checks if two FuncAttribute
instances are not equal.
Args:
- other (
Self
): TheFuncAttribute
to compare with.
Returns:
True if either the attribute type or value differs, False otherwise.
CACHE_MODE_CA
static 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:
A FuncAttribute
instance with CACHE_MODE_CA attribute type.
MAX_DYNAMIC_SHARED_SIZE_BYTES
static MAX_DYNAMIC_SHARED_SIZE_BYTES(val: SIMD[uint32, 1]) -> 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 (
SIMD[uint32, 1]
): Maximum dynamic shared memory size in bytes.
Returns:
A FuncAttribute
instance with MAX_DYNAMIC_SHARED_SIZE_BYTES
attribute type.
PREFERRED_SHARED_MEMORY_CARVEOUT
static PREFERRED_SHARED_MEMORY_CARVEOUT(val: SIMD[int32, 1]) -> 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 (
SIMD[int32, 1]
): Shared memory carveout preference as a percentage (0-100).
Returns:
A FuncAttribute instance with PREFERRED_SHARED_MEMORY_CARVEOUT
attribute type.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!