aclrtMallocCached
Applicable Products
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function
Allocates size bytes of linear memory on the device and returns the pointer to the allocated memory through *devPtr. 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 coherence 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 |
Memory size in bytes to allocate. size cannot be 0. |
policy |
Input |
Memory allocation policy. For details about the type definition, see aclrtMemMallocPolicy. If the configured memory allocation policy is beyond the value range of aclrtMemMallocPolicy, and size is greater than or equal to 2 MB, huge page memory is allocated; otherwise, common page memory is allocated. |
Returns
0 on success; otherwise, failure. For details, see aclError.
Restrictions
The value of policy can only be a single enumeration item and cannot be multiple enumeration items combined with bitwise OR. Only the following enumeration items are supported: ACL_MEM_MALLOC_HUGE_FIRST, ACL_MEM_MALLOC_HUGE_ONLY, ACL_MEM_MALLOC_NORMAL_ONLY, and ACL_MEM_MALLOC_HUGE1G_ONLY.