SWDEV-295037 - Fix passed() in DTests

passed() should not call exit(0) which will prevent object
destructor being called.

Change-Id: Ibaee0d85cb616727dc5db557bb9422702670b688
Este commit está contenido en:
Tao Sang
2021-07-13 23:39:01 -04:00
cometido por Tao Sang
padre 63586279ba
commit c74e2da333
Se han modificado 12 ficheros con 22 adiciones y 45 borrados
+2 -4
Ver fichero
@@ -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;
}
+1 -3
Ver fichero
@@ -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!");
}
+1 -2
Ver fichero
@@ -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);
}
+1 -3
Ver fichero
@@ -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));
+2 -4
Ver fichero
@@ -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));
+2 -4
Ver fichero
@@ -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;
@@ -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!");
}
}
@@ -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));
@@ -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));
@@ -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<void*>(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
@@ -275,9 +275,7 @@ void spawnProc(int deviceCount, const std::vector<char>& 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();
}
+3 -1
Ver fichero
@@ -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