aclrtMemMallocPolicy

A single enumeration item or multiple enumeration items are supported.

  • Configure a single enumeration item:

    If a value other than ACL_MEM_TYPE_LOW_BAND_WIDTH and ACL_MEM_TYPE_HIGH_BAND_WIDTH is configured, the system allocates memory from either the high-bandwidth or low-bandwidth physical memory, depending on the hardware situation.

    • 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_MALLOC_HUGE1G_ONLY
    • ACL_MEM_MALLOC_HUGE1G_ONLY_P2P
    • ACL_MEM_TYPE_LOW_BAND_WIDTH = 0x0100U
    • ACL_MEM_TYPE_HIGH_BAND_WIDTH = 0x1000U
    • ACL_MEM_ACCESS_USER_SPACE_READONLY = 0x100000U

    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.

  • Configure multiple enumeration item bits or:

    You can select one of the following two groups (for example, ACL_MEM_MALLOC_HUGE_FIRST | ACL_MEM_TYPE_HIGH_BAND_WIDTH):

    • ACL_MEM_MALLOC_HUGE_FIRST, ACL_MEM_MALLOC_HUGE_ONLY, ACL_MEM_MALLOC_NORMAL_ONLY
    • ACL_MEM_TYPE_LOW_BAND_WIDTH, ACL_MEM_TYPE_HIGH_BAND_WIDTH

Enumerated Item

Description

ACL_MEM_MALLOC_HUGE_FIRST = 0

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 =1

Allocate only huge page memory. If the huge page memory is insufficient, an error is returned.

ACL_MEM_MALLOC_NORMAL_ONLY = 2

Allocate only normal page memory. If the normal page memory is insufficient, an error is returned.

ACL_MEM_MALLOC_HUGE_FIRST_P2P = 3

Applicable to inter-device memory copy. Prioritize the allocation of huge page memory. If huge page memory is insufficient, allocate normal page memory.

Atlas 200I/500 A2 inference product: This item is not supported in the current version.

ACL_MEM_MALLOC_HUGE_ONLY_P2P = 4

Applicable to inter-device memory copy. Allocate only huge page memory. If the huge page memory is insufficient, an error is returned.

Atlas 200I/500 A2 inference product: This item is not supported in the current version.

ACL_MEM_MALLOC_NORMAL_ONLY_P2P= 5

Applicable to inter-device memory copy. Allocate only normal page memory.

Atlas 200/500 A2 Inference Product: This item is not supported in the current version.

ACL_MEM_TYPE_LOW_BAND_WIDTH = 6

Allocate memory from the physical memory with high bandwidth.

Atlas 200I/500 A2 inference product: This item is invalid. By default, the system selects the allocation rule based on hardware-supported memory types.

ACL_MEM_TYPE_HIGH_BAND_WIDTH = 7

Allocate memory from the physical memory with low bandwidth.

Atlas 200I/500 A2 inference product: This item is invalid. By default, the system selects the allocation rule based on hardware-supported memory types.

ACL_MEM_MALLOC_HUGE1G_ONLY = 8

Allocate huge page memory with a granularity of 1 GB. If the allocated memory is not a multiple of 1 GB, it is rounded up to the nearest multiple of 1 GB. For example, if 1.9 GB memory is requested, 2 GB memory is actually allocated according to the round-up rule.

If this item is configured, only huge page memory is allocated. If the huge page memory is insufficient, an error is returned.

To allocate 1 GB of huge page memory, ACL_MEM_MALLOC_HUGE_ONLY (with a 2 MB allocation granularity) requires 512 (= 1024/2) page tables, while ACL_MEM_MALLOC_HUGE1G_ONLY (with a 1 GB granularity) requires only one page table. The latter effectively reduces the number of page tables and expands the address range of the translation lookaside buffer (TLB), thereby improving the discrete access performance. TLB is a hardware module in the AI processor used for caching. It stores the mapping between the recently used virtual addresses and physical addresses.

The Atlas 350 Accelerator Card supports this item.

The Atlas A3 training product/Atlas A3 inference product supports this item.

The Atlas A2 training product/Atlas A2 inference product supports this item.

The Atlas 200I/500 A2 inference product does not support this item.

The Atlas inference product does not support this item.

The Atlas training product does not support this item.

ACL_MEM_MALLOC_HUGE1G_ONLY_P2P = 9

Allocate huge page memory in granularity of 1 GB only in the scenario of memory copy between two devices. If the allocated memory is not a multiple of 1 GB, it is rounded up to the nearest multiple of 1 GB. For example, if 1.9 GB memory is requested, 2 GB memory is actually allocated according to the round-up rule.

If this item is configured, only huge page memory is allocated. If the huge page memory is insufficient, an error is returned.

To allocate 1 GB of huge page memory, ACL_MEM_MALLOC_HUGE_ONLY_P2P (with a 2 MB allocation granularity) requires 512 (= 1024/2) page tables, while ACL_MEM_MALLOC_HUGE1G_ONLY_P2P (with a 1 GB granularity) requires only one page table. The latter effectively reduces the number of page tables and expands the address range of the TLB, thereby improving the discrete access performance. TLB is a hardware module in the AI processor used for caching. It stores the mapping between the recently used virtual addresses and physical addresses.

The Atlas 350 Accelerator Card supports this item.

The Atlas A3 training product/Atlas A3 inference product supports this item.

The Atlas A2 training product/Atlas A2 inference product supports this item.

The Atlas 200I/500 A2 inference product does not support this item.

The Atlas inference product does not support this item.

The Atlas training product does not support this item.

ACL_MEM_ACCESS_USER_SPACE_READONLY = 10

Specify that the allocated memory is read-only in user mode. Memory modification in user mode would fail.