2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2017-11-14 18:15:09 +08:00
|
|
|
* Copyright (c) 2017 - 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/gen_common/aub_mapper.h"
|
|
|
|
#include "runtime/command_stream/command_stream_receiver_hw.h"
|
|
|
|
#include "runtime/command_stream/aub_command_stream_receiver.h"
|
|
|
|
#include "runtime/memory_manager/address_mapper.h"
|
|
|
|
#include "runtime/memory_manager/page_table.h"
|
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
|
|
|
|
namespace OCLRT {
|
2018-06-13 02:33:03 +08:00
|
|
|
|
|
|
|
class AubSubCaptureManager;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
|
|
|
|
typedef CommandStreamReceiverHw<GfxFamily> BaseClass;
|
|
|
|
typedef typename AUBFamilyMapper<GfxFamily>::AUB AUB;
|
|
|
|
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
|
2018-08-17 19:38:09 +08:00
|
|
|
using ExternalAllocationsContainer = std::vector<AllocationView>;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
public:
|
2018-08-27 21:48:29 +08:00
|
|
|
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer *allocationsForResidency, OsContext &osContext) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
|
|
|
|
|
2018-09-14 16:39:21 +08:00
|
|
|
void processResidency(ResidencyContainer &allocationsForResidency, OsContext &osContext) override;
|
2018-06-13 02:33:03 +08:00
|
|
|
|
2018-08-17 19:38:09 +08:00
|
|
|
void makeResidentExternal(AllocationView &allocationView);
|
|
|
|
void makeNonResidentExternal(uint64_t gpuAddress);
|
|
|
|
|
2018-07-09 17:31:36 +08:00
|
|
|
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation);
|
2018-08-17 19:38:09 +08:00
|
|
|
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
|
2018-01-11 05:03:23 +08:00
|
|
|
|
2018-06-13 02:33:03 +08:00
|
|
|
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
// Family specific version
|
2017-11-14 18:15:09 +08:00
|
|
|
void submitLRCA(EngineType engineType, const MiContextDescriptorReg &contextDescriptor);
|
|
|
|
void pollForCompletion(EngineType engineType);
|
2017-12-21 07:45:38 +08:00
|
|
|
void initGlobalMMIO();
|
2017-11-14 18:15:09 +08:00
|
|
|
void initEngineMMIO(EngineType engineType);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
void addContextToken();
|
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
~AUBCommandStreamReceiverHw() override;
|
|
|
|
|
2018-01-19 17:00:51 +08:00
|
|
|
AUBCommandStreamReceiverHw(const AUBCommandStreamReceiverHw &) = delete;
|
|
|
|
AUBCommandStreamReceiverHw &operator=(const AUBCommandStreamReceiverHw &) = delete;
|
|
|
|
|
2018-07-09 17:31:36 +08:00
|
|
|
MOCKABLE_VIRTUAL void initFile(const std::string &fileName);
|
|
|
|
MOCKABLE_VIRTUAL void closeFile();
|
|
|
|
MOCKABLE_VIRTUAL bool isFileOpen();
|
|
|
|
MOCKABLE_VIRTUAL const std::string &getFileName();
|
|
|
|
|
2017-11-14 18:15:09 +08:00
|
|
|
void initializeEngine(EngineType engineType);
|
2018-07-09 17:31:36 +08:00
|
|
|
void freeEngineInfoTable();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-06 16:53:35 +08:00
|
|
|
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
|
|
|
this->memoryManager = new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory);
|
2018-04-04 17:34:46 +08:00
|
|
|
this->flatBatchBufferHelper->setMemoryManager(this->memoryManager);
|
2017-12-21 07:45:38 +08:00
|
|
|
return this->memoryManager;
|
|
|
|
}
|
|
|
|
|
2017-11-14 18:15:09 +08:00
|
|
|
static const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType);
|
2017-12-21 07:45:38 +08: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-07-09 17:31:36 +08:00
|
|
|
} engineInfoTable[EngineType::NUM_ENGINES] = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-14 18:07:51 +08:00
|
|
|
std::unique_ptr<AUBCommandStreamReceiver::AubFileStream> stream;
|
2018-06-13 02:33:03 +08:00
|
|
|
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
|
2018-06-06 23:03:46 +08:00
|
|
|
uint32_t aubDeviceId;
|
2018-01-19 17:00:51 +08:00
|
|
|
bool standalone;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-11 20:45:43 +08:00
|
|
|
PhysicalAddressAllocator physicalAddressAllocator;
|
2018-09-04 04:44:58 +08:00
|
|
|
std::unique_ptr<TypeSelector<PML4, PDPE, sizeof(void *) == 8>::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-03-01 05:50:41 +08:00
|
|
|
|
2018-03-14 18:07:51 +08:00
|
|
|
MOCKABLE_VIRTUAL bool addPatchInfoComments();
|
2018-04-04 17:34:46 +08:00
|
|
|
void addGUCStartMessage(uint64_t batchBufferAddress, EngineType engineType);
|
|
|
|
uint32_t getGUCWorkQueueItemHeader(EngineType engineType);
|
2018-05-09 21:25:01 +08:00
|
|
|
uint64_t getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation);
|
|
|
|
void getGTTData(void *memory, AubGTTData &data);
|
2018-06-06 16:34:51 +08:00
|
|
|
|
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_AUB;
|
|
|
|
}
|
2018-07-09 17:31:36 +08:00
|
|
|
|
|
|
|
protected:
|
2018-09-07 21:12:07 +08:00
|
|
|
int getAddressSpace(int hint);
|
|
|
|
|
2018-07-09 17:31:36 +08:00
|
|
|
bool dumpAubNonWritable = false;
|
2018-08-17 19:38:09 +08:00
|
|
|
ExternalAllocationsContainer externalAllocations;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
} // namespace OCLRT
|