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

@@ -57,6 +57,13 @@ if(NOT "${BRANCH_TYPE}" STREQUAL "")
endif()
message(STATUS "branch dir list: ${BRANCH_DIR_LIST}")
if(WIN32)
set(DRIVER_MODEL wddm)
else()
set(DRIVER_MODEL drm)
endif()
message(STATUS "Driver model : ${DRIVER_MODEL}")
if(TR_DEPRECATED)
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1)
endif()

View File

@@ -231,6 +231,7 @@ if(BUILD_WITH_L0)
PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_command_stream.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_deferred_deleter.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_memory_manager_${DRIVER_MODEL}.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/create_tbx_sockets.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/get_devices.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/source_level_debugger_dll.cpp
@@ -250,7 +251,6 @@ if(BUILD_WITH_L0)
${NEO_SHARED_DIRECTORY}/dll/windows/environment_variables.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/windows/options_windows.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/windows/os_interface.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/windows/create_wddm_memory_manager.cpp
)
target_link_libraries(${TARGET_NAME_L0}
dxgi
@@ -267,7 +267,6 @@ if(BUILD_WITH_L0)
${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}/devices.inl
${NEO_SHARED_DIRECTORY}/dll/devices/devices_base.inl
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/allocator_helper.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/create_drm_memory_manager.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/options_linux.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/os_interface.cpp
)

View File

@@ -58,6 +58,7 @@ target_include_directories(${NEO_STATIC_LIB_NAME} PUBLIC
${NEO__IGC_INCLUDE_DIR}
${THIRD_PARTY_DIR}
${NEO__GMM_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/os_interface/create_command_stream_receiver_${DRIVER_MODEL}
)
target_compile_definitions(${NEO_STATIC_LIB_NAME} PUBLIC

View File

@@ -14,6 +14,7 @@ set(RUNTIME_SRCS_DLL_BASE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/create_command_stream.cpp
${CMAKE_CURRENT_SOURCE_DIR}/create_deferred_deleter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/create_memory_manager_${DRIVER_MODEL}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/create_tbx_sockets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debug_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source_level_debugger_dll.cpp
@@ -41,7 +42,6 @@ append_sources_from_properties(RUNTIME_SRCS_DLL_BASE NEO_CORE_SRCS_LINK)
set(RUNTIME_SRCS_DLL_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/linux/allocator_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux/create_drm_memory_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux/drm_neo_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux/options_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux/os_interface.cpp
@@ -52,7 +52,6 @@ set(RUNTIME_SRCS_DLL_LINUX
)
set(RUNTIME_SRCS_DLL_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/windows/create_wddm_memory_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows/options_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows/os_interface.cpp
${NEO_SHARED_DIRECTORY}/dll/windows/environment_variables.cpp

View File

@@ -0,0 +1,14 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_memory_manager.h"
namespace NEO {
std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(ExecutionEnvironment &executionEnvironment, DriverModelType driverModel) {
return DrmMemoryManager::create(executionEnvironment);
}
} // namespace NEO

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_memory_manager.h"
#include "shared/source/os_interface/windows/wddm_memory_manager.h"
namespace NEO {
std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(ExecutionEnvironment &executionEnvironment, DriverModelType driverModel) {
if (driverModel == DriverModelType::DRM) {
return DrmMemoryManager::create(executionEnvironment);
} else {
return std::make_unique<WddmMemoryManager>(executionEnvironment);
}
}
} // namespace NEO

View File

@@ -1,20 +0,0 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/linux/drm_memory_manager.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::unique_ptr<MemoryManager> MemoryManager::createMemoryManager(ExecutionEnvironment &executionEnvironment, DriverModelType driverModel) {
return std::make_unique<DrmMemoryManager>(gemCloseWorkerMode::gemCloseWorkerActive,
DebugManager.flags.EnableForcePin.get(),
true,
executionEnvironment);
}
} // namespace NEO

View File

@@ -20,6 +20,7 @@ set(RUNTIME_SRCS_GENX_CPP_BASE
cl_hw_helper
command_queue
command_stream_receiver_simulated_common_hw
create_device_command_stream_receiver
experimental_command_buffer
gpgpu_walker
hardware_commands_helper

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/device_command_stream.h"
#include "create_command_stream_receiver.inl"
namespace NEO {
template <>
CommandStreamReceiver *createDeviceCommandStreamReceiver<ICLFamily>(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
return createCommandStreamReceiver<ICLFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
}
} // namespace NEO

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/device_command_stream.h"
#include "create_command_stream_receiver.inl"
namespace NEO {
template <>
CommandStreamReceiver *createDeviceCommandStreamReceiver<TGLLPFamily>(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
return createCommandStreamReceiver<TGLLPFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
}
} // namespace NEO

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/device_command_stream.h"
#include "create_command_stream_receiver.inl"
namespace NEO {
template <>
CommandStreamReceiver *createDeviceCommandStreamReceiver<BDWFamily>(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
return createCommandStreamReceiver<BDWFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
}
} // namespace NEO

View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/device_command_stream.h"
#include "create_command_stream_receiver.inl"
namespace NEO {
template <>
CommandStreamReceiver *createDeviceCommandStreamReceiver<SKLFamily>(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
return createCommandStreamReceiver<SKLFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
}
} // namespace NEO

View File

@@ -6,6 +6,7 @@
set(RUNTIME_SRCS_OS_INTERFACE_BASE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/create_command_stream_receiver_${DRIVER_MODEL}/create_command_stream_receiver.inl
${CMAKE_CURRENT_SOURCE_DIR}/metrics_library.cpp
${CMAKE_CURRENT_SOURCE_DIR}/metrics_library.h
${CMAKE_CURRENT_SOURCE_DIR}/ocl_reg_path.h

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/source/os_interface/linux/device_command_stream.inl"
namespace NEO {
template <typename GfxFamily>
CommandStreamReceiver *createCommandStreamReceiver(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
return createDrmCommandStreamReceiver<GfxFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
}
} // namespace NEO

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/os_interface.h"
#include "opencl/source/os_interface/linux/device_command_stream.inl"
#include "opencl/source/os_interface/windows/device_command_stream.inl"
namespace NEO {
template <typename GfxFamily>
CommandStreamReceiver *createCommandStreamReceiver(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get();
if (rootDeviceEnvironment->osInterface->getDriverModel()->getDriverModelType() == DriverModelType::DRM) {
return createDrmCommandStreamReceiver<GfxFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
} else {
return createWddmCommandStreamReceiver<GfxFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
}
}
} // namespace NEO

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/source/os_interface/windows/device_command_stream.inl"
namespace NEO {
template <typename GfxFamily>
CommandStreamReceiver *createCommandStreamReceiver(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
return createWddmCommandStreamReceiver<GfxFamily>(withAubDump, executionEnvironment, rootDeviceIndex, deviceBitfield);
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#

View File

@@ -6,7 +6,7 @@
*/
#include "shared/source/command_stream/device_command_stream.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "opencl/source/command_stream/command_stream_receiver_with_aub_dump.h"
#include "opencl/source/os_interface/linux/drm_command_stream.h"
@@ -14,10 +14,10 @@
namespace NEO {
template <typename GfxFamily>
CommandStreamReceiver *DeviceCommandStreamReceiver<GfxFamily>::create(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
CommandStreamReceiver *createDrmCommandStreamReceiver(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
if (withAubDump) {
return new CommandStreamReceiverWithAUBDump<DrmCommandStreamReceiver<GfxFamily>>("aubfile",
executionEnvironment,
@@ -39,5 +39,5 @@ CommandStreamReceiver *DeviceCommandStreamReceiver<GfxFamily>::create(bool withA
deviceBitfield,
gemMode);
}
};
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#

View File

@@ -20,10 +20,10 @@
namespace NEO {
template <typename GfxFamily>
CommandStreamReceiver *DeviceCommandStreamReceiver<GfxFamily>::create(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
CommandStreamReceiver *createWddmCommandStreamReceiver(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
if (withAubDump) {
return new CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<GfxFamily>>("aubfile",
executionEnvironment,

View File

@@ -160,4 +160,19 @@ void WddmCommandStreamReceiver<GfxFamily>::kmDafLockAllocations(ResidencyContain
}
}
template <typename GfxFamily>
CommandStreamReceiver *createWddmDeviceCommandStreamReceiver(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield) {
if (withAubDump) {
return new CommandStreamReceiverWithAUBDump<WddmCommandStreamReceiver<GfxFamily>>("aubfile",
executionEnvironment,
rootDeviceIndex,
deviceBitfield);
} else {
return new WddmCommandStreamReceiver<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield);
}
}
} // namespace NEO

View File

@@ -10,6 +10,7 @@
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "opencl/source/command_stream/aub_command_stream_receiver.h"
#include "opencl/source/os_interface/linux/device_command_stream.inl"

View File

@@ -10,6 +10,12 @@
namespace NEO {
template <typename GfxFamily>
CommandStreamReceiver *createDeviceCommandStreamReceiver(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield);
template <typename GfxFamily>
class DeviceCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
typedef CommandStreamReceiverHw<GfxFamily> BaseClass;
@@ -25,6 +31,9 @@ class DeviceCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
static CommandStreamReceiver *create(bool withAubDump,
ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield);
const DeviceBitfield deviceBitfield) {
return createDeviceCommandStreamReceiver<GfxFamily>(withAubDump, executionEnvironment,
rootDeviceIndex, deviceBitfield);
}
};
} // namespace NEO

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;