SWDEV-283930 - Fix bugs in HIP Tests on Windows

Windows doesn't have headers unistd.h, sys/wait.h, so
remove them for _WIN64. Also, Windows doesn't have rand_r
so define it. Fixes builds for HIP tests:
d2dMemCpyWithPinnedHostMemory, hipMemset3DFunctional,
hipModuleLoadMultProcessOnMultGPU,
hipModuleLoadUnloadStress, hipModuleNegative,
hipStreamACb_ThrdBehaviour, hipMemcpyNegativeMThrdMSize,
hipStreamACb_MStrm_Mgpu, StreamAddCallback,
hipStreamACb_StrmSyncTiming, hipStreamACb_MultiCalls,
hipMallocConcurrency, hipMemset3DRegressMultiThread,
and hipSetGetDevice.

Change-Id: Id2f98d664716026c590d879e464ba467d4c071be


[ROCm/clr commit: bacb89c086]
This commit is contained in:
Aaron En Ye Shi
2021-04-30 21:38:45 +00:00
förälder d3ff861a37
incheckning f6f8fa7787
12 ändrade filer med 38 tillägg och 7 borttagningar
@@ -40,8 +40,10 @@
* HIT_END
*/
#ifdef __linux__
#include <sys/wait.h>
#include <unistd.h>
#endif
#include "test_common.h"
int sequence_num = 0;
@@ -275,7 +277,7 @@ bool testValidDevices(int numDevices, bool useRocrEnv, int *deviceList,
testResult = false;
}
#else
printf("skipping testcase for non unix system \n)";
printf("skipping testcase for non unix system \n");
#endif
return testResult;
}
@@ -365,7 +367,7 @@ bool testMaxRvdMinHvd(int numDevices, int *deviceList, int count) {
testResult = false;
}
#else
printf("skipping testcase for non unix system \n)";
printf("skipping testcase for non unix system \n");
#endif
return testResult;
}
@@ -409,7 +411,7 @@ bool testRvdCvd(int numDevices, int *deviceList, int count) {
testResult = false;
}
#else
printf("skipping testcase for non unix system \n)";
printf("skipping testcase for non unix system \n");
#endif
return testResult;
}
@@ -457,7 +459,7 @@ bool testMinRvdMaxHvd(int numDevices, int *deviceList, int count) {
testResult = false;
}
#else
printf("skipping testcase for non unix system \n)";
printf("skipping testcase for non unix system \n");
#endif
return testResult;
}
@@ -540,7 +542,7 @@ bool testDeviceListSequence(int numDevices, bool useRocrEnv,
testResult = false;
}
#else
printf("skipping testcase for non unix system \n)";
printf("skipping testcase for non unix system \n");
#endif
return testResult;
}
@@ -69,9 +69,10 @@ Testcase Scenarios :
*/
#include <sys/types.h>
#ifdef __linux__
#include <sys/wait.h>
#include <unistd.h>
#endif
#include <iostream>
#include <vector>
#include <limits>
@@ -31,7 +31,9 @@ THE SOFTWARE.
* HIT_END
*/
#ifdef __linux__
#include <unistd.h>
#endif
#include <atomic>
#include <vector>
#include "test_common.h"
@@ -40,8 +40,10 @@ Testcase Scenarios :
*/
#include <sys/types.h>
#ifdef __linux__
#include <sys/wait.h>
#include <unistd.h>
#endif
#include <vector>
#include "test_common.h"
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <hip/hip_runtime.h>
#ifdef __linux__
#include <unistd.h>
#endif
#include "test_common.h"
#include <atomic>
@@ -27,7 +27,9 @@
*/
#include <stdio.h>
#ifdef __linux__
#include <unistd.h>
#endif
#include <thread>
#include <chrono>
#include "hip/hip_runtime.h"
@@ -28,7 +28,9 @@
#include <stdio.h>
#ifdef __linux__
#include <unistd.h>
#endif
#include <mutex>
#include <atomic>
#include "hip/hip_runtime.h"
@@ -28,7 +28,9 @@
*/
#include <stdio.h>
#ifdef __linux__
#include <unistd.h>
#endif
#include <chrono>
#include <atomic>
#include "hip/hip_runtime.h"
@@ -27,7 +27,9 @@
* HIT_END
*/
#ifdef __linux__
#include <unistd.h>
#endif
#include <stdio.h>
#include "hip/hip_runtime.h"
#include "test_common.h"
@@ -44,7 +44,9 @@ THE SOFTWARE.
* HIT_END
*/
#ifdef __linux__
#include <unistd.h>
#endif
#include <hip/hip_runtime.h>
#include "test_common.h"
@@ -53,6 +53,14 @@ const char* PATH_SEPERATOR_STR = "/";
const char* NULL_DEVICE = "/dev/null";
#endif
#ifdef _WIN64
// Windows does not have rand_r, use srand and rand instead.
int rand_r(unsigned int* s) {
srand(*s);
return rand();
}
#endif
// Get Free Memory from the system
static size_t getMemoryAmount() {
#if __linux__
+5 -1
Visa fil
@@ -136,8 +136,8 @@ inline int hip_skip_retcode() {
#define fileno(x) _fileno(x)
#define dup(x) _dup(x)
#define dup2(x,y) _dup2(x,y)
#define close(x) _close(x)
#define pipe(x,y,z) _pipe(x,y,z)
#define sleep(x) _sleep(x)
#else
#define aligned_free(x) free(x)
#endif
@@ -169,6 +169,10 @@ extern const char* NULL_DEVICE;
#define TYPENAME(T) "?"
#endif
#ifdef _WIN64
int rand_r(unsigned int* s);
#endif
// Get Optimal Thread count size
size_t getHostThreadCount(const size_t memPerThread = 200 /* MB */, const size_t maxThreads = 0);