aclrtMallocWithCfg
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Description
Allocates linear memory of the size bytes on the device and returns the allocated memory pointer through *devPtr. The start address of the memory is 64-byte aligned. The memory allocated by this API is byte-aligned. The size bytes requested by users are rounded up to the nearest multiple of 32 bytes, with an additional 32 bytes added. Compared with aclrtMalloc, this API can also specify memory configuration information when allocating memory.
Prototype
aclError aclrtMallocWithCfg(void **devPtr, size_t size, aclrtMemMallocPolicy policy, aclrtMallocConfig *cfg)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
devPtr |
Output |
Pointer to the pointer to the allocated device memory. |
size |
Input |
Requested allocation size in bytes. The size cannot be 0. |
policy |
Input |
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 |
Input |
Memory configuration. If no configuration is specified, NULL can be passed. |
Returns
0 on success; else, failure. For details, see aclError.