2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2023-01-02 09:56:45 +00:00
|
|
|
* Copyright (C) 2018-2023 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
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-03-19 14:26:08 +01:00
|
|
|
|
|
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/device/root_device.h"
|
|
|
|
|
#include "shared/source/device/sub_device.h"
|
2022-12-15 17:32:03 +00:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
|
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2022-11-16 14:01:52 +00:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
2021-01-21 13:10:13 +01:00
|
|
|
#include "shared/test/common/helpers/variable_backup.h"
|
2020-02-22 09:28:27 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2020-03-19 14:26:08 +01:00
|
|
|
class CommandStreamReceiver;
|
|
|
|
|
class DriverInfo;
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
class UltCommandStreamReceiver;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-10-29 15:33:35 +01:00
|
|
|
extern CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnvironment,
|
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
|
const DeviceBitfield deviceBitfield);
|
2018-07-12 10:04:07 +02:00
|
|
|
|
2019-11-05 13:38:20 +01:00
|
|
|
struct MockSubDevice : public SubDevice {
|
2021-12-13 12:45:24 +00:00
|
|
|
using Device::allEngines;
|
2021-05-09 19:41:56 +00:00
|
|
|
using Device::createEngines;
|
2021-05-06 11:33:39 +00:00
|
|
|
using Device::engineInstancedType;
|
2021-04-23 10:56:13 +00:00
|
|
|
using SubDevice::engineInstanced;
|
2020-10-30 10:27:48 +01:00
|
|
|
using SubDevice::getDeviceBitfield;
|
2020-04-16 14:44:03 +02:00
|
|
|
using SubDevice::getGlobalMemorySize;
|
2019-11-05 13:38:20 +01:00
|
|
|
using SubDevice::SubDevice;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const override {
|
2020-10-28 16:08:37 +01:00
|
|
|
return std::unique_ptr<CommandStreamReceiver>(createCommandStreamReceiverFunc(*executionEnvironment, getRootDeviceIndex(), getDeviceBitfield()));
|
2019-11-05 13:38:20 +01:00
|
|
|
}
|
|
|
|
|
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
2021-04-28 17:46:13 +00:00
|
|
|
|
|
|
|
|
bool failOnCreateEngine = false;
|
|
|
|
|
bool createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsage) override;
|
2019-11-05 13:38:20 +01:00
|
|
|
};
|
|
|
|
|
|
2019-08-27 09:34:20 +02:00
|
|
|
class MockDevice : public RootDevice {
|
2017-12-21 00:45:38 +01:00
|
|
|
public:
|
2021-09-16 14:53:49 +00:00
|
|
|
using Device::addEngineToEngineGroup;
|
2021-12-13 12:45:24 +00:00
|
|
|
using Device::allEngines;
|
2019-11-05 13:38:20 +01:00
|
|
|
using Device::commandStreamReceivers;
|
2019-08-06 18:01:26 +02:00
|
|
|
using Device::createDeviceInternals;
|
2019-07-16 09:23:02 +02:00
|
|
|
using Device::createEngine;
|
2021-04-27 09:51:03 +00:00
|
|
|
using Device::createSubDevices;
|
2023-01-19 08:57:27 +00:00
|
|
|
using Device::defaultBcsEngineIndex;
|
2021-09-27 23:27:46 +00:00
|
|
|
using Device::deviceBitfield;
|
2019-08-26 15:36:24 +02:00
|
|
|
using Device::deviceInfo;
|
2021-05-10 15:24:31 +00:00
|
|
|
using Device::engineInstanced;
|
2021-05-06 11:33:39 +00:00
|
|
|
using Device::engineInstancedType;
|
2018-07-11 14:16:35 +02:00
|
|
|
using Device::executionEnvironment;
|
2023-01-05 15:01:17 +01:00
|
|
|
using Device::generateUuidFromPciBusInfo;
|
2020-04-16 14:44:03 +02:00
|
|
|
using Device::getGlobalMemorySize;
|
2018-01-26 16:53:18 +01:00
|
|
|
using Device::initializeCaps;
|
2021-04-16 12:52:30 +00:00
|
|
|
using Device::isDebuggerActive;
|
2023-01-26 11:33:18 +00:00
|
|
|
using Device::regularContextPerBcsEngineAssignmentHelper;
|
|
|
|
|
using Device::regularContextPerCcsEngineAssignmentHelper;
|
2021-12-13 12:45:24 +00:00
|
|
|
using Device::regularEngineGroups;
|
2021-10-12 21:28:34 +00:00
|
|
|
using Device::rootCsrCreated;
|
2021-02-26 22:02:57 +00:00
|
|
|
using Device::rtMemoryBackedBuffer;
|
2023-01-05 15:01:17 +01:00
|
|
|
using Device::uuid;
|
2019-11-05 13:38:20 +01:00
|
|
|
using RootDevice::createEngines;
|
2020-05-25 12:11:30 +02:00
|
|
|
using RootDevice::defaultEngineIndex;
|
2020-06-02 10:04:25 +02:00
|
|
|
using RootDevice::getDeviceBitfield;
|
2020-09-15 10:11:12 +02:00
|
|
|
using RootDevice::initializeRootCommandStreamReceiver;
|
2021-01-25 09:24:00 +00:00
|
|
|
using RootDevice::numSubDevices;
|
2019-08-28 13:12:44 +02:00
|
|
|
using RootDevice::subdevices;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
void setOSTime(OSTime *osTime);
|
|
|
|
|
|
2019-10-07 12:42:28 +02:00
|
|
|
static bool createSingleDevice;
|
|
|
|
|
bool createDeviceImpl() override;
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
bool getCpuTime(uint64_t *timeStamp) { return true; };
|
2019-05-06 12:33:44 +02:00
|
|
|
MockDevice();
|
2019-11-05 13:38:20 +01:00
|
|
|
MockDevice(ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
void setPreemptionMode(PreemptionMode mode) {
|
|
|
|
|
preemptionMode = mode;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-09 11:50:58 +02:00
|
|
|
void injectMemoryManager(MemoryManager *);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-07-06 17:44:49 +00:00
|
|
|
void setPerfCounters(std::unique_ptr<PerformanceCounters> perfCounters) {
|
|
|
|
|
performanceCounters = std::move(perfCounters);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-27 12:44:57 +00:00
|
|
|
size_t getMaxParameterSizeFromIGC() const override {
|
2021-12-28 16:44:23 +00:00
|
|
|
if (callBaseGetMaxParameterSizeFromIGC) {
|
|
|
|
|
return Device::getMaxParameterSizeFromIGC();
|
|
|
|
|
}
|
2021-12-27 12:44:57 +00:00
|
|
|
return maxParameterSizeFromIGC;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-29 10:30:14 +01:00
|
|
|
const char *getProductAbbrev() const;
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename T>
|
|
|
|
|
UltCommandStreamReceiver<T> &getUltCommandStreamReceiver() {
|
2021-12-13 12:45:24 +00:00
|
|
|
return reinterpret_cast<UltCommandStreamReceiver<T> &>(*allEngines[defaultEngineIndex].commandStreamReceiver);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-28 11:13:04 +02:00
|
|
|
template <typename T>
|
|
|
|
|
UltCommandStreamReceiver<T> &getUltCommandStreamReceiverFromIndex(uint32_t index) {
|
2021-12-13 12:45:24 +00:00
|
|
|
return reinterpret_cast<UltCommandStreamReceiver<T> &>(*allEngines[index].commandStreamReceiver);
|
2019-08-28 11:13:04 +02:00
|
|
|
}
|
2021-12-13 12:45:24 +00:00
|
|
|
CommandStreamReceiver &getGpgpuCommandStreamReceiver() const { return *allEngines[defaultEngineIndex].commandStreamReceiver; }
|
2017-12-21 00:45:38 +01:00
|
|
|
void resetCommandStreamReceiver(CommandStreamReceiver *newCsr);
|
2019-03-22 14:04:25 +01:00
|
|
|
void resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint32_t engineIndex);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-02-10 15:57:49 +01:00
|
|
|
void setDebuggerActive(bool active) {
|
|
|
|
|
this->deviceInfo.debuggerActive = active;
|
2018-04-10 13:49:26 +02:00
|
|
|
}
|
2018-07-20 09:01:58 +02:00
|
|
|
|
2018-04-23 16:08:57 +02:00
|
|
|
template <typename T>
|
2019-11-05 13:38:20 +01:00
|
|
|
static T *createWithExecutionEnvironment(const HardwareInfo *pHwInfo, ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex) {
|
2020-03-24 17:04:08 +01:00
|
|
|
pHwInfo = pHwInfo ? pHwInfo : defaultHwInfo.get();
|
2023-01-03 10:27:35 +00:00
|
|
|
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->setHwInfoAndInitHelpers(pHwInfo);
|
2019-11-05 13:38:20 +01:00
|
|
|
T *device = new T(executionEnvironment, rootDeviceIndex);
|
2019-05-06 12:33:44 +02:00
|
|
|
return createDeviceInternals(device);
|
2018-07-03 10:00:12 +02:00
|
|
|
}
|
2018-04-10 13:49:26 +02:00
|
|
|
|
2023-01-02 09:56:45 +00:00
|
|
|
static ExecutionEnvironment *prepareExecutionEnvironment(const HardwareInfo *pHwInfo, uint32_t rootDeviceIndex);
|
2021-09-13 16:49:13 +00:00
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
static T *createWithNewExecutionEnvironment(const HardwareInfo *pHwInfo, uint32_t rootDeviceIndex = 0) {
|
|
|
|
|
auto executionEnvironment = prepareExecutionEnvironment(pHwInfo, rootDeviceIndex);
|
2019-12-04 13:45:32 +01:00
|
|
|
return createWithExecutionEnvironment<T>(pHwInfo, executionEnvironment, rootDeviceIndex);
|
2018-08-21 15:47:21 +02:00
|
|
|
}
|
2019-11-05 13:38:20 +01:00
|
|
|
|
|
|
|
|
SubDevice *createSubDevice(uint32_t subDeviceIndex) override {
|
|
|
|
|
return Device::create<MockSubDevice>(executionEnvironment, subDeviceIndex, *this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 10:56:13 +00:00
|
|
|
SubDevice *createEngineInstancedSubDevice(uint32_t subDeviceIndex, aub_stream::EngineType engineType) override {
|
|
|
|
|
return Device::create<MockSubDevice>(executionEnvironment, subDeviceIndex, *this, engineType);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-05 13:38:20 +01:00
|
|
|
std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const override {
|
2020-10-28 16:08:37 +01:00
|
|
|
return std::unique_ptr<CommandStreamReceiver>(createCommandStreamReceiverFunc(*executionEnvironment, getRootDeviceIndex(), getDeviceBitfield()));
|
2019-11-05 13:38:20 +01:00
|
|
|
}
|
2018-08-21 15:47:21 +02:00
|
|
|
|
2021-04-16 12:52:30 +00:00
|
|
|
bool isDebuggerActive() const override {
|
|
|
|
|
if (isDebuggerActiveParentCall) {
|
|
|
|
|
return Device::isDebuggerActive();
|
|
|
|
|
}
|
|
|
|
|
return isDebuggerActiveReturn;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-11 14:08:18 +00:00
|
|
|
bool verifyAdapterLuid() override;
|
|
|
|
|
|
2023-01-02 09:56:45 +00:00
|
|
|
void finalizeRayTracing();
|
2022-07-21 18:44:54 +00:00
|
|
|
|
|
|
|
|
void setRTDispatchGlobalsForceAllocation() {
|
|
|
|
|
rtDispatchGlobalsForceAllocation = true;
|
|
|
|
|
}
|
2022-11-16 15:50:07 +00:00
|
|
|
static ExecutionEnvironment *prepareExecutionEnvironment(const HardwareInfo *pHwInfo);
|
2020-01-20 07:02:07 +01:00
|
|
|
static decltype(&createCommandStream) createCommandStreamReceiverFunc;
|
2021-04-16 12:52:30 +00:00
|
|
|
|
|
|
|
|
bool isDebuggerActiveParentCall = true;
|
|
|
|
|
bool isDebuggerActiveReturn = false;
|
2021-12-28 16:44:23 +00:00
|
|
|
bool callBaseGetMaxParameterSizeFromIGC = false;
|
2022-05-11 14:08:18 +00:00
|
|
|
bool callBaseVerifyAdapterLuid = true;
|
|
|
|
|
bool verifyAdapterLuidReturnValue = true;
|
2021-12-27 12:44:57 +00:00
|
|
|
size_t maxParameterSizeFromIGC = 0u;
|
2022-07-21 18:44:54 +00:00
|
|
|
bool rtDispatchGlobalsForceAllocation = true;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2018-07-20 09:01:58 +02:00
|
|
|
template <>
|
2019-12-04 13:45:32 +01:00
|
|
|
inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const HardwareInfo *pHwInfo, uint32_t rootDeviceIndex) {
|
2022-11-16 15:50:07 +00:00
|
|
|
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(pHwInfo);
|
2019-09-17 10:44:49 +02:00
|
|
|
return Device::create<RootDevice>(executionEnvironment, 0u);
|
2018-07-20 09:01:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FailDevice : public MockDevice {
|
2017-12-21 00:45:38 +01:00
|
|
|
public:
|
2019-05-06 12:33:44 +02:00
|
|
|
FailDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2018-07-20 09:01:58 +02:00
|
|
|
class FailDeviceAfterOne : public MockDevice {
|
2017-12-21 00:45:38 +01:00
|
|
|
public:
|
2019-05-06 12:33:44 +02:00
|
|
|
FailDeviceAfterOne(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2018-01-26 16:53:18 +01:00
|
|
|
class MockAlignedMallocManagerDevice : public MockDevice {
|
|
|
|
|
public:
|
2019-05-06 12:33:44 +02:00
|
|
|
MockAlignedMallocManagerDevice(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
2018-01-26 16:53:18 +01:00
|
|
|
};
|
2019-11-05 13:38:20 +01:00
|
|
|
|
|
|
|
|
struct EnvironmentWithCsrWrapper {
|
|
|
|
|
template <typename CsrType>
|
|
|
|
|
void setCsrType() {
|
|
|
|
|
createSubDeviceCsrFuncBackup = EnvironmentWithCsrWrapper::createCommandStreamReceiver<CsrType>;
|
|
|
|
|
createRootDeviceCsrFuncBackup = EnvironmentWithCsrWrapper::createCommandStreamReceiver<CsrType>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename CsrType>
|
2020-10-29 15:33:35 +01:00
|
|
|
static CommandStreamReceiver *createCommandStreamReceiver(ExecutionEnvironment &executionEnvironment,
|
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
|
const DeviceBitfield deviceBitfield) {
|
2020-10-28 16:08:37 +01:00
|
|
|
return new CsrType(executionEnvironment, rootDeviceIndex, deviceBitfield);
|
2019-11-05 13:38:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VariableBackup<decltype(MockSubDevice::createCommandStreamReceiverFunc)> createSubDeviceCsrFuncBackup{&MockSubDevice::createCommandStreamReceiverFunc};
|
|
|
|
|
VariableBackup<decltype(MockDevice::createCommandStreamReceiverFunc)> createRootDeviceCsrFuncBackup{&MockDevice::createCommandStreamReceiverFunc};
|
|
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|