2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-02 20:20:18 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-01-02 20:20:18 +08:00
|
|
|
#include "core/debug_settings/debug_settings_manager.h"
|
2019-11-28 20:02:11 +08:00
|
|
|
#include "core/execution_environment/root_device_environment.h"
|
2019-11-29 22:41:47 +08:00
|
|
|
#include "core/helpers/hw_info.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/device/device.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/os_interface/device_factory.h"
|
2018-03-15 22:03:51 +08:00
|
|
|
#include "runtime/os_interface/hw_info_config.h"
|
2019-08-21 16:53:07 +08:00
|
|
|
#include "runtime/os_interface/linux/drm_memory_operations_handler.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/os_interface/linux/drm_neo.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/os_interface/linux/os_interface.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "drm/i915_drm.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t DeviceFactory::numDevices = 0;
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
bool DeviceFactory::getDevices(size_t &numDevices, ExecutionEnvironment &executionEnvironment) {
|
2017-12-21 07:45:38 +08:00
|
|
|
unsigned int devNum = 0;
|
2019-10-23 22:17:06 +08:00
|
|
|
size_t numRootDevices = 1;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-10-17 22:00:12 +08:00
|
|
|
if (DebugManager.flags.CreateMultipleRootDevices.get()) {
|
2019-10-23 22:17:06 +08:00
|
|
|
numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get();
|
2018-06-20 17:19:55 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-15 16:59:48 +08:00
|
|
|
executionEnvironment.prepareRootDeviceEnvironments(static_cast<uint32_t>(numRootDevices));
|
2019-10-22 17:44:06 +08:00
|
|
|
|
2018-06-20 17:19:55 +08:00
|
|
|
Drm *drm = Drm::create(devNum);
|
|
|
|
if (!drm) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-08-10 17:07:17 +08:00
|
|
|
|
2019-11-28 20:02:11 +08:00
|
|
|
for (auto rootDeviceIndex = 0u; rootDeviceIndex < numRootDevices; rootDeviceIndex++) {
|
|
|
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->memoryOperationsInterface = std::make_unique<DrmMemoryOperationsHandler>();
|
|
|
|
}
|
2018-08-10 17:07:17 +08:00
|
|
|
executionEnvironment.osInterface.reset(new OSInterface());
|
|
|
|
executionEnvironment.osInterface->get()->setDrm(drm);
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
auto hardwareInfo = executionEnvironment.getMutableHardwareInfo();
|
2018-06-20 17:19:55 +08:00
|
|
|
const HardwareInfo *pCurrDevice = platformDevices[devNum];
|
2019-05-08 22:00:24 +08:00
|
|
|
HwInfoConfig *hwConfig = HwInfoConfig::get(pCurrDevice->platform.eProductFamily);
|
2019-05-06 18:33:44 +08:00
|
|
|
if (hwConfig->configureHwInfo(pCurrDevice, hardwareInfo, executionEnvironment.osInterface.get())) {
|
2019-03-19 22:09:33 +08:00
|
|
|
return false;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2019-12-24 16:59:49 +08:00
|
|
|
executionEnvironment.calculateMaxOsContextCount();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-10-23 22:17:06 +08:00
|
|
|
numDevices = numRootDevices;
|
2019-03-19 22:09:33 +08:00
|
|
|
DeviceFactory::numDevices = numDevices;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-03 16:00:12 +08:00
|
|
|
return true;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceFactory::releaseDevices() {
|
|
|
|
if (DeviceFactory::numDevices > 0) {
|
|
|
|
for (unsigned int i = 0; i < DeviceFactory::numDevices; ++i) {
|
|
|
|
Drm::closeDevice(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DeviceFactory::numDevices = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Device::appendOSExtensions(std::string &deviceExtensions) {
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|