Fix memory pool ALLOC_REC_GRANULE query

Also changed enum value to leave gap between enums that only exist in
hsa_region_info_t and enums that exist in both hsa_amd_memory_pool_info_t

Change-Id: I8f9f31200de66648e9328e4203ab283068c993f0


[ROCm/ROCR-Runtime commit: 4317f8dece]
This commit is contained in:
David Yat Sin
2023-08-22 17:23:22 +00:00
parent 777df5c6dc
commit 0637810752
2 changed files with 25 additions and 26 deletions
@@ -420,21 +420,6 @@ hsa_status_t MemoryRegion::GetInfo(hsa_region_info_t attribute,
case HSA_AMD_REGION_INFO_MAX_CLOCK_FREQUENCY:
*((uint32_t*)value) = MaxMemCloc();
break;
case HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE:
switch (mem_props_.HeapType) {
case HSA_HEAPTYPE_SYSTEM:
*((size_t*)value) = kPageSize_;
break;
case HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE:
case HSA_HEAPTYPE_FRAME_BUFFER_PUBLIC:
*((size_t*)value) = core::Runtime::runtime_singleton_->flag().disable_fragment_alloc()
? kPageSize_ : fragment_allocator_.default_block_size();
break;
default:
*((size_t*)value) = 0;
break;
}
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
@@ -452,7 +437,6 @@ hsa_status_t MemoryRegion::GetPoolInfo(hsa_amd_memory_pool_info_t attribute,
case HSA_AMD_MEMORY_POOL_INFO_SIZE:
case HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED:
case HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE:
case HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE:
case HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT:
return GetInfo(static_cast<hsa_region_info_t>(attribute), value);
case HSA_AMD_MEMORY_POOL_INFO_ACCESSIBLE_BY_ALL:
@@ -480,6 +464,22 @@ hsa_status_t MemoryRegion::GetPoolInfo(hsa_amd_memory_pool_info_t attribute,
else
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
case HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE:
switch (mem_props_.HeapType) {
case HSA_HEAPTYPE_SYSTEM:
*((size_t*)value) = kPageSize_;
break;
case HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE:
case HSA_HEAPTYPE_FRAME_BUFFER_PUBLIC:
*((size_t*)value) = core::Runtime::runtime_singleton_->flag().disable_fragment_alloc()
? kPageSize_
: fragment_allocator_.default_block_size();
break;
default:
*((size_t*)value) = 0;
break;
}
break;
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
@@ -1104,14 +1104,6 @@ typedef enum {
* must be a power of 2. The type of this attribute is size_t.
*/
HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALIGNMENT = 7,
/**
* Internal block size for allocations. This would also be the recommended
* granularity size for allocations as this prevents internal fragmentation.
* The value of this attribute is only defined if
* ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for this pool.
* The size of this attribute is size_t.
*/
HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE = 8,
/**
* This memory_pool can be made directly accessible by all the agents in the
* system (::hsa_amd_agent_memory_pool_get_info does not return
@@ -1129,7 +1121,14 @@ typedef enum {
* is hsa_amd_memory_pool_location_t.
*/
HSA_AMD_MEMORY_POOL_INFO_LOCATION = 17,
/**
* Internal block size for allocations. This would also be the recommended
* granularity size for allocations as this prevents internal fragmentation.
* The value of this attribute is only defined if
* ::HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_ALLOWED is true for this pool.
* The size of this attribute is size_t.
*/
HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE = 18,
} hsa_amd_memory_pool_info_t;
/**
@@ -2780,7 +2779,7 @@ typedef enum {
* @p size must be a aligned to allocation granule size for this memory pool, see
* HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_GRANULE
* To minimize internal memory fragmentation, align the size to the recommended allocation granule
* size, see HSA_AMD_REGION_INFO_RUNTIME_ALLOC_RECOMMENDED_GRANULE
* size, see HSA_AMD_MEMORY_POOL_INFO_RUNTIME_ALLOC_REC_GRANULE
*
* @param[in] pool memory to use
* @param[in] size of the memory allocation