Skip to content

Commit b72d8da

Browse files
SWDEV-447525 - maxSize param for Mem pool props.
Change-Id: Ib743611a66921aeaa449b6622b933cc8b9190d87
1 parent f1adecd commit b72d8da

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

hipamd/src/hip_mempool_impl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ void* MemoryPool::AllocateMemory(size_t size, Stream* stream, void* dptr) {
171171
void* dev_ptr = nullptr;
172172
amd::Memory* memory = free_heap_.FindMemory(size, stream, Opportunistic(), dptr);
173173
if (memory == nullptr) {
174+
if (Properties().maxSize != 0 && (max_total_size_ + size) > Properties().maxSize) {
175+
return nullptr;
176+
}
174177
amd::Context* context = device_->asContext();
175178
const auto& dev_info = context->devices()[0]->info();
176179
if (dev_info.maxMemAllocSize_ < size) {

hipamd/src/hip_mempool_impl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ class MemoryPool : public amd::ReferenceCountedObject {
215215
.handleTypes = hipMemHandleTypeNone,
216216
.location = {.type = hipMemLocationTypeDevice, .id = device_->deviceId()},
217217
.win32SecurityAttributes = nullptr,
218+
.maxSize = 0;
218219
.reserved = {}};
219220
}
220221
state_.interprocess_ = properties_.handleTypes != hipMemHandleTypeNone;

0 commit comments

Comments
 (0)