SWDEV-548482 - Address memory leaks in memory tests (#526)

* SWDEV-548482 - Address memory leaks in memory tests

* SWDEV-548482 - Added destroy calls

* SWDEV-548482 - Address one more memory leak

* SWDEV-548482 - Minor tweaks

* SWDEV-548482 - Run clang-format

* SWDEV-548482 - Add new lines

* SWDEV-548482 - Run clang-format

* SWDEV-548482 - Minor fix

---------

Co-authored-by: Marko Arandjelovic <Marko.Arandjelovic@amd.com>
Этот коммит содержится в:
systems-assistant[bot]
2025-09-02 17:29:29 +02:00
коммит произвёл GitHub
родитель f3a2bb07a4
Коммит 05a9a528f7
11 изменённых файлов: 51 добавлений и 29 удалений
+8 -4
Просмотреть файл
@@ -84,11 +84,12 @@ static void LaunchKrnl(int* Hmm1, size_t NumElms, int InitVal, int GpuOrdnl, int
}
static void LaunchKrnl2(int* Hmm, size_t NumElms, int InitVal, int HmmMem) {
int *ptr = nullptr, blockSize = 64, *HstPtr = nullptr;
int *ptr = nullptr, blockSize = 64;
std::unique_ptr<int[]> host_ptr;
hipStream_t strm;
HIPCHECK(hipStreamCreate(&strm));
if (HmmMem == 0) {
HstPtr = reinterpret_cast<int*>(new int[NumElms]);
host_ptr = std::make_unique<int[]>(NumElms);
HIPCHECK(hipMalloc(&ptr, (sizeof(int) * NumElms)));
} else {
HIPCHECK(hipMallocManaged(&ptr, (sizeof(int) * NumElms)));
@@ -102,9 +103,9 @@ static void LaunchKrnl2(int* Hmm, size_t NumElms, int InitVal, int HmmMem) {
// Verifying the result
int DataMismatch = 0;
if (HmmMem == 0) {
HIPCHECK(hipMemcpy(HstPtr, ptr, (sizeof(int) * NumElms), hipMemcpyDeviceToHost));
HIPCHECK(hipMemcpy(host_ptr.get(), ptr, (sizeof(int) * NumElms), hipMemcpyDeviceToHost));
for (size_t i = 0; i < NumElms; ++i) {
if (HstPtr[i] != (InitVal + 10)) {
if (host_ptr[i] != (InitVal + 10)) {
DataMismatch++;
}
}
@@ -418,6 +419,7 @@ TEST_CASE("Unit_hipMallocManaged_MultiKrnlComnHmm") {
}
}
delete[] HstPtr;
HIP_CHECK(hipFree(Hmm));
}
@@ -481,6 +483,8 @@ TEST_CASE("Unit_hipMallocManaged_MultiThrdMultiStrm") {
thr.join();
}
}
HIP_CHECK(hipFree(Hmm1));
}