Add suballocator for ordinary VRAM allocations smaller than 2MB.
Track pointer info for sub 2MB fragment allocations in allocation_map_. Add fragment support to IPC. Change-Id: I00cfc2e2fa289aac90a4718c392f9bb056a61a87
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
|
||||
#include "core/inc/agent.h"
|
||||
#include "core/inc/memory_region.h"
|
||||
#include "core/util/simple_heap.h"
|
||||
|
||||
#include "inc/hsa_ext_amd.h"
|
||||
|
||||
@@ -181,7 +182,21 @@ class MemoryRegion : public core::MemoryRegion {
|
||||
HSAuint64 virtual_size_;
|
||||
|
||||
static const size_t kPageSize_ = 4096;
|
||||
|
||||
class BlockAllocator {
|
||||
private:
|
||||
MemoryRegion& region_;
|
||||
static const size_t block_size_ = 2 * 1024 * 1024; // 2MB blocks.
|
||||
public:
|
||||
explicit BlockAllocator(MemoryRegion& region) : region_(region) {}
|
||||
void* alloc(size_t request_size, size_t& allocated_size) const;
|
||||
void free(void* ptr, size_t length) const { region_.Free(ptr, length); }
|
||||
size_t block_size() const { return block_size_; }
|
||||
};
|
||||
|
||||
mutable SimpleHeap<BlockAllocator> fragment_allocator_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // header guard
|
||||
|
||||
@@ -85,6 +85,7 @@ class MemoryRegion : public Checked<0x9C961F19EE175BB3> {
|
||||
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
|
||||
AllocateDirect = (1 << 3), // Bypass fragment cache.
|
||||
};
|
||||
|
||||
typedef uint32_t AllocateFlags;
|
||||
|
||||
@@ -264,8 +264,14 @@ class Runtime {
|
||||
|
||||
hsa_status_t InteropUnmap(void* ptr);
|
||||
|
||||
struct PtrInfoBlockData {
|
||||
void* base;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
hsa_status_t PtrInfo(void* ptr, hsa_amd_pointer_info_t* info, void* (*alloc)(size_t),
|
||||
uint32_t* num_agents_accessible, hsa_agent_t** accessible);
|
||||
uint32_t* num_agents_accessible, hsa_agent_t** accessible,
|
||||
PtrInfoBlockData* block_info = nullptr);
|
||||
|
||||
hsa_status_t SetPtrInfoData(void* ptr, void* userptr);
|
||||
|
||||
@@ -315,12 +321,13 @@ class Runtime {
|
||||
static void AsyncEventsLoop(void*);
|
||||
|
||||
struct AllocationRegion {
|
||||
AllocationRegion() : region(NULL), size(0) {}
|
||||
AllocationRegion() : region(NULL), size(0), user_ptr(nullptr) {}
|
||||
AllocationRegion(const MemoryRegion* region_arg, size_t size_arg)
|
||||
: region(region_arg), size(size_arg) {}
|
||||
: region(region_arg), size(size_arg), user_ptr(nullptr) {}
|
||||
|
||||
const MemoryRegion* region;
|
||||
size_t size;
|
||||
void* user_ptr;
|
||||
};
|
||||
|
||||
struct AsyncEventsControl {
|
||||
|
||||
Reference in New Issue
Block a user