Function: malloc_cached
C Prototype |
aclError aclrtMallocCached(void **devPtr, size_t size, aclrtMemMallocPolicy policy) |
|---|---|
Python Function |
dev_ptr, ret = acl.rt.malloc_cached(size, policy) |
Function Usage |
Allocates cacheable device memory. Allocates size bytes of linear memory on the device and returns in dev_ptr a pointer address to the allocated memory. The memory allocated by calling acl.rt.malloc_cached is equivalent to the memory allocated by calling acl.rt.malloc. Both of them support cache, and you do not need to handle the cache consistency between the CPU and NPU. Before calling a media data processing API, acl.media.dvpp_malloc must be called to allocate memory on the device for storing the input or output data. |
Input Description |
size: int, size of the allocated memory, in bytes. The size cannot be 0. policy: int, memory allocation rule. For details, see aclrtMemMallocPolicy. |
Return Value |
dev_ptr: int, address of the pointer to the allocated device memory. ret: int, error code.
|
Restrictions |
Other restrictions are the same as those of acl.rt.malloc. |