Function: malloc_align32

Applicable Products

Product

Supported (√/x)

Ascend 950PR / Ascend 950DT

√

Atlas A3 training products / Atlas A3 inference products

√

Atlas A2 training products / Atlas A2 inference products

√

Atlas training products

√

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Allocates size bytes of linear memory on the device and returns in dev_ptr a pointer to the allocated memory. The allocation size is the input size rounded up to the nearest multiple of 32 bytes. Memory allocated by this call needs to be freed by the acl.rt.free call.

For the Ascend 950PR / Ascend 950DT , this API is equivalent to the aclrtMalloc API.

For the product models below, compared with the aclrtMalloc API, this API only rounds the input size up to the nearest multiple of 32 bytes, but does not add an extra 32 bytes.

Prototype

Parameters

Parameter

Description

size

Int, allocated memory size, in bytes. Must not be 0.

policy

  • Int, memory allocation policy.

    If the configured memory allocation rule exceeds the value range of aclrtMemMallocPolicy and size is greater than or equal to 2 MB, memory is allocated based on huge pages. Otherwise, memory is allocated based on normal pages.

Return Values

Return Value

Description

dev_ptr

Int, address of the pointer to the allocated device memory.

ret

Int, error code. 0 on success; else, failure.

Restrictions