Correct clGetDeviceIDs: return all requested devices
Related-To: NEO-4000 Change-Id: I2723b5364bf742aa490d88967c19329830f45322 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
5ac1d1258c
commit
8ccadbb240
|
@ -1,5 +1,5 @@
|
|||
#!groovy
|
||||
dependenciesRevision='8430df09c44f1b2739eee6ce13122f8e20d05776-1351'
|
||||
strategy='EQUAL'
|
||||
allowedCD=258
|
||||
allowedCD=257
|
||||
allowedF=7
|
||||
|
|
|
@ -190,8 +190,9 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
|
|||
break;
|
||||
}
|
||||
|
||||
Device *device = pPlatform->getDevice(0);
|
||||
DEBUG_BREAK_IF(device == nullptr);
|
||||
if (DebugManager.flags.LimitAmountOfReturnedDevices.get()) {
|
||||
numDev = std::min(static_cast<cl_uint>(DebugManager.flags.LimitAmountOfReturnedDevices.get()), numDev);
|
||||
}
|
||||
|
||||
if (deviceType == CL_DEVICE_TYPE_ALL) {
|
||||
/* According to Spec, set it to all except TYPE_CUSTOM. */
|
||||
|
@ -203,16 +204,20 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
|
|||
}
|
||||
|
||||
cl_uint retNum = 0;
|
||||
for (auto rootDeviceIndex = 0u; rootDeviceIndex < numDev; rootDeviceIndex++) {
|
||||
|
||||
if (deviceType & device->getDeviceInfo().deviceType) {
|
||||
if (devices) {
|
||||
devices[retNum] = device;
|
||||
Device *device = pPlatform->getDevice(rootDeviceIndex);
|
||||
DEBUG_BREAK_IF(device == nullptr);
|
||||
|
||||
if (deviceType & device->getDeviceInfo().deviceType) {
|
||||
if (devices) {
|
||||
if (retNum >= numEntries) {
|
||||
break;
|
||||
}
|
||||
devices[retNum] = device;
|
||||
}
|
||||
retNum++;
|
||||
}
|
||||
retNum++;
|
||||
}
|
||||
|
||||
if (DebugManager.flags.LimitAmountOfReturnedDevices.get()) {
|
||||
retNum = std::min(static_cast<uint32_t>(DebugManager.flags.LimitAmountOfReturnedDevices.get()), retNum);
|
||||
}
|
||||
|
||||
if (numDevices) {
|
||||
|
|
|
@ -13,7 +13,13 @@
|
|||
|
||||
using namespace NEO;
|
||||
|
||||
typedef api_tests clGetDeviceIDsTests;
|
||||
namespace NEO {
|
||||
extern bool overrideDeviceWithDefaultHardwareInfo;
|
||||
extern bool overrideCommandStreamReceiverCreation;
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
using clGetDeviceIDsTests = api_tests;
|
||||
|
||||
namespace ULT {
|
||||
|
||||
|
@ -96,9 +102,72 @@ TEST_F(clGetDeviceIDsTests, GivenDeviceTypeCpuWhenGettingDeviceIdsThenDeviceNotF
|
|||
EXPECT_EQ(numDevices, (cl_uint)0);
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
namespace NEO {
|
||||
extern bool overrideDeviceWithDefaultHardwareInfo;
|
||||
extern bool overrideCommandStreamReceiverCreation;
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsThenAllRootDevicesAreReturned) {
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<bool> backup(&overrideDeviceWithDefaultHardwareInfo, false);
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
cl_uint numDevices = 0;
|
||||
cl_uint numEntries = numRootDevices;
|
||||
cl_device_id devices[numRootDevices];
|
||||
auto retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_ALL, numEntries, devices, &numDevices);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_EQ(numEntries, numDevices);
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
EXPECT_EQ(devices[i], platform()->getDevice(i));
|
||||
}
|
||||
}
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWhenGetDeviceIdsButNumEntriesIsLowerThanNumDevicesThenSubsetOfRootDevicesIsReturned) {
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<bool> backup(&overrideDeviceWithDefaultHardwareInfo, false);
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
cl_uint maxNumDevices;
|
||||
auto retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_ALL, 0, nullptr, &maxNumDevices);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_EQ(numRootDevices, maxNumDevices);
|
||||
|
||||
} // namespace NEO
|
||||
cl_uint numDevices = 0;
|
||||
cl_uint numEntries = numRootDevices - 1;
|
||||
cl_device_id devices[numRootDevices];
|
||||
|
||||
const auto dummyDevice = reinterpret_cast<cl_device_id>(0x1357);
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
devices[i] = dummyDevice;
|
||||
}
|
||||
|
||||
retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_ALL, numEntries, devices, &numDevices);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_LT(numDevices, maxNumDevices);
|
||||
EXPECT_EQ(numEntries, numDevices);
|
||||
for (auto i = 0u; i < numEntries; i++) {
|
||||
EXPECT_EQ(devices[i], platform()->getDevice(i));
|
||||
}
|
||||
EXPECT_EQ(devices[numEntries], dummyDevice);
|
||||
}
|
||||
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesAndLimitedNumberOfReturnedDevicesWhenGetDeviceIdsThenLimitedNumberOfRootDevicesIsReturned) {
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<bool> backup(&overrideDeviceWithDefaultHardwareInfo, false);
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
DebugManager.flags.LimitAmountOfReturnedDevices.set(numRootDevices - 1);
|
||||
|
||||
cl_uint numDevices = 0;
|
||||
cl_uint numEntries = numRootDevices;
|
||||
cl_device_id devices[numRootDevices];
|
||||
|
||||
const auto dummyDevice = reinterpret_cast<cl_device_id>(0x1357);
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
devices[i] = dummyDevice;
|
||||
}
|
||||
|
||||
auto retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_ALL, numEntries, devices, &numDevices);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_EQ(numEntries - 1, numDevices);
|
||||
for (auto i = 0u; i < numDevices; i++) {
|
||||
EXPECT_EQ(devices[i], platform()->getDevice(i));
|
||||
}
|
||||
EXPECT_EQ(devices[numDevices], dummyDevice);
|
||||
}
|
||||
} // namespace ULT
|
||||
|
|
Loading…
Reference in New Issue