diff --git a/globals.cpp b/globals.cpp index 25fabb5ead..312f8d0d59 100644 --- a/globals.cpp +++ b/globals.cpp @@ -49,5 +49,7 @@ int vendor_packet_process; int enable_vendor_packet; /* check available system memory before allocation */ bool check_avail_sysram = false; +/* enable 128MB sub-allocator in libhsakmt, default: disable */ +int enable_thunk_sub_allocator = 0; -size_t max_single_alloc_size = 0; \ No newline at end of file +size_t max_single_alloc_size = 0; diff --git a/libhsakmt.h b/libhsakmt.h index 392db59afa..c6c4ffe565 100644 --- a/libhsakmt.h +++ b/libhsakmt.h @@ -48,6 +48,7 @@ extern int vendor_packet_process; extern int enable_vendor_packet; extern bool check_avail_sysram; extern size_t max_single_alloc_size; +extern int enable_thunk_sub_allocator; #undef HSAKMTAPI #define HSAKMTAPI __attribute__((visibility ("default"))) diff --git a/memory.cpp b/memory.cpp index 2b65def00b..57b7710fc7 100644 --- a/memory.cpp +++ b/memory.cpp @@ -278,7 +278,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtAllocMemoryAlign(HSAuint32 PreferredNode, void **MemoryAddress) { return hsaKmtAllocMemoryAlignInternal(PreferredNode, SizeInBytes, Alignment, MemFlags, - MemoryAddress); + MemoryAddress, + !enable_thunk_sub_allocator); } HSAKMT_STATUS hsaKmtFreeMemoryInternal(void *MemoryAddress, diff --git a/openclose.cpp b/openclose.cpp index 55f48c1e7e..6bf3ded56f 100644 --- a/openclose.cpp +++ b/openclose.cpp @@ -132,6 +132,10 @@ static HSAKMT_STATUS init_vars_from_env(void) { if (envvar) check_avail_sysram = !strcmp(envvar, "1"); + envvar = getenv("WSL_ENABLE_THUNK_SUB_ALLOCATOR"); + if (envvar) + enable_thunk_sub_allocator = atoi(envvar); + return HSAKMT_STATUS_SUCCESS; }