SWDEV-485763 - Fix memory leaks in various unit tests
Fix memory leaks by adding missing destroy calls for
events, streams, and graphs at the end of tests.
Ensure that every test case executes destroy calls,
regardless of whether it passes or fails.
Change-Id: I814e35c528d90ed2abb34d77377f1a7fd3f1f11c
[ROCm/hip-tests commit: 9cffda4ebb]
Этот коммит содержится в:
1 родитель
d9482cf69c
Коммит
fe9860bd47
33 files changed
+142
-38
No files matched your search
@@ -181,6 +181,9 @@ void Memcpy3DDeviceToDeviceShell(F memcpy_func, hipStream_t kernel_stream = null
|
||||
}
|
||||
if constexpr (enable_peer_access) {
|
||||
if (src_device == dst_device) {
|
||||
if (device_count > 0 && kernel_stream != nullptr && kernel_stream != hipStreamPerThread) {
|
||||
HIP_CHECK(hipStreamDestroy(kernel_stream));
|
||||
}
|
||||
return;
|
||||
}
|
||||
int can_access_peer = 0;
|
||||
@@ -189,6 +192,9 @@ void Memcpy3DDeviceToDeviceShell(F memcpy_func, hipStream_t kernel_stream = null
|
||||
std::string msg = "Skipped as peer access cannot be enabled between devices " +
|
||||
std::to_string(src_device) + " " + std::to_string(dst_device);
|
||||
HipTest::HIP_SKIP_TEST(msg.c_str());
|
||||
if (device_count > 0 && kernel_stream != nullptr && kernel_stream != hipStreamPerThread) {
|
||||
HIP_CHECK(hipStreamDestroy(kernel_stream));
|
||||
}
|
||||
return;
|
||||
}
|
||||
HIP_CHECK(hipDeviceEnablePeerAccess(dst_device, 0));
|
||||
@@ -888,4 +894,4 @@ void DrvMemcpy3DArrayDeviceShell(F memcpy_func, const hipStream_t kernel_stream
|
||||
};
|
||||
PitchedMemoryVerify(host_alloc.ptr(), extent.width, extent.width / sizeof(int), extent.height,
|
||||
extent.depth, f);
|
||||
}
|
||||
}
|
||||
@@ -307,8 +307,10 @@ class StreamGuard {
|
||||
break;
|
||||
case Streams::withFlags:
|
||||
HIP_CHECK(hipStreamCreateWithFlags(&stream_, flags_));
|
||||
break;
|
||||
case Streams::withPriority:
|
||||
HIP_CHECK(hipStreamCreateWithPriority(&stream_, flags_, priority_));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +320,7 @@ class StreamGuard {
|
||||
|
||||
StreamGuard& operator=(StreamGuard&& o) {
|
||||
if (this != &o) {
|
||||
if (stream_type_ == Streams::created) {
|
||||
if (stream_type_ >= Streams::created) {
|
||||
static_cast<void>(hipStreamDestroy(stream_));
|
||||
}
|
||||
|
||||
@@ -337,7 +339,7 @@ class StreamGuard {
|
||||
}
|
||||
|
||||
~StreamGuard() {
|
||||
if (stream_type_ == Streams::created && stream_ != nullptr) {
|
||||
if (stream_type_ >= Streams::created && stream_ != nullptr) {
|
||||
static_cast<void>(hipStreamDestroy(stream_));
|
||||
}
|
||||
}
|
||||
@@ -361,7 +363,9 @@ class EventsGuard {
|
||||
EventsGuard(EventsGuard&&) = delete;
|
||||
|
||||
~EventsGuard() {
|
||||
for (auto& e : events_) static_cast<void>(hipEventDestroy(e));
|
||||
for (auto& e : events_) {
|
||||
static_cast<void>(hipEventDestroy(e));
|
||||
}
|
||||
}
|
||||
|
||||
hipEvent_t& operator[](int index) { return events_[index]; }
|
||||
|
||||
Reference in new issue
Block a user