Add new debug flag to limit the number of returned devices.

Change-Id: I01e1b6804291956fb62b84ff5df68c57b51bd17d
This commit is contained in:
Mrozek, Michal
2018-10-08 14:23:29 -07:00
committed by sys_ocldev
parent 118d3ed0e2
commit 12b4d44375
4 changed files with 30 additions and 1 deletions

View File

@@ -7,6 +7,8 @@
#include "cl_api_tests.h"
#include "runtime/platform/platform.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/variable_backup.h"
using namespace OCLRT;
@@ -92,4 +94,24 @@ TEST_F(clGetDeviceIDsTests, cpuDevices) {
EXPECT_EQ(CL_DEVICE_NOT_FOUND, retVal);
EXPECT_EQ(numDevices, (cl_uint)0);
}
} // namespace ULT
namespace OCLRT {
extern bool overrideDeviceWithDefaultHardwareInfo;
extern bool overrideCommandStreamReceiverCreation;
TEST(MultiDeviceTests, givenCreateMultipleDevicesAndLimitAmountOfReturnedDevicesFlagWhenClGetDeviceIdsIsCalledThenLowerValueIsReturned) {
platformImpl.reset(nullptr);
overrideCommandStreamReceiverCreation = true;
VariableBackup<bool> overrideHelper(&overrideDeviceWithDefaultHardwareInfo, false);
DeviceFactoryCleaner cleaner;
DebugManagerStateRestore stateRestore;
DebugManager.flags.CreateMultipleDevices.set(2);
DebugManager.flags.LimitAmountOfReturnedDevices.set(1);
cl_uint numDevices = 0;
auto retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_GPU, 0, nullptr, &numDevices);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, numDevices);
}
} // namespace OCLRT