2019-08-28 19:12:44 +08:00
|
|
|
/*
|
2021-04-08 01:00:33 +08:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2019-08-28 19:12:44 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/device/sub_device.h"
|
2019-08-28 19:12:44 +08:00
|
|
|
|
2021-04-26 23:19:31 +08:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/device/root_device.h"
|
2021-04-29 01:46:13 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2019-08-28 19:12:44 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2021-04-22 22:28:27 +08:00
|
|
|
SubDevice::SubDevice(ExecutionEnvironment *executionEnvironment, uint32_t subDeviceIndex, Device &rootDevice)
|
2021-04-23 18:56:13 +08:00
|
|
|
: Device(executionEnvironment), rootDevice(static_cast<RootDevice &>(rootDevice)), subDeviceIndex(subDeviceIndex) {
|
2021-04-22 22:28:27 +08:00
|
|
|
UNRECOVERABLE_IF(rootDevice.isSubDevice());
|
2021-04-08 01:00:33 +08:00
|
|
|
deviceBitfield = 0;
|
|
|
|
deviceBitfield.set(subDeviceIndex);
|
2020-02-06 20:33:30 +08:00
|
|
|
}
|
|
|
|
|
2021-04-23 18:56:13 +08:00
|
|
|
SubDevice::SubDevice(ExecutionEnvironment *executionEnvironment, uint32_t subDeviceIndex, Device &rootDevice, aub_stream::EngineType engineType)
|
|
|
|
: SubDevice(executionEnvironment, subDeviceIndex, rootDevice) {
|
2021-05-06 19:33:39 +08:00
|
|
|
this->engineInstancedType = engineType;
|
2021-04-23 18:56:13 +08:00
|
|
|
engineInstanced = true;
|
|
|
|
}
|
|
|
|
|
2020-04-02 22:38:42 +08:00
|
|
|
void SubDevice::incRefInternal() {
|
|
|
|
rootDevice.incRefInternal();
|
|
|
|
}
|
|
|
|
unique_ptr_if_unused<Device> SubDevice::decRefInternal() {
|
|
|
|
return rootDevice.decRefInternal();
|
|
|
|
}
|
|
|
|
|
2019-10-21 19:41:35 +08:00
|
|
|
uint32_t SubDevice::getRootDeviceIndex() const {
|
|
|
|
return this->rootDevice.getRootDeviceIndex();
|
|
|
|
}
|
2019-11-05 18:25:26 +08:00
|
|
|
|
|
|
|
uint32_t SubDevice::getSubDeviceIndex() const {
|
|
|
|
return subDeviceIndex;
|
|
|
|
}
|
2020-02-06 20:33:30 +08:00
|
|
|
|
2021-04-08 01:00:33 +08:00
|
|
|
Device *SubDevice::getRootDevice() const {
|
2020-07-15 18:38:34 +08:00
|
|
|
return &rootDevice;
|
|
|
|
}
|
|
|
|
|
2020-10-30 17:27:48 +08:00
|
|
|
uint64_t SubDevice::getGlobalMemorySize(uint32_t deviceBitfield) const {
|
|
|
|
auto globalMemorySize = Device::getGlobalMemorySize(static_cast<uint32_t>(maxNBitValue(rootDevice.getNumSubDevices())));
|
2020-04-16 20:44:03 +08:00
|
|
|
return globalMemorySize / rootDevice.getNumAvailableDevices();
|
|
|
|
}
|
|
|
|
|
2019-08-28 19:12:44 +08:00
|
|
|
} // namespace NEO
|