mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
/*
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "shared/source/device/sub_device.h"
|
|
|
|
#include "shared/source/device/root_device.h"
|
|
|
|
namespace NEO {
|
|
|
|
SubDevice::SubDevice(ExecutionEnvironment *executionEnvironment, uint32_t subDeviceIndex, Device &rootDevice)
|
|
: Device(executionEnvironment), subDeviceIndex(subDeviceIndex), rootDevice(static_cast<RootDevice &>(rootDevice)) {
|
|
UNRECOVERABLE_IF(rootDevice.isSubDevice());
|
|
deviceBitfield = 0;
|
|
deviceBitfield.set(subDeviceIndex);
|
|
}
|
|
|
|
void SubDevice::incRefInternal() {
|
|
rootDevice.incRefInternal();
|
|
}
|
|
unique_ptr_if_unused<Device> SubDevice::decRefInternal() {
|
|
return rootDevice.decRefInternal();
|
|
}
|
|
|
|
uint32_t SubDevice::getRootDeviceIndex() const {
|
|
return this->rootDevice.getRootDeviceIndex();
|
|
}
|
|
|
|
uint32_t SubDevice::getSubDeviceIndex() const {
|
|
return subDeviceIndex;
|
|
}
|
|
|
|
Device *SubDevice::getRootDevice() const {
|
|
return &rootDevice;
|
|
}
|
|
|
|
uint64_t SubDevice::getGlobalMemorySize(uint32_t deviceBitfield) const {
|
|
auto globalMemorySize = Device::getGlobalMemorySize(static_cast<uint32_t>(maxNBitValue(rootDevice.getNumSubDevices())));
|
|
return globalMemorySize / rootDevice.getNumAvailableDevices();
|
|
}
|
|
|
|
} // namespace NEO
|