2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2025-01-13 20:18:55 +08:00
|
|
|
* Copyright (C) 2018-2025 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-09-21 21:34:20 +08:00
|
|
|
#include "shared/test/common/libult/create_command_stream.h"
|
2020-02-03 20:19:12 +08:00
|
|
|
|
2023-11-18 01:01:46 +08:00
|
|
|
#include "shared/source/command_stream/aub_command_stream_receiver.h"
|
2021-09-23 06:03:07 +08:00
|
|
|
#include "shared/source/command_stream/create_command_stream_impl.h"
|
2023-11-18 01:01:46 +08:00
|
|
|
#include "shared/source/command_stream/tbx_command_stream_receiver.h"
|
2022-12-22 19:31:28 +08:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2022-03-26 05:04:08 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2022-11-10 17:37:42 +08:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
|
|
|
#include "shared/test/common/helpers/ult_hw_config.h"
|
2025-02-17 22:16:02 +08:00
|
|
|
#include "shared/test/common/mocks/mock_memory_operations_handler.h"
|
2021-01-21 20:10:13 +08:00
|
|
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
2023-11-18 01:01:46 +08:00
|
|
|
#include "shared/test/common/tests_configuration.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
extern CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE];
|
2018-02-14 20:48:31 +08:00
|
|
|
|
2020-10-29 22:33:35 +08:00
|
|
|
CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield) {
|
2020-02-18 20:29:30 +08:00
|
|
|
auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
2019-08-07 00:01:26 +08:00
|
|
|
|
2020-02-03 20:19:12 +08:00
|
|
|
if (ultHwConfig.useHwCsr) {
|
2020-10-28 23:08:37 +08:00
|
|
|
return createCommandStreamImpl(executionEnvironment, rootDeviceIndex, deviceBitfield);
|
2019-08-07 00:01:26 +08:00
|
|
|
}
|
|
|
|
|
2023-11-18 01:01:46 +08:00
|
|
|
if (ultHwConfig.aubTestName != nullptr) {
|
2023-12-13 17:17:24 +08:00
|
|
|
if (testMode == TestMode::aubTestsWithTbx) {
|
2023-11-18 01:01:46 +08:00
|
|
|
return TbxCommandStreamReceiver::create(ultHwConfig.aubTestName, true, executionEnvironment, rootDeviceIndex, deviceBitfield);
|
|
|
|
} else {
|
|
|
|
return AUBCommandStreamReceiver::create(ultHwConfig.aubTestName, true, executionEnvironment, rootDeviceIndex, deviceBitfield);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-07 00:01:26 +08:00
|
|
|
auto funcCreate = commandStreamReceiverFactory[IGFX_MAX_CORE + hwInfo->platform.eRenderCoreFamily];
|
|
|
|
if (funcCreate) {
|
2020-10-28 23:08:37 +08:00
|
|
|
return funcCreate(false, executionEnvironment, rootDeviceIndex, deviceBitfield);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2019-08-07 00:01:26 +08:00
|
|
|
return nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2020-03-23 16:13:25 +08:00
|
|
|
bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment) {
|
2022-06-08 16:23:02 +08:00
|
|
|
auto retVal = true;
|
2025-02-17 18:42:28 +08:00
|
|
|
if (ultHwConfig.sourceExecutionEnvironment && ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc) {
|
|
|
|
if (executionEnvironment.rootDeviceEnvironments.size() < ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments.size()) {
|
|
|
|
executionEnvironment.rootDeviceEnvironments.resize(ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments.size());
|
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments.size(); i++) {
|
|
|
|
executionEnvironment.rootDeviceEnvironments[i] = std::make_unique<RootDeviceEnvironment>(executionEnvironment);
|
|
|
|
executionEnvironment.rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(defaultHwInfo.get());
|
|
|
|
executionEnvironment.rootDeviceEnvironments[i]->initGmm();
|
2025-02-17 22:16:02 +08:00
|
|
|
executionEnvironment.rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique<MockMemoryOperations>();
|
2025-02-17 18:42:28 +08:00
|
|
|
|
|
|
|
executionEnvironment.rootDeviceEnvironments[i]->getMutableHardwareInfo()->platform = ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments[i]->getHardwareInfo()->platform;
|
|
|
|
executionEnvironment.rootDeviceEnvironments[i]->getMutableHardwareInfo()->capabilityTable = ultHwConfig.sourceExecutionEnvironment->rootDeviceEnvironments[i]->getHardwareInfo()->capabilityTable;
|
|
|
|
}
|
|
|
|
return ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult;
|
|
|
|
}
|
2020-03-04 15:51:02 +08:00
|
|
|
if (executionEnvironment.rootDeviceEnvironments.size() == 0) {
|
|
|
|
executionEnvironment.prepareRootDeviceEnvironments(1u);
|
|
|
|
}
|
|
|
|
auto currentHwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
2020-01-30 16:36:05 +08:00
|
|
|
if (currentHwInfo->platform.eProductFamily == IGFX_UNKNOWN && currentHwInfo->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE) {
|
2023-01-03 18:27:35 +08:00
|
|
|
executionEnvironment.rootDeviceEnvironments[0]->setHwInfoAndInitHelpers(defaultHwInfo.get());
|
2020-01-30 16:36:05 +08:00
|
|
|
}
|
2022-06-08 16:23:02 +08:00
|
|
|
|
2020-03-23 16:13:25 +08:00
|
|
|
if (ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc) {
|
2023-11-30 16:32:25 +08:00
|
|
|
uint32_t numRootDevices = debugManager.flags.CreateMultipleRootDevices.get() != 0 ? debugManager.flags.CreateMultipleRootDevices.get() : 1u;
|
2025-01-13 20:18:55 +08:00
|
|
|
retVal = UltDeviceFactory::prepareDeviceEnvironments(executionEnvironment, numRootDevices);
|
|
|
|
retVal &= ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult;
|
2022-06-08 16:23:02 +08:00
|
|
|
} else {
|
|
|
|
retVal = prepareDeviceEnvironmentsImpl(executionEnvironment);
|
|
|
|
}
|
|
|
|
|
2025-01-13 20:18:55 +08:00
|
|
|
if (retVal) {
|
|
|
|
for (uint32_t rootDeviceIndex = 0u; rootDeviceIndex < executionEnvironment.rootDeviceEnvironments.size(); rootDeviceIndex++) {
|
|
|
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->initGmm();
|
|
|
|
}
|
2018-02-14 20:48:31 +08:00
|
|
|
}
|
2018-06-21 00:25:40 +08:00
|
|
|
|
2022-06-08 16:23:02 +08:00
|
|
|
return retVal;
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
2021-10-11 23:34:03 +08:00
|
|
|
|
|
|
|
bool prepareDeviceEnvironment(ExecutionEnvironment &executionEnvironment, std::string &osPciPath, const uint32_t rootDeviceIndex) {
|
2022-06-14 18:46:03 +08:00
|
|
|
auto retVal = true;
|
2021-10-11 23:34:03 +08:00
|
|
|
executionEnvironment.prepareRootDeviceEnvironment(rootDeviceIndex);
|
|
|
|
auto currentHwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
|
|
|
if (currentHwInfo->platform.eProductFamily == IGFX_UNKNOWN && currentHwInfo->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE) {
|
2023-01-03 18:27:35 +08:00
|
|
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->setHwInfoAndInitHelpers(defaultHwInfo.get());
|
2021-10-11 23:34:03 +08:00
|
|
|
}
|
|
|
|
if (ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc) {
|
2023-11-30 16:32:25 +08:00
|
|
|
uint32_t numRootDevices = debugManager.flags.CreateMultipleRootDevices.get() != 0 ? debugManager.flags.CreateMultipleRootDevices.get() : 1u;
|
2021-10-11 23:34:03 +08:00
|
|
|
UltDeviceFactory::prepareDeviceEnvironments(executionEnvironment, numRootDevices);
|
2022-06-14 18:46:03 +08:00
|
|
|
retVal = ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult;
|
|
|
|
} else {
|
|
|
|
retVal = prepareDeviceEnvironmentImpl(executionEnvironment, osPciPath, rootDeviceIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t rootDeviceIndex = 0u; rootDeviceIndex < executionEnvironment.rootDeviceEnvironments.size(); rootDeviceIndex++) {
|
|
|
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->initGmm();
|
2021-10-11 23:34:03 +08:00
|
|
|
}
|
|
|
|
|
2022-06-14 18:46:03 +08:00
|
|
|
return retVal;
|
2021-10-11 23:34:03 +08:00
|
|
|
}
|
2022-02-04 21:41:04 +08:00
|
|
|
const HardwareInfo *getDefaultHwInfo() {
|
|
|
|
return defaultHwInfo.get();
|
|
|
|
}
|
2021-10-11 23:34:03 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|