Function: malloc_with_cfg
Applicability
Product |
Supported (√/x) |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function Usage
Allocates linear memory of the size on the device and returns the pointer to the allocated memory through dev_ptr. Compared with the acl.rt.malloc API, this API can specify memory-related configuration information when allocating memory.
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)
Parameter Description
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 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. |
cfg |
Dict, memory configuration. If no configuration is specified, an empty dictionary is allowed. For details, see aclrtMallocConfig. |
Return Value Description
Return Value |
Description |
|---|---|
devPtr |
Int, address of the pointer to the allocated device memory. |
ret |
Int, error code: 0 on success; else, failure. |