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