Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/gpgmm/common/JSONSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ namespace gpgmm {
return dict;
}

// static
JSONDict JSONSerializer::Serialize(const MemoryAllocationInfo& info) {
JSONDict dict;
dict.AddItem("SizeInBytes", info.SizeInBytes);
dict.AddItem("Alignment", info.Alignment);
return dict;
}

// static
JSONDict JSONSerializer::Serialize(const void* objectPtr) {
JSONDict dict;
Expand Down
2 changes: 0 additions & 2 deletions src/gpgmm/common/JSONSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace gpgmm {
// Forward declare common types.
struct MemoryPoolInfo;
struct MemoryAllocatorStats;
struct MemoryAllocationInfo;
struct MemoryAllocationRequest;
struct EventMessageInfo;

Expand All @@ -32,7 +31,6 @@ namespace gpgmm {
static JSONDict Serialize(const EventMessageInfo& info);
static JSONDict Serialize(const MemoryAllocatorStats& info);
static JSONDict Serialize(const MemoryAllocationRequest& desc);
static JSONDict Serialize(const MemoryAllocationInfo& info);
static JSONDict Serialize(const MemoryPoolInfo& desc);
static JSONDict Serialize(const void* objectPtr);
};
Expand Down
26 changes: 8 additions & 18 deletions src/gpgmm/common/MemoryAllocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,39 @@ namespace gpgmm {
mMemory(nullptr),
mOffset(kInvalidOffset),
mMethod(AllocationMethod::kUndefined),
mBlock(nullptr),
mMappedPointer(nullptr) {
#ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS
mRequestSize(kInvalidSize),
#endif
mBlock(nullptr) {
}

MemoryAllocation::MemoryAllocation(MemoryAllocator* allocator,
MemoryBase* memory,
uint64_t offset,
AllocationMethod method,
MemoryBlock* block,
uint64_t requestSize,
uint8_t* mappedPointer)
uint64_t requestSize)
: mAllocator(allocator),
mMemory(memory),
mOffset(offset),
mMethod(method),
mBlock(block),
#ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS
mRequestSize(requestSize),
#endif
mMappedPointer(mappedPointer) {
mBlock(block) {
}

MemoryAllocation::MemoryAllocation(MemoryAllocator* allocator,
MemoryBase* memory,
uint64_t requestSize,
uint8_t* mappedPointer)
uint64_t requestSize)
: mAllocator(allocator),
mMemory(memory),
mOffset(0),
mMethod(AllocationMethod::kStandalone),
mBlock(nullptr),
#ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS
mRequestSize(requestSize),
#endif
mMappedPointer(mappedPointer) {
mBlock(nullptr) {
}

bool MemoryAllocation::operator==(const MemoryAllocation& other) const {
Expand All @@ -72,18 +70,10 @@ namespace gpgmm {
return !operator==(other);
}

MemoryAllocationInfo MemoryAllocation::GetInfo() const {
return {GetSize(), GetAlignment()};
}

MemoryBase* MemoryAllocation::GetMemory() const {
return mMemory;
}

uint8_t* MemoryAllocation::GetMappedPointer() const {
return mMappedPointer;
}

MemoryAllocator* MemoryAllocation::GetAllocator() const {
return mAllocator;
}
Expand Down
21 changes: 6 additions & 15 deletions src/gpgmm/common/MemoryAllocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ namespace gpgmm {
struct MemoryBlock;
class MemoryAllocator;

struct MemoryAllocationInfo {
uint64_t SizeInBytes;
uint64_t Alignment;
};

// Represents a location and range in memory.
class MemoryAllocation {
public:
Expand All @@ -43,14 +38,10 @@ namespace gpgmm {
uint64_t offset,
AllocationMethod method,
MemoryBlock* block,
uint64_t requestSize,
uint8_t* mappedPointer = nullptr);
uint64_t requestSize);

// Constructs a "standalone" memory allocation.
MemoryAllocation(MemoryAllocator* allocator,
MemoryBase* memory,
uint64_t requestSize,
uint8_t* mappedPointer = nullptr);
MemoryAllocation(MemoryAllocator* allocator, MemoryBase* memory, uint64_t requestSize);

virtual ~MemoryAllocation() = default;

Expand All @@ -59,9 +50,7 @@ namespace gpgmm {
bool operator==(const MemoryAllocation&) const;
bool operator!=(const MemoryAllocation& other) const;

MemoryAllocationInfo GetInfo() const;
MemoryBase* GetMemory() const;
uint8_t* GetMappedPointer() const;
MemoryAllocator* GetAllocator() const;
uint64_t GetSize() const;
uint64_t GetRequestSize() const;
Expand All @@ -79,10 +68,12 @@ namespace gpgmm {
MemoryBase* mMemory;
uint64_t mOffset; // Offset always local to the memory.
AllocationMethod mMethod;
MemoryBlock* mBlock;

#ifdef GPGMM_ENABLE_MEMORY_ALIGN_CHECKS
uint64_t mRequestSize;
uint8_t* mMappedPointer;
#endif

MemoryBlock* mBlock;
};
} // namespace gpgmm

Expand Down