Add method to device that returns device id.

Change-Id: I0fc5d1e37eb6f49a513c202a89db07ef539646f3
This commit is contained in:
Mrozek, Michal 2018-09-07 08:45:13 +02:00 committed by sys_ocldev
parent ac2a2de3be
commit 05b93ef221
3 changed files with 16 additions and 0 deletions

View File

@ -267,4 +267,9 @@ GFXCORE_FAMILY Device::getRenderCoreFamily() const {
bool Device::isSourceLevelDebuggerActive() const {
return deviceInfo.sourceLevelDebuggerActive;
}
uint32_t Device::getDeviceIndex() {
return osContext->getContextId();
}
} // namespace OCLRT

View File

@ -133,6 +133,7 @@ class Device : public BaseObject<_cl_device_id> {
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
const HardwareCapabilities &getHardwareCapabilities() { return hardwareCapabilities; }
OsContext *getOsContext() const { return osContext; }
uint32_t getDeviceIndex();
protected:
Device() = delete;

View File

@ -193,6 +193,16 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqu
EXPECT_EQ(2u, device->getMemoryManager()->getOsContextCount());
}
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment));
auto device2 = std::unique_ptr<Device>(Device::create<Device>(nullptr, &executionEnvironment));
EXPECT_EQ(0u, device->getDeviceIndex());
EXPECT_EQ(1u, device2->getDeviceIndex());
}
TEST(DeviceCreation, givenFtrSimulationModeFlagTrueWhenNoOtherSimulationFlagsArePresentThenIsSimulationReturnsTrue) {
FeatureTable skuTable = *platformDevices[0]->pSkuTable;
skuTable.ftrSimulationMode = true;