Refactor of global factories

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor
2021-05-27 19:44:47 +02:00
committed by Compute-Runtime-Automation
parent dca72d3226
commit 3b4ec5b3fa
63 changed files with 573 additions and 117 deletions

View File

@@ -4,7 +4,15 @@
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_GLOBAL_FACTORIES
${CMAKE_CURRENT_SOURCE_DIR}/create_os_context_${DRIVER_MODEL}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/create_os_time_${DRIVER_MODEL}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_${DRIVER_MODEL}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/init_os_interface_${DRIVER_MODEL}.cpp
)
set(NEO_CORE_OS_INTERFACE
${NEO_CORE_GLOBAL_FACTORIES}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/aub_memory_operations_handler.h

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/source/os_interface/os_context.h"
namespace NEO {
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
return OsContextLinux::create(osInterface, contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
}
} // namespace NEO

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/os_context_win.h"
namespace NEO {
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
if (osInterface) {
if (osInterface->getDriverModel()->getDriverModelType() == DriverModelType::DRM) {
return OsContextLinux::create(osInterface, contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
} else {
return OsContextWin::create(osInterface, contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
}
}
return OsContextLinux::create(osInterface, contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
}
} // namespace NEO

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/os_context.h"
#include "shared/source/os_interface/windows/os_context_win.h"
namespace NEO {
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
return OsContextWin::create(osInterface, contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
}
} // namespace NEO

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/device_time_drm.h"
#include "shared/source/os_interface/linux/os_time_linux.h"
#include "shared/source/os_interface/os_time.h"
namespace NEO {
std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
return OSTimeLinux::create(osInterface, std::make_unique<DeviceTimeDrm>(osInterface));
}
} // namespace NEO

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/device_time_drm.h"
#include "shared/source/os_interface/linux/os_time_linux.h"
#include "shared/source/os_interface/os_time.h"
#include "shared/source/os_interface/windows/device_time_wddm.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
namespace NEO {
std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
if (osInterface->getDriverModel()->getDriverModelType() == DriverModelType::DRM) {
return OSTimeLinux::create(osInterface, std::make_unique<DeviceTimeDrm>(osInterface));
} else {
auto wddm = osInterface->getDriverModel()->as<Wddm>();
return OSTimeLinux::create(osInterface, std::make_unique<DeviceTimeWddm>(wddm));
}
}
} // namespace NEO

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/os_time.h"
#include "shared/source/os_interface/windows/os_time_win.h"
namespace NEO {
std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
return OSTimeWin::create(osInterface);
}
} // namespace NEO

View File

@@ -5,13 +5,13 @@
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionEnvironment &executionEnvironment) {
return OSInterface::discoverDevicesDrm(executionEnvironment);
return Drm::discoverDevices(executionEnvironment);
}
} // namespace NEO

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionEnvironment &executionEnvironment) {
auto devices = Drm::discoverDevices(executionEnvironment);
if (devices.empty()) {
devices = Wddm::discoverDevices(executionEnvironment);
}
return devices;
}
} // namespace NEO

View File

@@ -5,13 +5,13 @@
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionEnvironment &executionEnvironment) {
return OSInterface::discoverDevicesWddm(executionEnvironment);
return Wddm::discoverDevices(executionEnvironment);
}
} // namespace NEO

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/os_interface_linux.h"
namespace NEO {
bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex) {
return initDrmOsInterface(std::move(hwDeviceId), rootDeviceIndex, this, this->osInterface, this->memoryOperationsInterface);
}
} // namespace NEO

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/linux/os_interface_linux.h"
#include "shared/source/os_interface/windows/os_interface_win.h"
namespace NEO {
bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex) {
if (hwDeviceId->getDriverModelType() == DriverModelType::DRM) {
return initDrmOsInterface(std::move(hwDeviceId), rootDeviceIndex, this, osInterface, memoryOperationsInterface);
} else {
return initWddmOsInterface(std::move(hwDeviceId), rootDeviceIndex, this, osInterface, memoryOperationsInterface);
}
}
} // namespace NEO

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/windows/os_interface_win.h"
namespace NEO {
bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex) {
return initWddmOsInterface(std::move(hwDeviceId), rootDeviceIndex, this, osInterface, memoryOperationsInterface);
}
} // namespace NEO

View File

@@ -11,8 +11,6 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/cache_info_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/device_time_drm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_time_drm.h
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_wddm_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_linux.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_allocation.cpp
@@ -51,6 +49,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux.h
${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_linux.h
${CMAKE_CURRENT_SOURCE_DIR}/os_library_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_library_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_library_linux.h

View File

@@ -1,18 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesWddm(ExecutionEnvironment &executionEnvironment) {
UNRECOVERABLE_IF(true);
return {};
}
} // namespace NEO

View File

@@ -1027,4 +1027,12 @@ void DrmMemoryManager::registerAllocationInOs(GraphicsAllocation *allocation) {
}
}
}
std::unique_ptr<MemoryManager> DrmMemoryManager::create(ExecutionEnvironment &executionEnvironment) {
return std::make_unique<DrmMemoryManager>(gemCloseWorkerMode::gemCloseWorkerActive,
DebugManager.flags.EnableForcePin.get(),
true,
executionEnvironment);
}
} // namespace NEO

View File

@@ -73,6 +73,8 @@ class DrmMemoryManager : public MemoryManager {
void disableGemCloseWorkerForNewResidencyModel() override;
static std::unique_ptr<MemoryManager> create(ExecutionEnvironment &executionEnvironment);
protected:
BufferObject *findAndReferenceSharedBufferObject(int boHandle);
void eraseSharedBufferObject(BufferObject *bo);

View File

@@ -382,7 +382,7 @@ void appendHwDeviceId(std::vector<std::unique_ptr<HwDeviceId>> &hwDeviceIds, int
}
}
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesDrm(ExecutionEnvironment &executionEnvironment) {
std::vector<std::unique_ptr<HwDeviceId>> Drm::discoverDevices(ExecutionEnvironment &executionEnvironment) {
std::vector<std::unique_ptr<HwDeviceId>> hwDeviceIds;
executionEnvironment.osEnvironment = std::make_unique<OsEnvironment>();
std::string devicePrefix = std::string(Os::pciDevicesDirectory) + "/pci-0000:";

View File

@@ -206,6 +206,8 @@ class Drm : public DriverModel {
const std::vector<int> &getSliceMappings(uint32_t deviceIndex);
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
protected:
struct TopologyMapping {
std::vector<int> sliceIndices;

View File

@@ -19,8 +19,8 @@
namespace NEO {
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
OsContext *OsContextLinux::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
if (osInterface) {
return new OsContextLinux(*osInterface->getDriverModel()->as<Drm>(), contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
}

View File

@@ -27,6 +27,8 @@ class OsContextLinux : public OsContext {
bool isDirectSubmissionSupported(const HardwareInfo &hwInfo) const override;
Drm &getDrm() const;
void waitForPagingFence();
static OsContext *create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice);
protected:
void initializeContext() override;

View File

@@ -5,6 +5,8 @@
*
*/
#include "shared/source/os_interface/linux/os_interface_linux.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/gmm_lib.h"
@@ -32,20 +34,24 @@ bool OSInterface::isDebugAttachAvailable() const {
return false;
}
bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex) {
Drm *drm = Drm::create(std::unique_ptr<HwDeviceIdDrm>(hwDeviceId.release()->as<HwDeviceIdDrm>()), *this);
bool initDrmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex,
RootDeviceEnvironment *rootDeviceEnv,
std::unique_ptr<OSInterface> &dstOsInterface, std::unique_ptr<MemoryOperationsHandler> &dstMemoryOpsHandler) {
auto hwDeviceIdDrm = std::unique_ptr<HwDeviceIdDrm>(reinterpret_cast<HwDeviceIdDrm *>(hwDeviceId.release()));
Drm *drm = Drm::create(std::move(hwDeviceIdDrm), *rootDeviceEnv);
if (!drm) {
return false;
}
osInterface.reset(new OSInterface());
osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
auto hardwareInfo = getMutableHardwareInfo();
dstOsInterface.reset(new OSInterface());
dstOsInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
auto hardwareInfo = rootDeviceEnv->getMutableHardwareInfo();
HwInfoConfig *hwConfig = HwInfoConfig::get(hardwareInfo->platform.eProductFamily);
if (hwConfig->configureHwInfoDrm(hardwareInfo, hardwareInfo, osInterface.get())) {
if (hwConfig->configureHwInfoDrm(hardwareInfo, hardwareInfo, dstOsInterface.get())) {
return false;
}
memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex);
dstMemoryOpsHandler = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex);
return true;
}

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/os_interface.h"
#include <cstdint>
#include <memory>
namespace NEO {
bool initDrmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex,
RootDeviceEnvironment *rootDeviceEnv,
std::unique_ptr<OSInterface> &dstOsInterface, std::unique_ptr<MemoryOperationsHandler> &dstMemoryOpsHandler);
} // namespace NEO

View File

@@ -54,8 +54,8 @@ uint64_t OSTimeLinux::getCpuRawTimestamp() {
return timesInNsec / ticksInNsec;
}
std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
return std::unique_ptr<OSTime>(new OSTimeLinux(osInterface, std::make_unique<DeviceTimeDrm>(osInterface)));
std::unique_ptr<OSTime> OSTimeLinux::create(OSInterface *osInterface, std::unique_ptr<DeviceTime> deviceTime) {
return std::unique_ptr<OSTime>(new OSTimeLinux(osInterface, std::move(deviceTime)));
}
} // namespace NEO

View File

@@ -20,6 +20,8 @@ class OSTimeLinux : public OSTime {
double getHostTimerResolution() const override;
uint64_t getCpuRawTimestamp() override;
static std::unique_ptr<OSTime> create(OSInterface *osInterface, std::unique_ptr<DeviceTime> deviceTime);
protected:
typedef int (*resolutionFunc_t)(clockid_t, struct timespec *);
typedef int (*getTimeFunc_t)(clockid_t, struct timespec *);

View File

@@ -24,7 +24,7 @@ struct HardwareInfo;
class OsContext : public ReferenceTrackedObject<OsContext> {
public:
OsContext() = delete;
OsContext(uint32_t contextId, DeviceBitfield deviceBitfield, EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice);
static OsContext *create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice);
@@ -54,7 +54,6 @@ class OsContext : public ReferenceTrackedObject<OsContext> {
bool &startInContext);
protected:
OsContext(uint32_t contextId, DeviceBitfield deviceBitfield, EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice);
virtual void initializeContext() {}
const uint32_t contextId;

View File

@@ -103,8 +103,6 @@ class OSInterface : public NonCopyableClass {
static bool gpuIdleImplicitFlush;
static bool requiresSupportForWddmTrimNotification;
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevicesWddm(ExecutionEnvironment &executionEnvironment);
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevicesDrm(ExecutionEnvironment &executionEnvironment);
protected:
std::unique_ptr<DriverModel> driverModel = nullptr;

View File

@@ -24,8 +24,6 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/device_time_wddm.h
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_windows.h
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_drm_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environment_variables.h
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.h
@@ -33,6 +31,7 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_wddm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/init_wddm_os_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener${KMDAF_FILE_SUFFIX}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener.h
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.cpp
@@ -41,6 +40,7 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/os_environment_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_inc.h
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_library_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_library_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.cpp

View File

@@ -1,18 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesDrm(ExecutionEnvironment &executionEnvironment) {
UNRECOVERABLE_IF(true);
return {};
}
} // namespace NEO

View File

@@ -8,7 +8,6 @@
#pragma once
#include "shared/source/os_interface/driver_info.h"
#include "shared/source/utilities/debug_settings_reader.h"
#include <functional>
#include <memory>
@@ -16,6 +15,8 @@
namespace NEO {
class SettingsReader;
bool isCompatibleDriverStore(std::string &&deviceRegistryPath);
class DriverInfoWindows : public DriverInfo {

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/os_interface_win.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
namespace NEO {
bool initWddmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex,
RootDeviceEnvironment *rootDeviceEnv,
std::unique_ptr<OSInterface> &dstOsInterface, std::unique_ptr<MemoryOperationsHandler> &dstMemoryOpsHandler) {
UNRECOVERABLE_IF(hwDeviceId->getDriverModelType() != DriverModelType::WDDM);
auto hwDeviceIdWddm = std::unique_ptr<HwDeviceIdWddm>(reinterpret_cast<HwDeviceIdWddm *>(hwDeviceId.release()));
auto wddm(Wddm::createWddm(std::move(hwDeviceIdWddm), *rootDeviceEnv));
if (!wddm->init()) {
return false;
}
dstMemoryOpsHandler = std::make_unique<WddmMemoryOperationsHandler>(wddm);
return true;
}
} // namespace NEO

View File

@@ -13,8 +13,8 @@
namespace NEO {
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
OsContext *OsContextWin::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice) {
if (osInterface) {
return new OsContextWin(*osInterface->getDriverModel()->as<Wddm>(), contextId, deviceBitfield, typeUsage, preemptionMode, rootDevice);
}

View File

@@ -34,6 +34,8 @@ class OsContextWin : public OsContext {
void setHwQueue(HardwareQueue hardwareQueue) { this->hardwareQueue = hardwareQueue; }
Wddm *getWddm() const { return &wddm; }
MOCKABLE_VIRTUAL WddmResidencyController &getResidencyController() { return residencyController; }
static OsContext *create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
EngineTypeUsage typeUsage, PreemptionMode preemptionMode, bool rootDevice);
protected:
void initializeContext() override;

View File

@@ -5,11 +5,7 @@
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
namespace NEO {
@@ -21,15 +17,4 @@ bool OSInterface::requiresSupportForWddmTrimNotification = true;
bool OSInterface::isDebugAttachAvailable() const {
return false;
}
bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex) {
UNRECOVERABLE_IF(hwDeviceId->getDriverModelType() != DriverModelType::WDDM);
auto hwDeviceIdWddm = std::unique_ptr<HwDeviceIdWddm>(reinterpret_cast<HwDeviceIdWddm *>(hwDeviceId.release()));
auto wddm(Wddm::createWddm(std::move(hwDeviceIdWddm), *this));
if (!wddm->init()) {
return false;
}
memoryOperationsInterface = std::make_unique<WddmMemoryOperationsHandler>(wddm);
return true;
}
} // namespace NEO

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/os_interface.h"
#include <cstdint>
#include <memory>
namespace NEO {
bool initWddmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex,
RootDeviceEnvironment *rootDeviceEnv,
std::unique_ptr<OSInterface> &dstOsInterface, std::unique_ptr<MemoryOperationsHandler> &dstMemoryOpsHandler);
} // namespace NEO

View File

@@ -24,7 +24,7 @@ bool OSTimeWin::getCpuTime(uint64_t *timeStamp) {
return true;
};
std::unique_ptr<OSTime> OSTime::create(OSInterface *osInterface) {
std::unique_ptr<OSTime> OSTimeWin::create(OSInterface *osInterface) {
return std::unique_ptr<OSTime>(new OSTimeWin(osInterface));
}

View File

@@ -23,6 +23,8 @@ class OSTimeWin : public OSTime {
double getHostTimerResolution() const override;
uint64_t getCpuRawTimestamp() override;
static std::unique_ptr<OSTime> create(OSInterface *osInterface);
protected:
LARGE_INTEGER frequency;
OSTimeWin() = default;

View File

@@ -293,7 +293,7 @@ std::unique_ptr<HwDeviceIdWddm> createHwDeviceIdFromAdapterLuid(OsEnvironmentWin
return std::make_unique<HwDeviceIdWddm>(OpenAdapterData.hAdapter, adapterLuid, &osEnvironment, std::move(umKmDataTranslator));
}
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesWddm(ExecutionEnvironment &executionEnvironment) {
std::vector<std::unique_ptr<HwDeviceId>> Wddm::discoverDevices(ExecutionEnvironment &executionEnvironment) {
auto osEnvironment = new OsEnvironmentWin();
auto gdi = osEnvironment->gdi.get();

View File

@@ -188,6 +188,8 @@ class Wddm : public DriverModel {
PhysicalDevicePciBusInfo getPciBusInfo() const override;
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
protected:
std::unique_ptr<HwDeviceIdWddm> hwDeviceId;
D3DKMT_HANDLE device = 0;