aclrtMallocCached

Description

Allocates size bytes of linear memory on the device and returns in *devPtr a pointer to the allocated memory. The allocated memory is cacheable. This API is synchronous.

Both aclrtMallocCached and aclrtMalloc allocate cacheable memory.

Before calling a media data processing API, acldvppMalloc must be called to allocate memory on the device for storing the input or output data.

Restrictions

Other restrictions are the same as those of aclrtMalloc.

Prototype

aclError aclrtMallocCached(void **devPtr, size_t size, aclrtMemMallocPolicy policy)

Parameters

Parameter

Input/Output

Description

devPtr

Output

Pointer to the pointer to the allocated device memory.

size

Input

Requested allocation size in bytes.

Must not be 0.

policy

Input

Memory allocation policy.

typedef enum aclrtMemMallocPolicy {
ACL_MEM_MALLOC_HUGE_FIRST, //When the allocated memory is less than or equal to 1 MB, only normal page memory is allocated even under this memory allocation policy. When the allocated memory is greater than 1 MB, the allocation of huge page memory is prioritized. If the huge page memory is insufficient, normal page memory is allocated.
ACL_MEM_MALLOC_HUGE_ONLY, //Only huge page memory is allocated. If huge page memory is insufficient, an error is returned.
ACL_MEM_MALLOC_NORMAL_ONLY, //Only normal page memory is allocated.
ACL_MEM_MALLOC_HUGE_FIRST_P2P, //Applies to inter-device memory copy. The allocation of huge page memory is prioritized. If huge page memory is insufficient, normal page memory will be allocated. This option is not supported by Ascend 310 AI Processor in the current version.
ACL_MEM_MALLOC_HUGE_ONLY_P2P, //Applies to inter-device memory copy. Only huge page memory is allocated. If huge page memory is insufficient, a failure will be returned. This option is not supported by Ascend 310 AI Processor in the current version.
ACL_MEM_MALLOC_NORMAL_ONLY_P2P, //Applies to inter-device memory copy. Only normal page memory is allocated. This option is not supported by Ascend 310 AI Processor in the current version.
} aclrtMemMallocPolicy;

Returns

0 on success; else, failure.