2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-02-04 21:41:04 +08:00
|
|
|
* Copyright (C) 2018-2022 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
|
|
|
|
2021-09-23 06:03:07 +08:00
|
|
|
#include "shared/source/command_stream/create_command_stream_impl.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.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"
|
|
|
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <cassert>
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
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) {
|
2020-03-23 17:23:43 +08:00
|
|
|
executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
|
2020-01-30 16:36:05 +08:00
|
|
|
}
|
2020-03-23 16:13:25 +08:00
|
|
|
if (ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc) {
|
2020-03-20 23:54:09 +08:00
|
|
|
uint32_t numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get() != 0 ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u;
|
2020-11-20 19:04:46 +08:00
|
|
|
UltDeviceFactory::prepareDeviceEnvironments(executionEnvironment, numRootDevices);
|
2020-03-23 16:13:25 +08:00
|
|
|
return ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult;
|
2018-02-14 20:48:31 +08:00
|
|
|
}
|
2018-06-21 00:25:40 +08:00
|
|
|
|
2020-03-23 16:13:25 +08:00
|
|
|
return prepareDeviceEnvironmentsImpl(executionEnvironment);
|
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) {
|
|
|
|
executionEnvironment.prepareRootDeviceEnvironment(rootDeviceIndex);
|
|
|
|
auto currentHwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
|
|
|
if (currentHwInfo->platform.eProductFamily == IGFX_UNKNOWN && currentHwInfo->platform.eRenderCoreFamily == IGFX_UNKNOWN_CORE) {
|
|
|
|
executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->setHwInfo(defaultHwInfo.get());
|
|
|
|
}
|
|
|
|
if (ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc) {
|
|
|
|
uint32_t numRootDevices = DebugManager.flags.CreateMultipleRootDevices.get() != 0 ? DebugManager.flags.CreateMultipleRootDevices.get() : 1u;
|
|
|
|
UltDeviceFactory::prepareDeviceEnvironments(executionEnvironment, numRootDevices);
|
|
|
|
return ultHwConfig.mockedPrepareDeviceEnvironmentsFuncResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
return prepareDeviceEnvironmentImpl(executionEnvironment, osPciPath, rootDeviceIndex);
|
|
|
|
}
|
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
|