From b889bbd960c7a259cbf198c5ce41f968c42bc832 Mon Sep 17 00:00:00 2001 From: Tao Sang Date: Fri, 12 Feb 2021 17:03:09 -0500 Subject: [PATCH] SWDEV-272089 - Fix concurrent memory test failure on CUDA Change-Id: Ibf35c789d6bd4279bdcedba1a6e057639c258489 --- .../memory/hipMallocConcurrency.cpp | 22 ++++++++++--------- .../runtimeApi/memory/hipMemset3DNegative.cpp | 5 ++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/src/runtimeApi/memory/hipMallocConcurrency.cpp b/tests/src/runtimeApi/memory/hipMallocConcurrency.cpp index 934c364b6b..9118df3332 100644 --- a/tests/src/runtimeApi/memory/hipMallocConcurrency.cpp +++ b/tests/src/runtimeApi/memory/hipMallocConcurrency.cpp @@ -94,7 +94,7 @@ Testcase Scenarios : /** * Validates data consitency on supplied gpu */ -bool validateMemoryOnGPU(int gpu) { +bool validateMemoryOnGPU(int gpu, bool concurOnOneGPU = false) { size_t Nbytes = N * sizeof(int); int *A_d, *B_d, *C_d; int *A_h, *B_h, *C_h; @@ -127,9 +127,10 @@ bool validateMemoryOnGPU(int gpu) { HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false); HIPCHECK(hipMemGetInfo(&curAvl, &curTot)); - if ((prevAvl != curAvl) || (prevTot != 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.", __func__); + "Possible memory leak.\n", __func__); TestPassed &= false; } @@ -206,10 +207,12 @@ bool regressAllocInLoop(int gpu) { HIPCHECK(hipMalloc(&ptr, numBytes)); HIPCHECK(hipMemGetInfo(&avail, &tot)); - if (pavail-avail != numBytes) { - printf("LoopAllocation : Memory allocation of %6.2fMB" - "not matching with hipMemGetInfo - FAIL\n", - numBytes/(1024.0*1024.0)); + if (pavail-avail < numBytes) // We expect pavail-avail >= numBytes + { + printf("LoopAllocation %d : Memory allocation of %6.2fMB " + "not matching with hipMemGetInfo - FAIL\n" + "pavail=%zu, ptot=%zu, avail=%zu, tot=%zu, pavail-avail=%zu \n", + i, numBytes/(1024.0*1024.0), pavail, ptot, avail, tot, pavail-avail); TestPassed &= false; HIPCHECK(hipFree(ptr)); break; @@ -369,8 +372,7 @@ int main(int argc, char* argv[]) { } else if (!pid) { // Child process bool TestPassedChild = true; - - TestPassedChild = validateMemoryOnGPU(0); + TestPassedChild = validateMemoryOnGPU(0, true); if (TestPassedChild) { exit(0); // child exit with success status @@ -381,7 +383,7 @@ int main(int argc, char* argv[]) { } else { // Parent process int exitStatus; - TestPassed = validateMemoryOnGPU(0); + TestPassed = validateMemoryOnGPU(0, true); pid = wait(&exitStatus); if ( WEXITSTATUS(exitStatus) || ( pid < 0 ) ) diff --git a/tests/src/runtimeApi/memory/hipMemset3DNegative.cpp b/tests/src/runtimeApi/memory/hipMemset3DNegative.cpp index 7dcf083bd5..e73a57e1dc 100644 --- a/tests/src/runtimeApi/memory/hipMemset3DNegative.cpp +++ b/tests/src/runtimeApi/memory/hipMemset3DNegative.cpp @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) { hipGetErrorString(ret), ret); TestPassed &= false; } - +#ifdef __HIP_PLATFORM_AMD__ if ((ret = hipMemset3D(devPitchedPtr, memsetval, extMD)) != hipErrorInvalidValue) { printf("ArgValidation : Inappropriate error value returned for " @@ -176,6 +176,9 @@ int main(int argc, char *argv[]) { hipGetErrorString(ret), ret); TestPassed &= false; } +#else + printf("Cuda doesn't check the maximum depth of extent field\n"); +#endif } else if (p_tests == 4) { // Device Ptr out bound and extent(0) passed for memset