SWDEV-353281 - Add support for MemPool in graphs
Implement hipDeviceGetGraphMemAttribute, hipDeviceSetGraphMemAttribute and hipDeviceGraphMemTrim Change-Id: I4f8fc1250ce1e8b7636d43d59ba7343158e45088
Este commit está contenido en:
1 padre
d0920c5959
commit
314bdba632
5 files changed
+58
-33
No files matched your search
@@ -44,7 +44,7 @@ hip::Stream* Device::GetNullStream() {
|
||||
if (null_stream_ == nullptr) {
|
||||
null_stream_ = new Stream(this, Stream::Priority::Normal, 0, true);
|
||||
}
|
||||
|
||||
|
||||
if (null_stream_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -60,6 +60,18 @@ bool Device::Create() {
|
||||
if (default_mem_pool_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create graph memory pool
|
||||
graph_mem_pool_ = new MemoryPool(this);
|
||||
if (graph_mem_pool_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t max_size = std::numeric_limits<uint64_t>::max();
|
||||
// Use maximum value to hold memory, because current implementation doesn't support VM
|
||||
// Note: the call for the threshold is always successful
|
||||
auto error = graph_mem_pool_->SetAttribute(hipMemPoolAttrReleaseThreshold, &max_size);
|
||||
|
||||
// Current is default pool after device creation
|
||||
current_mem_pool_ = default_mem_pool_;
|
||||
return true;
|
||||
@@ -85,7 +97,7 @@ void Device::RemoveMemoryPool(MemoryPool* pool) {
|
||||
bool Device::FreeMemory(amd::Memory* memory, Stream* stream) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
// Search for memory in the entire list of pools
|
||||
for (auto& it : mem_pools_) {
|
||||
for (auto it : mem_pools_) {
|
||||
if (it->FreeMemory(memory, stream)) {
|
||||
return true;
|
||||
}
|
||||
@@ -97,7 +109,7 @@ bool Device::FreeMemory(amd::Memory* memory, Stream* stream) {
|
||||
void Device::ReleaseFreedMemory(Stream* stream) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
// Search for memory in the entire list of pools
|
||||
for (auto& it : mem_pools_) {
|
||||
for (auto it : mem_pools_) {
|
||||
it->ReleaseFreedMemory(stream);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +118,7 @@ void Device::ReleaseFreedMemory(Stream* stream) {
|
||||
void Device::RemoveStreamFromPools(Stream* stream) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
// Update all pools with the destroyed stream
|
||||
for (auto& it : mem_pools_) {
|
||||
for (auto it : mem_pools_) {
|
||||
it->RemoveStream(stream);
|
||||
}
|
||||
}
|
||||
@@ -135,6 +147,10 @@ Device::~Device() {
|
||||
default_mem_pool_->release();
|
||||
}
|
||||
|
||||
if (graph_mem_pool_ != nullptr) {
|
||||
graph_mem_pool_->release();
|
||||
}
|
||||
|
||||
if (null_stream_!= nullptr) {
|
||||
delete null_stream_;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user