2019-08-28 13:12:44 +02:00
|
|
|
/*
|
2020-01-14 14:32:11 +01:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2019-08-28 13:12:44 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/device/sub_device.h"
|
2019-08-28 13:12:44 +02:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/device/root_device.h"
|
2019-08-28 13:12:44 +02:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2020-02-06 13:33:30 +01:00
|
|
|
SubDevice::SubDevice(ExecutionEnvironment *executionEnvironment, uint32_t subDeviceIndex, RootDevice &rootDevice)
|
|
|
|
: Device(executionEnvironment), subDeviceIndex(subDeviceIndex), rootDevice(rootDevice) {
|
|
|
|
}
|
|
|
|
|
2020-04-02 16:38:42 +02:00
|
|
|
void SubDevice::incRefInternal() {
|
|
|
|
rootDevice.incRefInternal();
|
|
|
|
}
|
|
|
|
unique_ptr_if_unused<Device> SubDevice::decRefInternal() {
|
|
|
|
return rootDevice.decRefInternal();
|
|
|
|
}
|
|
|
|
|
2019-12-03 10:15:46 +01:00
|
|
|
DeviceBitfield SubDevice::getDeviceBitfield() const {
|
2019-09-17 10:44:49 +02:00
|
|
|
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;
|
|
|
|
}
|
2020-02-06 13:33:30 +01:00
|
|
|
|
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
|
|
|
|
2020-07-15 12:38:34 +02:00
|
|
|
Device *SubDevice::getParentDevice() const {
|
|
|
|
return &rootDevice;
|
|
|
|
}
|
|
|
|
|
2020-04-16 14:44:03 +02:00
|
|
|
uint64_t SubDevice::getGlobalMemorySize() const {
|
|
|
|
auto globalMemorySize = Device::getGlobalMemorySize();
|
|
|
|
return globalMemorySize / rootDevice.getNumAvailableDevices();
|
|
|
|
}
|
|
|
|
|
2019-08-28 13:12:44 +02:00
|
|
|
} // namespace NEO
|