diff --git a/tests/performance/compute/hipPerfDotProduct.cpp b/tests/performance/compute/hipPerfDotProduct.cpp index 78215c8502..e1d444d5b5 100644 --- a/tests/performance/compute/hipPerfDotProduct.cpp +++ b/tests/performance/compute/hipPerfDotProduct.cpp @@ -238,9 +238,7 @@ int main(int argc, char* argv[]) { HIPCHECK(hipGetDeviceCount(&nGpu)); if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); - return 0; + failed("No GPU!"); } hipDeviceProp_t props = {0}; props = {0}; @@ -379,6 +377,6 @@ int main(int argc, char* argv[]) { HIPCHECK(hipFree(workspace)); } - + passed(); return 0; } diff --git a/tests/performance/compute/hipPerfMandelbrot.cpp b/tests/performance/compute/hipPerfMandelbrot.cpp index 5d556ed960..8e6c3a25cc 100644 --- a/tests/performance/compute/hipPerfMandelbrot.cpp +++ b/tests/performance/compute/hipPerfMandelbrot.cpp @@ -403,9 +403,7 @@ void hipPerfMandelBrot::open(int deviceId) { int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); - return; + failed("No GPU!"); } diff --git a/tests/performance/memory/hipPerfMemFill.cpp b/tests/performance/memory/hipPerfMemFill.cpp index 4aedb72073..0dbae58ce4 100644 --- a/tests/performance/memory/hipPerfMemFill.cpp +++ b/tests/performance/memory/hipPerfMemFill.cpp @@ -130,8 +130,7 @@ class hipPerfMemFill { int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); if (nGpu < 1) { - cout << "Info: didn't find any GPU! skipping the test!\n"; - passed(); + failed("No GPU!"); } else if (deviceId >= nGpu) { failed("Info: wrong GPU Id %d\n", deviceId); } diff --git a/tests/performance/memory/hipPerfMemcpy.cpp b/tests/performance/memory/hipPerfMemcpy.cpp index 005b1a9c85..c9dfedc99e 100644 --- a/tests/performance/memory/hipPerfMemcpy.cpp +++ b/tests/performance/memory/hipPerfMemcpy.cpp @@ -62,9 +62,7 @@ void hipPerfMemcpy::open(int deviceId) { int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); - return; + failed("No GPU!"); } HIPCHECK(hipSetDevice(deviceId)); diff --git a/tests/performance/memory/hipPerfMemset.cpp b/tests/performance/memory/hipPerfMemset.cpp index 4e71a094dc..4d6ae88711 100644 --- a/tests/performance/memory/hipPerfMemset.cpp +++ b/tests/performance/memory/hipPerfMemset.cpp @@ -18,7 +18,7 @@ */ /* HIT_START - * BUILD: %t %s ../../src/test_common.cpp EXCLUDE_HIP_PLATFORM nvcc + * BUILD: %t %s ../../src/test_common.cpp EXCLUDE_HIP_PLATFORM nvidia * TEST: %t * HIT_END */ @@ -110,9 +110,7 @@ void hipPerfMemset::open(int deviceId) { int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); - return; + failed("No GPU!"); } HIPCHECK(hipSetDevice(deviceId)); diff --git a/tests/performance/memory/hipPerfSampleRate.cpp b/tests/performance/memory/hipPerfSampleRate.cpp index 8346cb3cda..1cb0741158 100644 --- a/tests/performance/memory/hipPerfSampleRate.cpp +++ b/tests/performance/memory/hipPerfSampleRate.cpp @@ -128,10 +128,8 @@ void hipPerfSampleRate::open(void) { int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); - if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); - return; + if (nGpu < 1) { + failed("No GPU!"); } int deviceId = 0; diff --git a/tests/performance/stream/hipPerfDeviceConcurrency.cpp b/tests/performance/stream/hipPerfDeviceConcurrency.cpp index a4403eeae7..0c1a1ec6dc 100644 --- a/tests/performance/stream/hipPerfDeviceConcurrency.cpp +++ b/tests/performance/stream/hipPerfDeviceConcurrency.cpp @@ -95,17 +95,12 @@ hipPerfDeviceConcurrency::hipPerfDeviceConcurrency() {} hipPerfDeviceConcurrency::~hipPerfDeviceConcurrency() {} void hipPerfDeviceConcurrency::open(void) { - - int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); setNumGpus(nGpu); if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); + failed("No GPU!"); } - - } diff --git a/tests/performance/stream/hipPerfStreamConcurrency.cpp b/tests/performance/stream/hipPerfStreamConcurrency.cpp index fd4b0107e4..557ad7823c 100644 --- a/tests/performance/stream/hipPerfStreamConcurrency.cpp +++ b/tests/performance/stream/hipPerfStreamConcurrency.cpp @@ -235,17 +235,12 @@ hipPerfStreamConcurrency::hipPerfStreamConcurrency() {} hipPerfStreamConcurrency::~hipPerfStreamConcurrency() {} void hipPerfStreamConcurrency::open(int deviceId) { - - int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); - return; + failed("No GPU!"); } - HIPCHECK(hipSetDevice(deviceId)); hipDeviceProp_t props = {0}; HIPCHECK(hipGetDeviceProperties(&props, deviceId)); diff --git a/tests/performance/stream/hipPerfStreamCreateCopyDestroy.cpp b/tests/performance/stream/hipPerfStreamCreateCopyDestroy.cpp index 1a58f7e045..90292942db 100644 --- a/tests/performance/stream/hipPerfStreamCreateCopyDestroy.cpp +++ b/tests/performance/stream/hipPerfStreamCreateCopyDestroy.cpp @@ -54,9 +54,7 @@ void hipPerfStreamCreateCopyDestroy::open(int deviceId) { int nGpu = 0; HIPCHECK(hipGetDeviceCount(&nGpu)); if (nGpu < 1) { - std::cout << "info: didn't find any GPU! skipping the test!\n"; - passed(); - return; + failed("No GPU!"); } HIPCHECK(hipSetDevice(deviceId)); diff --git a/tests/src/runtimeApi/memory/hipIpcMemAccessTest.cpp b/tests/src/runtimeApi/memory/hipIpcMemAccessTest.cpp index 03f76f49dc..cd9809ded5 100644 --- a/tests/src/runtimeApi/memory/hipIpcMemAccessTest.cpp +++ b/tests/src/runtimeApi/memory/hipIpcMemAccessTest.cpp @@ -60,10 +60,9 @@ class IpcMemHandleTest { pid_t pid; size_t N = 1024; size_t Nbytes = N * sizeof(int); - int *A_d = NULL, out = 0; + int out = 0; int *A_h, *C_h; int Num_devices = 0, Data_mismatch, CanAccessPeer = 0; - int *Ad1 = NULL, *Ad2 = NULL; IpcMemHandleTest(); bool Test(); ~IpcMemHandleTest(); @@ -84,6 +83,7 @@ bool IpcMemHandleTest::Test() { HIPCHECK_NO_RETURN(status, hipGetDeviceCount(&Num_devices)); for (int i = 0; i < Num_devices; ++i) { if (shrd_mem->IfTestPassed == true) { + int *A_d = NULL; HIPCHECK_NO_RETURN(status, hipSetDevice(i)); HIPCHECK_NO_RETURN(status, hipMalloc(&A_d, Nbytes)); HIPCHECK_NO_RETURN(status, hipIpcGetMemHandle((hipIpcMemHandle_t *) &shrd_mem->memHandle, @@ -116,6 +116,8 @@ bool IpcMemHandleTest::Test() { } for (int i = 0; i < Num_devices; ++i) { Data_mismatch = 0; + int *Ad1 = NULL; + int *Ad2 = NULL; HIPCHECK_NO_RETURN(status, hipSetDevice(i)); HIPCHECK_NO_RETURN(status, hipMalloc(&Ad2, Nbytes)); HIPCHECK_NO_RETURN(status, hipIpcOpenMemHandle((void **) &Ad1, shrd_mem->memHandle, @@ -147,8 +149,8 @@ bool IpcMemHandleTest::Test() { } } HIPCHECK_NO_RETURN(status, hipIpcCloseMemHandle(reinterpret_cast(Ad1))); + HIPCHECK_NO_RETURN(status, hipFree(Ad2)); } - HIPCHECK_NO_RETURN(status, hipFree(Ad2)); if ((out=sem_post(sem_ob2)) == -1) { shrd_mem->IfTestPassed = false; printf("sem_post() call on sem_ob2 failed"); @@ -210,11 +212,8 @@ IpcMemHandleTest::IpcMemHandleTest() { IpcMemHandleTest::~IpcMemHandleTest() { munmap(shrd_mem, sizeof(hip_ipc_t)); - HIPCHECK(hipFree((A_d))); free(A_h); free(C_h); - HIPCHECK(hipFree((Ad1))); - HIPCHECK(hipFree((Ad2))); } #endif diff --git a/tests/src/runtimeApi/module/hipModuleLoadMultProcessOnMultGPU.cpp b/tests/src/runtimeApi/module/hipModuleLoadMultProcessOnMultGPU.cpp index de32a63369..dafa418b07 100644 --- a/tests/src/runtimeApi/module/hipModuleLoadMultProcessOnMultGPU.cpp +++ b/tests/src/runtimeApi/module/hipModuleLoadMultProcessOnMultGPU.cpp @@ -275,9 +275,7 @@ void spawnProc(int deviceCount, const std::vector& buffer) { TestPassed &= testhipModuleLoadUnloadFunc(buffer); } #endif - if (TestPassed) { - passed(); - } else { + if (!TestPassed) { failed("hipMallocChild_Concurrency_MultiGpu Failed!"); } } @@ -309,4 +307,5 @@ int main(int argc, char* argv[]) { globTestID = 3; spawnProc(numDevices, buffer); } + passed(); } diff --git a/tests/src/test_common.h b/tests/src/test_common.h index 6815f0cbec..40acdf4bc1 100755 --- a/tests/src/test_common.h +++ b/tests/src/test_common.h @@ -67,9 +67,11 @@ inline int hip_skip_retcode() { return HIP_SKIP_RETURN_CODE; } +// This must be called in the end of main() to indicate test passed with success. +// If it's called somewhere else, compiling issues or unexpected result will arise. #define passed() \ printf("%sPASSED!%s\n", KGRN, KNRM); \ - exit(0); + return 0; // The real "assert" would have written to stderr. But it is // sufficient to just fflush here without getting pedantic. This also