2019-08-28 13:12:44 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "runtime/device/sub_device.h"
|
|
|
|
|
|
|
|
#include "runtime/device/root_device.h"
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2019-11-05 13:38:20 +01:00
|
|
|
SubDevice::SubDevice(ExecutionEnvironment *executionEnvironment, uint32_t subDeviceIndex, RootDevice &rootDevice) : Device(executionEnvironment), subDeviceIndex(subDeviceIndex), rootDevice(rootDevice) {}
|
2019-08-28 13:12:44 +02:00
|
|
|
void SubDevice::retain() {
|
|
|
|
rootDevice.incRefInternal();
|
|
|
|
Device::retain();
|
|
|
|
};
|
|
|
|
unique_ptr_if_unused<Device> SubDevice::release() {
|
|
|
|
rootDevice.decRefInternal();
|
|
|
|
return Device::release();
|
|
|
|
};
|
|
|
|
void SubDevice::retainInternal() {
|
|
|
|
rootDevice.incRefInternal();
|
|
|
|
}
|
|
|
|
void SubDevice::releaseInternal() {
|
|
|
|
rootDevice.decRefInternal();
|
|
|
|
}
|
|
|
|
|
2019-09-17 10:44:49 +02:00
|
|
|
DeviceBitfield SubDevice::getDeviceBitfieldForOsContext() const {
|
|
|
|
DeviceBitfield deviceBitfield;
|
|
|
|
deviceBitfield.set(subDeviceIndex);
|
|
|
|
return deviceBitfield;
|
|
|
|
}
|
2019-09-23 14:04:18 +02:00
|
|
|
uint32_t SubDevice::getNumAvailableDevices() const {
|
|
|
|
return 1u;
|
|
|
|
}
|
2019-10-21 13:41:35 +02:00
|
|
|
uint32_t SubDevice::getRootDeviceIndex() const {
|
|
|
|
return this->rootDevice.getRootDeviceIndex();
|
|
|
|
}
|
2019-11-05 11:25:26 +01:00
|
|
|
|
|
|
|
uint32_t SubDevice::getSubDeviceIndex() const {
|
|
|
|
return subDeviceIndex;
|
|
|
|
}
|
2019-10-10 15:56:10 +02:00
|
|
|
Device *SubDevice::getDeviceById(uint32_t deviceId) const {
|
|
|
|
UNRECOVERABLE_IF(deviceId >= getNumAvailableDevices());
|
|
|
|
return const_cast<SubDevice *>(this);
|
|
|
|
}
|
2019-09-17 10:44:49 +02:00
|
|
|
|
2019-08-28 13:12:44 +02:00
|
|
|
} // namespace NEO
|