2019-08-28 13:12:44 +02:00
|
|
|
/*
|
2025-05-07 00:06:28 +00:00
|
|
|
* Copyright (C) 2019-2025 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
|
|
|
|
2021-04-26 15:19:31 +00:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/device/root_device.h"
|
2025-05-07 00:06:28 +00:00
|
|
|
#include "shared/source/helpers/basic_math.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2019-08-28 13:12:44 +02:00
|
|
|
|
2025-05-07 00:06:28 +00:00
|
|
|
#include <iostream>
|
2019-08-28 13:12:44 +02:00
|
|
|
namespace NEO {
|
|
|
|
|
|
2021-04-22 14:28:27 +00:00
|
|
|
SubDevice::SubDevice(ExecutionEnvironment *executionEnvironment, uint32_t subDeviceIndex, Device &rootDevice)
|
2021-12-16 11:08:32 +00:00
|
|
|
: Device(executionEnvironment, rootDevice.getRootDeviceIndex()), rootDevice(static_cast<RootDevice &>(rootDevice)), subDeviceIndex(subDeviceIndex) {
|
2021-04-22 14:28:27 +00:00
|
|
|
UNRECOVERABLE_IF(rootDevice.isSubDevice());
|
2021-04-07 17:00:33 +00:00
|
|
|
deviceBitfield = 0;
|
|
|
|
|
deviceBitfield.set(subDeviceIndex);
|
2020-02-06 13:33:30 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-23 10:56:13 +00:00
|
|
|
SubDevice::SubDevice(ExecutionEnvironment *executionEnvironment, uint32_t subDeviceIndex, Device &rootDevice, aub_stream::EngineType engineType)
|
|
|
|
|
: SubDevice(executionEnvironment, subDeviceIndex, 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-11-05 11:25:26 +01:00
|
|
|
uint32_t SubDevice::getSubDeviceIndex() const {
|
|
|
|
|
return subDeviceIndex;
|
|
|
|
|
}
|
2020-02-06 13:33:30 +01:00
|
|
|
|
2025-05-07 00:06:28 +00:00
|
|
|
NEO::SubDeviceIdsVec SubDevice::getSubDeviceIdsFromDevice(NEO::Device &device) {
|
|
|
|
|
|
|
|
|
|
NEO::SubDeviceIdsVec subDeviceIds;
|
|
|
|
|
|
|
|
|
|
if (device.getNumSubDevices() == 0) {
|
|
|
|
|
subDeviceIds.push_back(NEO::SubDevice::getSubDeviceId(device));
|
|
|
|
|
} else {
|
|
|
|
|
for (auto &subDevice : device.getSubDevices()) {
|
|
|
|
|
if (subDevice == nullptr) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
subDeviceIds.push_back(NEO::SubDevice::getSubDeviceId(*subDevice));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return subDeviceIds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t SubDevice::getSubDeviceId(NEO::Device &device) {
|
|
|
|
|
if (!device.isSubDevice()) {
|
|
|
|
|
uint32_t deviceBitField = static_cast<uint32_t>(device.getDeviceBitfield().to_ulong());
|
|
|
|
|
if (device.getDeviceBitfield().count() > 1) {
|
|
|
|
|
deviceBitField &= ~deviceBitField + 1;
|
|
|
|
|
}
|
|
|
|
|
return Math::log2(deviceBitField);
|
|
|
|
|
}
|
|
|
|
|
return static_cast<NEO::SubDevice *>(&device)->getSubDeviceIndex();
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-07 17:00:33 +00:00
|
|
|
Device *SubDevice::getRootDevice() const {
|
2020-07-15 12:38:34 +02:00
|
|
|
return &rootDevice;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-28 13:12:44 +02:00
|
|
|
} // namespace NEO
|