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
4 changes: 2 additions & 2 deletions src/gpgmm/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ source_set("gpgmm_common_sources") {
"BuddyMemoryAllocator.h",
"ConditionalMemoryAllocator.cpp",
"ConditionalMemoryAllocator.h",
"DedicatedMemoryAllocator.cpp",
"DedicatedMemoryAllocator.h",
"Defaults.h",
"Error.h",
"EventMessage.cpp",
Expand Down Expand Up @@ -219,8 +221,6 @@ source_set("gpgmm_common_sources") {
"SlabBlockAllocator.h",
"SlabMemoryAllocator.cpp",
"SlabMemoryAllocator.h",
"StandaloneMemoryAllocator.cpp",
"StandaloneMemoryAllocator.h",
"TraceEvent.cpp",
"TraceEvent.h",
"WorkerThread.cpp",
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ target_sources(gpgmm_common PRIVATE
"BuddyMemoryAllocator.h"
"ConditionalMemoryAllocator.cpp"
"ConditionalMemoryAllocator.h"
"DedicatedMemoryAllocator.cpp"
"DedicatedMemoryAllocator.h"
"Defaults.h"
"Error.h"
"EventTraceWriter.cpp"
Expand Down Expand Up @@ -52,8 +54,6 @@ target_sources(gpgmm_common PRIVATE
"SlabBlockAllocator.h"
"SlabMemoryAllocator.cpp"
"SlabMemoryAllocator.h"
"StandaloneMemoryAllocator.cpp"
"StandaloneMemoryAllocator.h"
"TraceEvent.cpp"
"TraceEvent.h"
"WorkerThread.cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "gpgmm/common/StandaloneMemoryAllocator.h"
#include "gpgmm/common/DedicatedMemoryAllocator.h"

#include "gpgmm/common/TraceEvent.h"

namespace gpgmm {

StandaloneMemoryAllocator::StandaloneMemoryAllocator(
DedicatedMemoryAllocator::DedicatedMemoryAllocator(
std::unique_ptr<MemoryAllocator> memoryAllocator)
: MemoryAllocator(std::move(memoryAllocator)) {
}

std::unique_ptr<MemoryAllocation> StandaloneMemoryAllocator::TryAllocateMemory(
std::unique_ptr<MemoryAllocation> DedicatedMemoryAllocator::TryAllocateMemory(
const MemoryAllocationRequest& request) {
TRACE_EVENT0(TraceEventCategory::Default, "StandaloneMemoryAllocator.TryAllocateMemory");
TRACE_EVENT0(TraceEventCategory::Default, "DedicatedMemoryAllocator.TryAllocateMemory");

std::lock_guard<std::mutex> lock(mMutex);

Expand All @@ -42,8 +42,8 @@ namespace gpgmm {
new MemoryBlock{0, request.SizeInBytes}, request.SizeInBytes);
}

void StandaloneMemoryAllocator::DeallocateMemory(std::unique_ptr<MemoryAllocation> allocation) {
TRACE_EVENT0(TraceEventCategory::Default, "StandaloneMemoryAllocator.DeallocateMemory");
void DedicatedMemoryAllocator::DeallocateMemory(std::unique_ptr<MemoryAllocation> allocation) {
TRACE_EVENT0(TraceEventCategory::Default, "DedicatedMemoryAllocator.DeallocateMemory");

std::lock_guard<std::mutex> lock(mMutex);

Expand All @@ -55,18 +55,18 @@ namespace gpgmm {
GetNextInChain()->DeallocateMemory(std::move(allocation));
}

MemoryAllocatorInfo StandaloneMemoryAllocator::GetInfo() const {
MemoryAllocatorInfo DedicatedMemoryAllocator::GetInfo() const {
std::lock_guard<std::mutex> lock(mMutex);
MemoryAllocatorInfo result = mInfo;
result += GetNextInChain()->GetInfo();
return result;
}

uint64_t StandaloneMemoryAllocator::GetMemoryAlignment() const {
uint64_t DedicatedMemoryAllocator::GetMemoryAlignment() const {
return GetNextInChain()->GetMemoryAlignment();
}

const char* StandaloneMemoryAllocator::GetTypename() const {
return "StandaloneMemoryAllocator";
const char* DedicatedMemoryAllocator::GetTypename() const {
return "DedicatedMemoryAllocator";
}
} // namespace gpgmm
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef GPGMM_COMMON_STANDALONEMEMORYALLOCATOR_H_
#define GPGMM_COMMON_STANDALONEMEMORYALLOCATOR_H_
#ifndef GPGMM_COMMON_DEDICATEDMEMORYALLOCATOR_H_
#define GPGMM_COMMON_DEDICATEDMEMORYALLOCATOR_H_

#include "gpgmm/common/MemoryAllocator.h"

#include <memory>

namespace gpgmm {

// StandaloneMemoryAllocator sub-allocates memory with exactly one block.
class StandaloneMemoryAllocator final : public MemoryAllocator {
// DedicatedMemoryAllocator sub-allocates memory with exactly one block.
class DedicatedMemoryAllocator final : public MemoryAllocator {
public:
StandaloneMemoryAllocator(std::unique_ptr<MemoryAllocator> memoryAllocator);
DedicatedMemoryAllocator(std::unique_ptr<MemoryAllocator> memoryAllocator);

// MemoryAllocator interface
std::unique_ptr<MemoryAllocation> TryAllocateMemory(
Expand All @@ -38,4 +38,4 @@ namespace gpgmm {

} // namespace gpgmm

#endif // GPGMM_COMMON_STANDALONEMEMORYALLOCATOR_H_
#endif // GPGMM_COMMON_DEDICATEDMEMORYALLOCATOR_H_
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#include "gpgmm/d3d12/ResourceAllocatorD3D12.h"

#include "gpgmm/common/BuddyMemoryAllocator.h"
#include "gpgmm/common/DedicatedMemoryAllocator.h"
#include "gpgmm/common/Defaults.h"
#include "gpgmm/common/EventMessage.h"
#include "gpgmm/common/PooledMemoryAllocator.h"
#include "gpgmm/common/SegmentedMemoryAllocator.h"
#include "gpgmm/common/SlabMemoryAllocator.h"
#include "gpgmm/common/StandaloneMemoryAllocator.h"
#include "gpgmm/common/TraceEvent.h"
#include "gpgmm/d3d12/BackendD3D12.h"
#include "gpgmm/d3d12/BufferAllocatorD3D12.h"
Expand Down
4 changes: 2 additions & 2 deletions src/tests/perftests/MemoryAllocatorPerfTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include <benchmark/benchmark.h>

#include "gpgmm/common/BuddyMemoryAllocator.h"
#include "gpgmm/common/DedicatedMemoryAllocator.h"
#include "gpgmm/common/SegmentedMemoryAllocator.h"
#include "gpgmm/common/SizeClass.h"
#include "gpgmm/common/SlabMemoryAllocator.h"
#include "gpgmm/common/StandaloneMemoryAllocator.h"
#include "tests/DummyMemoryAllocator.h"

#include <vector>
Expand Down Expand Up @@ -128,7 +128,7 @@ BENCHMARK_DEFINE_F(SingleSizeAllocationPerfTests, BuddySystem)(benchmark::State&
}

BENCHMARK_DEFINE_F(SingleSizeAllocationPerfTests, Standalone)(benchmark::State& state) {
StandaloneMemoryAllocator allocator(std::make_unique<DummyMemoryAllocator>());
DedicatedMemoryAllocator allocator(std::make_unique<DummyMemoryAllocator>());

for (auto _ : state) {
SingleStep(state, &allocator, CreateBasicRequest(state.range(2)));
Expand Down