From 973b35bc06113986a2f0b972c533334b41ddfa50 Mon Sep 17 00:00:00 2001 From: Alex Sierra Date: Wed, 9 Sep 2020 15:55:04 -0700 Subject: [PATCH] libhsakmt: change memory allocation alignment it is to optimize memory allocation latency, which changes alignment from 2MB to 1GB. Signed-off-by: Alex Sierra Signed-off-by: Eric Huang Change-Id: I7818e9f13b17e2c0992e75b17f978dc03a018a57 --- src/fmm.c | 6 +++--- src/libhsakmt.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fmm.c b/src/fmm.c index c9a356d0fd..fa874156b0 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -714,10 +714,10 @@ static void *mmap_aperture_allocate_aligned(manageable_aperture_t *aper, return NULL; } - /* Align big buffers to the next power-of-2 up to huge page - * size for flexible fragment size TLB optimizations + /* Align big buffers to the next power-of-2 up to 1GB + * size for memory allocation optimization */ - while (align < GPU_HUGE_PAGE_SIZE && size >= (align << 1)) + while (align < GPU_GIANT_PAGE_SIZE && size >= (align << 1)) align <<= 1; /* Add padding to guarantee proper alignment and leave guard diff --git a/src/libhsakmt.h b/src/libhsakmt.h index 9fcd6d66fa..f815e43e99 100644 --- a/src/libhsakmt.h +++ b/src/libhsakmt.h @@ -72,6 +72,7 @@ extern int PAGE_SHIFT; /* 2MB huge page size for 4-level page tables on Vega10 and later GPUs */ #define GPU_HUGE_PAGE_SIZE (2 << 20) +#define GPU_GIANT_PAGE_SIZE (1 << 30) #define CHECK_PAGE_MULTIPLE(x) \ do { if ((uint64_t)PORT_VPTR_TO_UINT64(x) % PAGE_SIZE) return HSAKMT_STATUS_INVALID_PARAMETER; } while(0)