Function: malloc_with_cfg
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Description
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 information when allocating memory.
Memory allocated by this call needs to be freed by the acl.rt.free call.
Prototype
- C Prototype
1aclError aclrtMallocWithCfg(void **devPtr, size_t size, aclrtMemMallocPolicy policy, aclrtMallocConfig *cfg)
- Python Function
1dev_ptr, ret = acl.rt.malloc_with_cfg(size, policy, cfg)
Parameters
Parameter |
Description |
|---|---|
size |
Int, allocated memory size, in bytes. Must not be 0. |
policy |
Int, memory allocation policy. If the configured memory allocation rule exceeds the value range of aclrtMemMallocPolicy and size is greater than or equal to 2 MB, memory is allocated based on huge pages. Otherwise, memory is allocated based on normal pages. |
cfg |
Dict, memory configuration. If no configuration is specified, an empty dictionary can be transferred. For details, see aclrtMallocConfig. |
Return Value
Return Value |
Description |
|---|---|
devPtr |
Int, address of the pointer to the allocated device memory. |
ret |
Int, error code. 0 on success; else, failure. |