Refactor: Consolidate calls to hsaKmtAllocMemory

Route all device-visible system memory allocations through system_allocator.

Change-Id: I5e90a1bf491e432678a6d8ab1f9f3770734cbda1


[ROCm/ROCR-Runtime commit: 74f5aca93d]
이 커밋은 다음에 포함됨:
Jay Cornwall
2016-08-22 20:19:21 -05:00
부모 7e2179da7b
커밋 d5ecfae62f
17개의 변경된 파일89개의 추가작업 그리고 153개의 파일을 삭제
-1
파일 보기
@@ -49,7 +49,6 @@
#include <vector>
#include "core/inc/runtime.h"
#include "core/inc/checked.h"
#include "core/inc/isa.h"
#include "core/inc/queue.h"
+1
파일 보기
@@ -44,6 +44,7 @@
#define HSA_RUNTIME_CORE_INC_AMD_BLIT_KERNEL_H_
#include <map>
#include <mutex>
#include <stdint.h>
#include "core/inc/blit.h"
+1 -3
파일 보기
@@ -99,9 +99,7 @@ class MemoryRegion : public core::MemoryRegion {
~MemoryRegion();
hsa_status_t Allocate(size_t size, void** address) const;
hsa_status_t Allocate(bool restrict_access, size_t size,
hsa_status_t Allocate(size_t size, AllocateFlags alloc_flags,
void** address) const;
hsa_status_t Free(void* address, size_t size) const;
+2 -1
파일 보기
@@ -43,7 +43,8 @@
#ifndef HSA_RUNTME_CORE_INC_CHECKED_H_
#define HSA_RUNTME_CORE_INC_CHECKED_H_
#include "stdint.h"
#include <stdint.h>
#include <stdlib.h>
namespace core {
+11 -2
파일 보기
@@ -47,7 +47,6 @@
#include <vector>
#include "core/inc/runtime.h"
#include "core/inc/agent.h"
#include "core/inc/checked.h"
@@ -81,7 +80,17 @@ class MemoryRegion : public Checked<0x9C961F19EE175BB3> {
return reinterpret_cast<MemoryRegion*>(region.handle);
}
virtual hsa_status_t Allocate(size_t size, void** address) const = 0;
enum AllocateEnum {
AllocateNoFlags = 0,
AllocateRestrict = (1 << 0), // Don't map system memory to GPU agents
AllocateExecutable = (1 << 1), // Set executable permission
AllocateDoubleMap = (1 << 2), // Map twice VA allocation to backing store
};
typedef uint32_t AllocateFlags;
virtual hsa_status_t Allocate(size_t size, AllocateFlags alloc_flags,
void** address) const = 0;
virtual hsa_status_t Free(void* address, size_t size) const = 0;
-1
파일 보기
@@ -48,7 +48,6 @@
#include "core/common/shared.h"
#include "core/inc/runtime.h"
#include "core/inc/checked.h"
#include "core/util/utils.h"
+6 -15
파일 보기
@@ -151,25 +151,14 @@ class Runtime {
///
/// @param [in] region Pointer to region object.
/// @param [in] size Allocation size in bytes.
/// @param [in] alloc_flags Modifiers to pass to MemoryRegion allocator.
/// @param [out] address Pointer to store the allocation result.
///
/// @retval ::HSA_STATUS_SUCCESS If allocation is successful.
hsa_status_t AllocateMemory(const MemoryRegion* region, size_t size,
MemoryRegion::AllocateFlags alloc_flags,
void** address);
/// @brief Allocate memory on a particular region with option to restrict
/// access to the owning agent.
///
/// @param [in] restrict_access If true, the allocation result would only be
/// accessible to the agent(s) that own the region object.
/// @param [in] region Pointer to region object.
/// @param [in] size Allocation size in bytes.
/// @param [out] address Pointer to store the allocation result.
///
/// @retval ::HSA_STATUS_SUCCESS If allocation is successful.
hsa_status_t AllocateMemory(bool restrict_access, const MemoryRegion* region,
size_t size, void** address);
/// @brief Free memory previously allocated with AllocateMemory.
///
/// @param [in] ptr Address of the memory to be freed.
@@ -292,7 +281,8 @@ class Runtime {
amd::hsa::code::AmdHsaCodeManager* code_manager() { return &code_manager_; }
std::function<void*(size_t, size_t)>& system_allocator() {
std::function<void*(size_t, size_t, MemoryRegion::AllocateFlags)>&
system_allocator() {
return system_allocator_;
}
@@ -446,7 +436,8 @@ class Runtime {
std::map<const void*, AllocationRegion> allocation_map_;
// Allocator using ::system_region_
std::function<void*(size_t, size_t)> system_allocator_;
std::function<void*(size_t, size_t, MemoryRegion::AllocateFlags)>
system_allocator_;
// Deallocator using ::system_region_
std::function<void(void*)> system_deallocator_;