Mojo function
stack_allocation
stack_allocation[count: Int, type: DType, /, alignment: Int = alignof[::DType,__mlir_type.!kgen.target]() if is_gpu() else 1.value, address_space: AddressSpace = 0]() -> UnsafePointer[SIMD[type, 1], address_space=address_space]
Allocates data buffer space on the stack given a data type and number of elements.
Parameters:
- count (
Int
): Number of elements to allocate memory for. - type (
DType
): The data type of each element. - alignment (
Int
): Address alignment of the allocated data. - address_space (
AddressSpace
): The address space of the pointer.
Returns:
A data pointer of the given type pointing to the allocated space.
stack_allocation[count: Int, type: AnyType, /, name: Optional[StringLiteral] = Optional(None), alignment: Int = alignof[::AnyType,__mlir_type.!kgen.target]() if is_gpu() else 1.value, address_space: AddressSpace = 0]() -> UnsafePointer[type, address_space=address_space]
Allocates data buffer space on the stack given a data type and number of elements.
Parameters:
- count (
Int
): Number of elements to allocate memory for. - type (
AnyType
): The data type of each element. - name (
Optional[StringLiteral]
): The name of the global variable (only honored in certain cases). - alignment (
Int
): Address alignment of the allocated data. - address_space (
AddressSpace
): The address space of the pointer.
Returns:
A data pointer of the given type pointing to the allocated space.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!