SWDEV-311271 - Make sure memory pool can accept default stream

Add lock protection for access to the pool list.
Remove destroyed stream from the list of the safe streams

Change-Id: I1863b89bd3f5e188c161227cc790c3adaf72cc58


[ROCm/clr commit: 5957ff9f7b]
This commit is contained in:
German Andryeyev
2022-04-14 19:04:01 -04:00
rodzic 5516c2d12e
commit 3de1a9e36c
6 zmienionych plików z 63 dodań i 8 usunięć
@@ -120,6 +120,13 @@ bool Heap::ReleaseAllMemory(hip::Stream* stream) {
return true;
}
// ================================================================================================
void Heap::RemoveStream(hip::Stream* stream) {
for (auto it = allocations_.begin(); it != allocations_.end();) {
it->second.safe_streams_.erase(stream);
}
}
// ================================================================================================
void* MemoryPool::AllocateMemory(size_t size, hip::Stream* stream) {
amd::ScopedLock lock(lock_pool_ops_);
@@ -197,6 +204,13 @@ void MemoryPool::ReleaseFreedMemory(hip::Stream* stream) {
free_heap_.ReleaseAllMemory(stream);
}
// ================================================================================================
void MemoryPool::RemoveStream(hip::Stream* stream) {
amd::ScopedLock lock(lock_pool_ops_);
free_heap_.RemoveStream(stream);
}
// ================================================================================================
void MemoryPool::TrimTo(size_t min_bytes_to_hold) {
amd::ScopedLock lock(lock_pool_ops_);