|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Allocates linear memory of the size on the device and returns the pointer to the allocated memory through dev_ptr. The start address of the memory is 64-byte aligned. The memory allocated by this API needs to be freed by calling acl.rt.free.
The allocated memory is byte-aligned. The alignment policy varies depending on the product model.
1
|
aclError aclrtMalloc(void **devPtr, size_t size, aclrtMemMallocPolicy policy) |
1
|
dev_ptr, ret = acl.rt.malloc(size, policy) |
|
Parameter |
Description |
|---|---|
|
size |
Int, size of the memory to be allocated, in bytes. The value cannot 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. |
|
Return Value |
Description |
|---|---|
|
dev_ptr |
Int, address of the pointer to the allocated device memory. |
|
ret |
Int, error code. 0 on success; else, failure. |
len indicates the size of a memory segment. ALIGN_UP[len,k] indicates rounding up to a multiple of k bytes as in this formula: ((len – 1)/k + 1) x k.