aclrtMemAttr
typedef enum aclrtMemAttr {
ACL_DDR_MEM, // Huge page memory + normal page memory
ACL_HBM_MEM, // Huge page memory + normal page memory
ACL_DDR_MEM_HUGE, // Huge page memory
ACL_DDR_MEM_NORMAL, // Normal page memory
ACL_HBM_MEM_HUGE, // Huge page memory. The memory allocation granularity is 2 MB. If the allocated memory is not a multiple of 2 MB, it is rounded up to the nearest multiple of 2 MB.
ACL_HBM_MEM_NORMAL, // Normal page memory
ACL_DDR_MEM_P2P_HUGE, // Huge page memory for inter-device memory copy
ACL_DDR_MEM_P2P_NORMAL, // Normal page memory for inter-device memory copy
ACL_HBM_MEM_P2P_HUGE, // Normal page memory used for inter-device memory copy. The memory allocation granularity is 2 MB. If the allocated memory is not a multiple of 2 MB, it is rounded up to the nearest multiple of 2 MB.
ACL_HBM_MEM_P2P_NORMAL, // Normal page memory for inter-device memory copy
ACL_HBM_MEM_HUGE1G, // Huge page memory. The memory allocation granularity is 1 GB. If the allocated memory is not a multiple of 1 GB, it is rounded up to the nearest multiple of 1 GB.
ACL_HBM_MEM_P2P_HUGE1G // Normal page memory used for inter-device memory copy. The memory allocation granularity is 1 GB. If the allocated memory is not a multiple of 1 GB, it is rounded up to the nearest multiple of 1 GB.
/* The preceding options are compatible with earlier versions. You need to select the memory attribute options based on the hardware memory (DDR and HBM). */
/* The following options are automatically selected by the API based on the underlying hardware memory. You do not need to pay attention to the hardware details. The following options are recommended. */
ACL_MEM_NORMAL, // Normal page memory
ACL_MEM_HUGE, // Huge page memory. The memory allocation granularity is 2 MB. If the allocated memory is not a multiple of 2 MB, it is rounded up to the nearest multiple of 2 MB.
ACL_MEM_HUGE1G, // Huge page memory. The memory allocation granularity is 1 GB. If the allocated memory is not a multiple of 1 GB, it is rounded up to the nearest multiple of 1 GB.
ACL_MEM_P2P_NORMAL, // Normal page memory for inter-device memory copy
ACL_MEM_P2P_HUGE, // Normal page memory used for inter-device memory copy. The memory allocation granularity is 2 MB. If the allocated memory is not a multiple of 2 MB, it is rounded up to the nearest multiple of 2 MB.
ACL_MEM_P2P_HUGE1G, // Normal page memory used for inter-device memory copy. The memory allocation granularity is 1 GB. If the allocated memory is not a multiple of 1 GB, it is rounded up to the nearest multiple of 1 GB.
} aclrtMemAttr;
In the scenario where huge page memory is allocated, when the memory allocation granularity is 2 MB, to allocate 1 GB of huge page memory, 512 (1024/2) page tables are needed. In contrast, when the memory allocation granularity is 1 GB, to allocate 1 GB of huge page memory, only one page table is needed. This effectively reduces the number of page tables, expands the address range of the translation lookaside buffer (TLB), and improves the discrete access performance. TLB is a hardware module in the Ascend AI Processor used for caching. It stores the mapping between the recently used virtual addresses and physical addresses.
HUGE1G-related options are supported only by the
Currently, HUGE1G-related options are not supported by other models.