aclrtMemMallocPolicy
typedef enum aclrtMemMallocPolicy {
ACL_MEM_MALLOC_HUGE_FIRST,
ACL_MEM_MALLOC_HUGE_ONLY,
ACL_MEM_MALLOC_NORMAL_ONLY,
ACL_MEM_MALLOC_HUGE_FIRST_P2P,
ACL_MEM_MALLOC_HUGE_ONLY_P2P,
ACL_MEM_MALLOC_NORMAL_ONLY_P2P,
ACL_MEM_TYPE_LOW_BAND_WIDTH = 0x0100,
ACL_MEM_TYPE_HIGH_BAND_WIDTH = 0x1000
} aclrtMemMallocPolicy;
A single enumeration item or multiple enumeration items are supported.
- Configuring a single enumeration item:
If ACL_MEM_MALLOC_HUGE_FIRST, ACL_MEM_MALLOC_HUGE_ONLY, ACL_MEM_MALLOC_NORMAL_ONLY, ACL_MEM_MALLOC_HUGE_FIRST_P2P, ACL_MEM_MALLOC_HUGE_ONLY_P2P, or ACL_MEM_MALLOC_NORMAL_ONLY_P2P is configured, the system allocates memory from the high-bandwidth or low-bandwidth physical memory based on the hardware situation.
If ACL_MEM_TYPE_LOW_BAND_WIDTH or ACL_MEM_TYPE_HIGH_BAND_WIDTH is configured, the system uses ACL_MEM_MALLOC_HUGE_FIRST by default and preferentially allocates huge pages.
- Configuring multiple enumeration items: Supports combining ACL_MEM_MALLOC_HUGE_FIRST, ACL_MEM_MALLOC_HUGE_ONLY and ACL_MEM_MALLOC_NORMAL_ONLY with ACL_MEM_TYPE_LOW_BAND_WIDTH and ACL_MEM_TYPE_HIGH_BAND_WIDTH. For example, ACL_MEM_MALLOC_HUGE_FIRST | ACL_MEM_TYPE_HIGH_BAND_WIDTH.
Enumerated Item |
Description |
|---|---|
ACL_MEM_MALLOC_HUGE_FIRST |
When the requested memory is less than or equal to 1 MB, only normal page memory will be allocated. When the requested memory is greater than 1 MB, the huge page memory is preferentially allocated, and normal page memory will be allocated only when the huge page memory is insufficient. |
ACL_MEM_MALLOC_HUGE_ONLY |
Allocate only huge page memory. If the huge page memory is insufficient, an error is returned. |
ACL_MEM_MALLOC_NORMAL_ONLY |
Allocate only normal page memory. If the normal page memory is insufficient, an error is returned. |
ACL_MEM_MALLOC_HUGE_FIRST_P2P |
Applicable to inter-device memory copy. Prioritize the allocation of huge page memory. If huge page memory is insufficient, allocate normal page memory. The |
ACL_MEM_MALLOC_HUGE_ONLY_P2P |
Applicable to inter-device memory copy. Allocate only huge page memory. If the huge page memory is insufficient, an error is returned. The |
ACL_MEM_MALLOC_NORMAL_ONLY_P2P |
Applicable to inter-device memory copy. Allocate only normal page memory. The |
ACL_MEM_TYPE_LOW_BAND_WIDTH |
Allocate memory from the physical memory with high bandwidth. This option is invalid. By default, the system selects the allocation rule based on hardware-supported memory types. |
ACL_MEM_TYPE_HIGH_BAND_WIDTH |
Allocate memory from the physical memory with low bandwidth. This option is invalid. By default, the system selects the allocation rule based on hardware-supported memory types. |