2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2018-09-18 13:17:55 -07:00
|
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 13:17:55 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
#include "runtime/gen_common/aub_mapper.h"
|
2018-09-25 13:47:03 -07:00
|
|
|
#include "command_stream_receiver_simulated_hw.h"
|
2018-11-10 22:25:48 +01:00
|
|
|
#include "runtime/aub/aub_center.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "runtime/command_stream/aub_command_stream_receiver.h"
|
2018-10-19 11:32:05 -07:00
|
|
|
#include "runtime/helpers/array_count.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "runtime/memory_manager/address_mapper.h"
|
|
|
|
|
#include "runtime/memory_manager/page_table.h"
|
2018-09-26 15:28:11 +02:00
|
|
|
#include "runtime/memory_manager/physical_address_allocator.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
2018-11-26 23:31:00 -08:00
|
|
|
#include "third_party/aub_stream/headers/hardware_context.h"
|
|
|
|
|
|
|
|
|
|
using namespace AubDump;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
namespace OCLRT {
|
2018-06-12 20:33:03 +02:00
|
|
|
|
|
|
|
|
class AubSubCaptureManager;
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename GfxFamily>
|
2018-09-25 13:47:03 -07:00
|
|
|
class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFamily> {
|
2018-12-03 10:05:36 +01:00
|
|
|
protected:
|
2018-09-25 13:47:03 -07:00
|
|
|
typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass;
|
2017-12-21 00:45:38 +01:00
|
|
|
typedef typename AUBFamilyMapper<GfxFamily>::AUB AUB;
|
|
|
|
|
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
|
2018-08-17 13:38:09 +02:00
|
|
|
using ExternalAllocationsContainer = std::vector<AllocationView>;
|
2018-11-26 14:04:52 +01:00
|
|
|
using BaseClass::osContext;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
public:
|
2018-11-01 22:28:20 -07:00
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
|
|
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
|
|
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2017-12-21 00:45:38 +01:00
|
|
|
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
|
|
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
void processResidency(ResidencyContainer &allocationsForResidency) override;
|
2018-06-12 20:33:03 +02:00
|
|
|
|
2018-08-17 13:38:09 +02:00
|
|
|
void makeResidentExternal(AllocationView &allocationView);
|
|
|
|
|
void makeNonResidentExternal(uint64_t gpuAddress);
|
|
|
|
|
|
2018-11-01 22:28:20 -07:00
|
|
|
AubMemDump::AubFileStream *getAubStream() const {
|
|
|
|
|
return static_cast<AubMemDump::AubFileStream *>(this->stream);
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-26 18:17:57 -08:00
|
|
|
MOCKABLE_VIRTUAL void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits, DevicesBitfield devicesBitfield);
|
2018-07-09 11:31:36 +02:00
|
|
|
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation);
|
2018-08-17 13:38:09 +02:00
|
|
|
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
|
2018-09-23 21:42:07 -07:00
|
|
|
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue);
|
2018-11-16 11:18:53 +01:00
|
|
|
|
|
|
|
|
void expectMemoryEqual(void *gfxAddress, const void *srcAddress, size_t length);
|
|
|
|
|
void expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length);
|
2018-01-10 22:03:23 +01:00
|
|
|
|
2018-06-12 20:33:03 +02:00
|
|
|
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
// Family specific version
|
2018-11-25 14:58:12 -08:00
|
|
|
MOCKABLE_VIRTUAL void submitBatchBuffer(size_t engineIndex, uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits);
|
2018-10-24 02:15:06 -07:00
|
|
|
MOCKABLE_VIRTUAL void pollForCompletion(EngineInstanceT engineInstance);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-10-30 11:08:09 -07:00
|
|
|
uint32_t getDumpHandle();
|
2018-10-19 11:32:05 -07:00
|
|
|
MOCKABLE_VIRTUAL void addContextToken(uint32_t dumpHandle);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-08-08 13:49:09 +02:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-08-08 13:49:09 +02:00
|
|
|
AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 00:45:38 +01:00
|
|
|
~AUBCommandStreamReceiverHw() override;
|
|
|
|
|
|
2018-01-19 10:00:51 +01:00
|
|
|
AUBCommandStreamReceiverHw(const AUBCommandStreamReceiverHw &) = delete;
|
|
|
|
|
AUBCommandStreamReceiverHw &operator=(const AUBCommandStreamReceiverHw &) = delete;
|
|
|
|
|
|
2018-09-20 00:36:44 +02:00
|
|
|
MOCKABLE_VIRTUAL void openFile(const std::string &fileName);
|
|
|
|
|
MOCKABLE_VIRTUAL bool reopenFile(const std::string &fileName);
|
2018-07-09 11:31:36 +02:00
|
|
|
MOCKABLE_VIRTUAL void initFile(const std::string &fileName);
|
|
|
|
|
MOCKABLE_VIRTUAL void closeFile();
|
2018-10-02 10:37:17 +02:00
|
|
|
MOCKABLE_VIRTUAL bool isFileOpen() const;
|
2018-07-09 11:31:36 +02:00
|
|
|
MOCKABLE_VIRTUAL const std::string &getFileName();
|
|
|
|
|
|
2018-11-26 23:31:00 -08:00
|
|
|
MOCKABLE_VIRTUAL void initializeEngine(size_t engineIndex);
|
2018-07-09 11:31:36 +02:00
|
|
|
void freeEngineInfoTable();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-09-06 10:53:35 +02:00
|
|
|
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
2018-10-11 11:19:49 +02:00
|
|
|
return new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, true, this->executionEnvironment);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-26 23:31:00 -08:00
|
|
|
AubManager *aubManager = nullptr;
|
|
|
|
|
std::unique_ptr<HardwareContext> hardwareContext;
|
|
|
|
|
EngineType defaultEngineType;
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
struct EngineInfo {
|
|
|
|
|
void *pLRCA;
|
|
|
|
|
uint32_t ggttLRCA;
|
|
|
|
|
void *pGlobalHWStatusPage;
|
|
|
|
|
uint32_t ggttHWSP;
|
|
|
|
|
void *pRingBuffer;
|
|
|
|
|
uint32_t ggttRingBuffer;
|
|
|
|
|
size_t sizeRingBuffer;
|
|
|
|
|
uint32_t tailRingBuffer;
|
2018-12-06 15:54:55 +01:00
|
|
|
} engineInfoTable[EngineInstanceConstants::numAllEngineInstances] = {};
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-06-12 20:33:03 +02:00
|
|
|
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
|
2018-06-06 17:03:46 +02:00
|
|
|
uint32_t aubDeviceId;
|
2018-01-19 10:00:51 +01:00
|
|
|
bool standalone;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-09-27 15:08:57 +02:00
|
|
|
std::unique_ptr<std::conditional<is64bit, PML4, PDPE>::type> ppgtt;
|
2018-09-11 14:45:43 +02:00
|
|
|
std::unique_ptr<PDPE> ggtt;
|
2017-12-21 00:45:38 +01:00
|
|
|
// remap CPU VA -> GGTT VA
|
2018-10-02 10:37:17 +02:00
|
|
|
AddressMapper *gttRemap;
|
2018-02-28 22:50:41 +01:00
|
|
|
|
2018-10-19 11:32:05 -07:00
|
|
|
void setCsrProgrammingMode(void){};
|
2018-03-14 11:07:51 +01:00
|
|
|
MOCKABLE_VIRTUAL bool addPatchInfoComments();
|
2018-04-04 11:34:46 +02:00
|
|
|
void addGUCStartMessage(uint64_t batchBufferAddress, EngineType engineType);
|
|
|
|
|
uint32_t getGUCWorkQueueItemHeader(EngineType engineType);
|
2018-06-06 10:34:51 +02:00
|
|
|
|
|
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
|
return CommandStreamReceiverType::CSR_AUB;
|
|
|
|
|
}
|
2018-07-09 11:31:36 +02:00
|
|
|
|
2018-09-20 19:33:21 -07:00
|
|
|
int getAddressSpaceFromPTEBits(uint64_t entryBits) const;
|
|
|
|
|
|
2018-11-15 14:47:52 +01:00
|
|
|
size_t getPreferredTagPoolSize() const override { return 1; }
|
|
|
|
|
|
2018-07-09 11:31:36 +02:00
|
|
|
protected:
|
2018-11-16 11:18:53 +01:00
|
|
|
MOCKABLE_VIRTUAL void expectMemory(void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
|
2018-07-09 11:31:36 +02:00
|
|
|
bool dumpAubNonWritable = false;
|
2018-08-17 13:38:09 +02:00
|
|
|
ExternalAllocationsContainer externalAllocations;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
} // namespace OCLRT
|