IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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.

Reference: https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__TYPES.html#group__CUDA__TYPES_1g9d955dde0904a9b43ca4d875ac1551bc

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): The FuncAttribute to 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.