SWDEV-1 - Add EMU_ENV option

Fix FEAT-39125
Add EMU_ENV option. If it is ON, the building is for
emulation environment, thus some logics can be adjusted
to match emulation environment. If it is OFF, the
building is for regular environment.
Currently only ocltst will use the option. But it can
be used for other modules.

Change-Id: I54e1bc1309e82794b41fca2ae1f01f004138dced
This commit is contained in:
taosang2
2021-11-24 21:55:27 -05:00
committed by Tao Sang
parent df2eec8465
commit 76c6dcd558
15 changed files with 153 additions and 12 deletions
@@ -83,8 +83,11 @@ void OCLMemoryInfo::run(void) {
if (failed_) {
return;
}
#if EMU_ENV
size_t BufSize = 0x10000;
#else
size_t BufSize = 0x1000000;
#endif // EMU_ENV
bool succeed = false;
bool done = false;
if (test_ == 0) {
@@ -166,12 +169,19 @@ void OCLMemoryInfo::run(void) {
_wrapper->clGetDeviceInfo(devices_[_deviceId],
CL_DEVICE_GLOBAL_FREE_MEMORY_AMD,
2 * sizeof(size_t), memoryInfo2, NULL);
#if EMU_ENV
// For testing on emulator with 2G RAM and buffer size of x10000
if (memoryInfo2[0] < (0x3e000 + (BufSize * sizeof(cl_int4) / 1024))) {
#else
if (memoryInfo2[0] < (0x50000 + (BufSize * sizeof(cl_int4) / 1024))) {
#endif // EMU_ENV
break;
}
size_t dif = memoryInfo[0] - memoryInfo2[0];
// extra memory could be allocated/destroyed in the driver
if ((dif / sizeAll) == 1 || (sizeAll / dif) == 1) {
if (dif == 0) {
// the buffer memory may come from the cached memory pool
} else if ((dif / sizeAll) == 1 || (sizeAll / dif) == 1) {
succeed = true;
} else {
succeed = false;