Add support for contiguous memory allocations
Support contiguous physical memory allocation flag. Allocations with this flag will have contiguous physical memory. This is dependent on KFD support for this flag and the AllocateKfdMemory(..) function call will fail when it is not supported. Change-Id: I6c51c8b061f7b026fdcc2aa2c37c74ecc13d95b6
This commit is contained in:
@@ -104,6 +104,7 @@ class MemoryRegion : public Checked<0x9C961F19EE175BB3> {
|
||||
// Note: The node_id needs to be the node_id of the device even though this is allocating
|
||||
// system memory
|
||||
AllocateGTTAccess = (1 << 9),
|
||||
AllocateContiguous = (1 << 10), // Physically contiguous memory
|
||||
};
|
||||
|
||||
typedef uint32_t AllocateFlags;
|
||||
|
||||
@@ -209,6 +209,12 @@ hsa_status_t MemoryRegion::AllocateImpl(size_t& size, AllocateFlags alloc_flags,
|
||||
kmt_alloc_flags.ui32.NoSubstitute = (alloc_flags & AllocatePinned ? 1 : kmt_alloc_flags.ui32.NoSubstitute);
|
||||
|
||||
kmt_alloc_flags.ui32.GTTAccess = (alloc_flags & AllocateGTTAccess ? 1 : kmt_alloc_flags.ui32.GTTAccess);
|
||||
if (IsLocalMemory()) {
|
||||
// Allocate physically contiguous memory - AllocateKfdMemory function call will fail
|
||||
// if this flag is not supported in KFD.
|
||||
kmt_alloc_flags.ui32.Contiguous =
|
||||
(alloc_flags & AllocateContiguous ? 1 : kmt_alloc_flags.ui32.Contiguous);
|
||||
}
|
||||
|
||||
// Only allow using the suballocator for ordinary VRAM.
|
||||
if (IsLocalMemory() && !kmt_alloc_flags.ui32.NoAddress) {
|
||||
|
||||
@@ -761,7 +761,7 @@ hsa_status_t hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, siz
|
||||
TRY;
|
||||
IS_OPEN();
|
||||
|
||||
if (size == 0 || ptr == NULL || (flags > HSA_AMD_MEMORY_POOL_PCIE_FLAG)) {
|
||||
if (size == 0 || ptr == NULL) {
|
||||
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
@@ -774,7 +774,11 @@ hsa_status_t hsa_amd_memory_pool_allocate(hsa_amd_memory_pool_t memory_pool, siz
|
||||
|
||||
MemoryRegion::AllocateFlags alloc_flag = core::MemoryRegion::AllocateRestrict;
|
||||
|
||||
if (flags == HSA_AMD_MEMORY_POOL_PCIE_FLAG) alloc_flag |= core::MemoryRegion::AllocatePCIeRW;
|
||||
if (flags & HSA_AMD_MEMORY_POOL_PCIE_FLAG)
|
||||
alloc_flag |= core::MemoryRegion::AllocatePCIeRW;
|
||||
|
||||
if (flags & HSA_AMD_MEMORY_POOL_CONTIGUOUS_FLAG)
|
||||
alloc_flag |= core::MemoryRegion::AllocateContiguous;
|
||||
|
||||
#ifdef SANITIZER_AMDGPU
|
||||
alloc_flag |= core::MemoryRegion::AllocateAsan;
|
||||
|
||||
@@ -1182,7 +1182,11 @@ typedef enum hsa_amd_memory_pool_flag_s {
|
||||
* connection. Atomic memory operations on these memory buffers are not
|
||||
* guaranteed to be visible at system scope.
|
||||
*/
|
||||
HSA_AMD_MEMORY_POOL_PCIE_FLAG = 1,
|
||||
HSA_AMD_MEMORY_POOL_PCIE_FLAG = (1 << 0),
|
||||
/**
|
||||
* Allocates physically contiguous memory
|
||||
*/
|
||||
HSA_AMD_MEMORY_POOL_CONTIGUOUS_FLAG = (1 << 1),
|
||||
|
||||
} hsa_amd_memory_pool_flag_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user