aclrtMallocCached

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

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.

The memory allocated by calling aclrtMallocCached is equivalent to the memory allocated by calling aclrtMalloc. Both of them support cache, and you do not need to handle the cache consistency between the CPU and NPU.

Prototype

1
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. For details about the type definition, see aclrtMemMallocPolicy.

If the configured memory allocation policy is not within the value range of aclrtMemMallocPolicy, and the size is greater than or equal to 2 MB, the huge page memory is allocated; otherwise, the common page memory is allocated.

Returns

0 on success; else, failure. For details, see aclError.