Product |
Supported (√/x) |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Allocates size bytes of linear memory on the device and returns in dev_ptr a pointer to the allocated memory.
Compared with the acl.rt.malloc API, this API can also specify memory-related configuration when allocating memory.
Memory allocated by this call needs to be freed by the acl.rt.free call.
1 | aclError aclrtMallocWithCfg(void **devPtr, size_t size, aclrtMemMallocPolicy policy, aclrtMallocConfig *cfg) |
1 | dev_ptr, ret = acl.rt.malloc_with_cfg(size, policy, cfg) |
Parameter |
Description |
|---|---|
size |
Int, allocated memory size, in bytes. Must not be 0. |
policy |
Int, memory allocation policy. 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. |
cfg |
Dict, memory configuration. If no configuration is specified, an empty dictionary can be transferred. For details, see aclrtMallocConfig. |
Return Value |
Description |
|---|---|
devPtr |
Int, address of the pointer to the allocated device memory. |
ret |
Int, error code. 0 on success; else, failure. |
The value of policy can be a single enumeration item or multiple enumeration items combined with bitwise OR. If bitwise OR is used, combinations of enumeration items from the three predefined groups are supported, for example, ACL_MEM_TYPE_HIGH_BAND_WIDTH | ACL_MEM_ACCESS_USER_SPACE_READONLY | ACL_MEM_MALLOC_HUGE_FIRST: