From de7cbdd4cdf998c04ffce6973eed602654b886af Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Fri, 29 Jul 2022 16:31:04 +0530 Subject: [PATCH] SWDEV-299940 - Needs to Fix Malloc tests (#2832) Change-Id: I21739d88871b5813cf266a6be8eb05ecee487046 [ROCm/hip-tests commit: 870c9c218a9f722608288843882d71c083b8913f] --- .../catch/unit/memory/hipMallocConcurrency.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/projects/hip-tests/catch/unit/memory/hipMallocConcurrency.cc b/projects/hip-tests/catch/unit/memory/hipMallocConcurrency.cc index 592ce86897..647d38d99d 100644 --- a/projects/hip-tests/catch/unit/memory/hipMallocConcurrency.cc +++ b/projects/hip-tests/catch/unit/memory/hipMallocConcurrency.cc @@ -95,6 +95,14 @@ static bool validateMemoryOnGPU(int gpu, bool concurOnOneGPU = false) { HIP_CHECK(hipSetDevice(gpu)); HIP_CHECK(hipMemGetInfo(&prevAvl, &prevTot)); HipTest::initArrays(&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N, false); + HIP_CHECK(hipMemGetInfo(&curAvl, &curTot)); + + if (!concurOnOneGPU && (prevAvl < curAvl || prevTot != curTot)) { + //In concurrent calls on one GPU, we cannot verify leaking in this way + printf("%s : Memory allocation mismatch observed." + "Possible memory leak.\n", __func__); + TestPassed &= false; + } unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, N); @@ -113,10 +121,11 @@ static bool validateMemoryOnGPU(int gpu, bool concurOnOneGPU = false) { TestPassed = false; } + HIP_CHECK(hipMemGetInfo(&prevAvl, &prevTot)); HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false); HIP_CHECK(hipMemGetInfo(&curAvl, &curTot)); - if (!concurOnOneGPU && (prevAvl != curAvl || prevTot != curTot)) { + if (!concurOnOneGPU && (curAvl < prevAvl || prevTot != curTot)) { // In concurrent calls on one GPU, we cannot verify leaking in this way UNSCOPED_INFO("validateMemoryOnGPU : Memory allocation mismatch observed." << "Possible memory leak.");