2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-19 04:17:55 +08:00
|
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-19 04:17:55 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/gen_common/aub_mapper.h"
|
2018-09-26 04:47:03 +08:00
|
|
|
#include "command_stream_receiver_simulated_hw.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/command_stream/tbx_command_stream_receiver.h"
|
|
|
|
#include "runtime/memory_manager/address_mapper.h"
|
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
#include "runtime/memory_manager/page_table.h"
|
2018-12-19 20:15:14 +08:00
|
|
|
#include "third_party/aub_stream/headers/aub_manager.h"
|
|
|
|
#include "third_party/aub_stream/headers/hardware_context.h"
|
|
|
|
|
|
|
|
using namespace AubDump;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
2018-11-02 13:28:20 +08:00
|
|
|
class TbxStream;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
class TbxMemoryManager : public OsAgnosticMemoryManager {
|
|
|
|
public:
|
2018-10-01 22:10:54 +08:00
|
|
|
TbxMemoryManager(bool enable64kbPages, bool enableLocalMemory, ExecutionEnvironment &executionEnvironment) : OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment) {}
|
2017-12-21 07:45:38 +08:00
|
|
|
uint64_t getSystemSharedMemory() override {
|
|
|
|
return 1 * GB;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-09-26 04:47:03 +08:00
|
|
|
class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFamily> {
|
2018-12-03 17:05:36 +08:00
|
|
|
protected:
|
2018-09-26 04:47:03 +08:00
|
|
|
typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass;
|
2018-12-19 20:11:16 +08:00
|
|
|
using AUB = typename AUBFamilyMapper<GfxFamily>::AUB;
|
2018-11-26 21:04:52 +08:00
|
|
|
using BaseClass::osContext;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
public:
|
2018-11-02 13:28:20 +08:00
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
|
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
|
|
|
|
|
2018-11-26 21:04:52 +08:00
|
|
|
FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2018-04-03 18:23:14 +08:00
|
|
|
void makeCoherent(GraphicsAllocation &gfxAllocation) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-11-26 21:04:52 +08:00
|
|
|
void processResidency(ResidencyContainer &allocationsForResidency) override;
|
2018-08-02 21:17:58 +08:00
|
|
|
void waitBeforeMakingNonResidentWhenRequired() override;
|
2018-12-19 20:15:14 +08:00
|
|
|
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits, DevicesBitfield devicesBitfield);
|
2018-03-06 05:16:21 +08:00
|
|
|
bool writeMemory(GraphicsAllocation &gfxAllocation);
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
// Family specific version
|
2018-12-19 20:15:14 +08:00
|
|
|
MOCKABLE_VIRTUAL void submitBatchBuffer(size_t engineIndex, uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits);
|
|
|
|
MOCKABLE_VIRTUAL void pollForCompletion(EngineInstanceT engineInstance);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-30 15:27:47 +08:00
|
|
|
TbxCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
~TbxCommandStreamReceiverHw() override;
|
|
|
|
|
2018-12-19 20:15:14 +08:00
|
|
|
void initializeEngine(size_t engineIndex);
|
|
|
|
|
|
|
|
AubManager *aubManager = nullptr;
|
|
|
|
std::unique_ptr<HardwareContext> hardwareContext;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
struct EngineInfo {
|
|
|
|
void *pLRCA;
|
|
|
|
uint32_t ggttLRCA;
|
|
|
|
void *pGlobalHWStatusPage;
|
|
|
|
uint32_t ggttHWSP;
|
|
|
|
void *pRCS;
|
|
|
|
uint32_t ggttRCS;
|
|
|
|
size_t sizeRCS;
|
|
|
|
uint32_t tailRCS;
|
2018-12-19 20:15:14 +08:00
|
|
|
} engineInfoTable[EngineInstanceConstants::numAllEngineInstances] = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-06 16:53:35 +08:00
|
|
|
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
2018-10-11 17:19:49 +08:00
|
|
|
return new TbxMemoryManager(enable64kbPages, enableLocalMemory, this->executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
TbxMemoryManager *getMemoryManager() {
|
|
|
|
return (TbxMemoryManager *)CommandStreamReceiver::getMemoryManager();
|
|
|
|
}
|
|
|
|
|
2018-11-02 13:28:20 +08:00
|
|
|
TbxStream tbxStream;
|
|
|
|
|
2018-06-06 23:03:46 +08:00
|
|
|
uint32_t aubDeviceId;
|
2018-07-03 23:56:55 +08:00
|
|
|
bool streamInitialized = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-21 04:54:19 +08:00
|
|
|
std::unique_ptr<PhysicalAddressAllocator> physicalAddressAllocator;
|
2018-09-27 21:08:57 +08:00
|
|
|
std::unique_ptr<std::conditional<is64bit, PML4, PDPE>::type> ppgtt;
|
2018-09-11 20:45:43 +08:00
|
|
|
std::unique_ptr<PDPE> ggtt;
|
2017-12-21 07:45:38 +08:00
|
|
|
// remap CPU VA -> GGTT VA
|
|
|
|
AddressMapper gttRemap;
|
2018-06-06 16:34:51 +08:00
|
|
|
|
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_TBX;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
} // namespace OCLRT
|