2019-08-27 15:34:20 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "runtime/device/root_device.h"
|
|
|
|
|
|
|
|
#include "runtime/device/sub_device.h"
|
2019-08-28 19:12:44 +08:00
|
|
|
#include "runtime/os_interface/debug_settings_manager.h"
|
2019-08-27 15:34:20 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
RootDevice::~RootDevice() = default;
|
2019-08-28 19:12:44 +08:00
|
|
|
|
|
|
|
uint32_t RootDevice::getNumSubDevices() const {
|
|
|
|
return static_cast<uint32_t>(subdevices.size());
|
|
|
|
}
|
|
|
|
|
2019-08-27 15:34:20 +08:00
|
|
|
RootDevice::RootDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : Device(executionEnvironment, deviceIndex) {}
|
2019-08-28 19:12:44 +08:00
|
|
|
bool RootDevice::createDeviceImpl() {
|
|
|
|
auto status = Device::createDeviceImpl();
|
|
|
|
if (!status) {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
auto numSubDevices = DebugManager.flags.CreateMultipleSubDevices.get();
|
|
|
|
subdevices.reserve(numSubDevices);
|
|
|
|
for (int i = 0; i < numSubDevices; i++) {
|
|
|
|
|
|
|
|
auto subDevice = Device::createDeviceInternals(new SubDevice(executionEnvironment, deviceIndex + i + 1, *this));
|
|
|
|
if (!subDevice) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
subdevices.push_back(std::unique_ptr<SubDevice>(subDevice));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We hide the retain and release function of BaseObject. */
|
|
|
|
void RootDevice::retain() {
|
|
|
|
DEBUG_BREAK_IF(!isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
unique_ptr_if_unused<Device> RootDevice::release() {
|
|
|
|
DEBUG_BREAK_IF(!isValid());
|
|
|
|
return unique_ptr_if_unused<Device>(this, false);
|
|
|
|
}
|
2019-08-27 15:34:20 +08:00
|
|
|
|
|
|
|
} // namespace NEO
|