Skip to content

Commit faac50c

Browse files
authored
SWDEV-528860 - reserve some memory in visible frame buffer (#251)
1 parent b434fbe commit faac50c

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

rocclr/device/pal/paldevice.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,23 @@ bool Device::create(Pal::IDevice* device) {
998998
// Fill the device info structure
999999
fillDeviceInfo(properties(), heaps_, 16 * Ki, numComputeEngines(), numExclusiveComputeEngines(), iDev());
10001000

1001+
// Reserve percentage memory for large frame buffer.
1002+
// Reserve a threshold size for small frame buffer, used by page table for remote memory mapping
1003+
Pal::gpusize invisibleSize = heaps_[Pal::GpuHeapInvisible].logicalSize;
1004+
Pal::gpusize visibleSize = heaps_[Pal::GpuHeapLocal].logicalSize;
1005+
1006+
Pal::gpusize maxInvisibleAllocation = std::min((invisibleSize / 100) * 98,
1007+
invisibleSize < 128 * Mi? 0: invisibleSize - 128 * Mi);
1008+
Pal::gpusize maxVisibleAllocation = std::min((visibleSize / 100) * 98,
1009+
visibleSize < 128 * Mi? 0: visibleSize - 128 * Mi);
1010+
1011+
if (invisibleSize < visibleSize && invisibleSize > 0) {
1012+
// Page table is in invisible and its size is smaller. Invisible is the only deciding factor
1013+
maxFrameBufferAllocation_ = maxInvisibleAllocation;
1014+
} else {
1015+
maxFrameBufferAllocation_ = std::max(maxInvisibleAllocation, maxVisibleAllocation);
1016+
}
1017+
10011018
if (!ValidateComgr()) {
10021019
LogError("Code object manager initialization failed!");
10031020
return false;

rocclr/device/pal/paldevice.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,8 @@ class Device : public NullDevice {
675675
//! Allocates hidden heap for device memory allocations
676676
void HiddenHeapAlloc(const VirtualGPU& gpu);
677677

678-
const Pal::GpuMemoryHeapProperties& GetGpuHeapInvisible() const {
679-
return heaps_[Pal::GpuHeapInvisible];
678+
Pal::gpusize GetMaxFrameBuffer() const {
679+
return maxFrameBufferAllocation_;
680680
}
681681

682682
Pal::gpusize TotalAlloc() const {
@@ -760,6 +760,7 @@ class Device : public NullDevice {
760760
ICaptureMgr* captureMgr_; //!< RGP/UberTrace capture manager
761761
Pal::GpuMemoryHeapProperties
762762
heaps_[Pal::GpuHeapCount]; //!< Information about heaps, returned from PAL
763+
Pal::gpusize maxFrameBufferAllocation_; //!< To reserve some memory in frame buffer
763764
std::map<Pal::IQueue*, QueueRecycleInfo*> queue_pool_; //!< Pool of PAL queues for recycling
764765
amd::Program* trap_handler_ = nullptr; //!< Trap handler program for debugger setup
765766
};

rocclr/device/pal/palmemory.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ bool Memory::create(Resource::MemoryType memType, Resource::CreateParams* params
116116
}
117117

118118
if (amd::IS_HIP && dev().settings().apuSystem_) {
119-
const Pal::GpuMemoryHeapProperties& invisibleHeap = dev().GetGpuHeapInvisible();
120119
Pal::gpusize totalAlloc = dev().TotalAlloc();
121-
if (memType == Local && (totalAlloc > invisibleHeap.logicalSize)) {
120+
if (memType == Local && totalAlloc > dev().GetMaxFrameBuffer()) {
122121
memType = RemoteUSWC;
123122
}
124123
}

0 commit comments

Comments
 (0)