2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-01-07 22:53:31 +08:00
|
|
|
* Copyright (C) 2018-2022 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
|
2020-10-16 18:10:52 +08:00
|
|
|
#include "shared/source/aub/aub_center.h"
|
2021-07-06 21:44:16 +08:00
|
|
|
#include "shared/source/command_stream/aub_command_stream_receiver.h"
|
2021-09-23 06:03:07 +08:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver_simulated_hw.h"
|
2022-01-07 22:53:31 +08:00
|
|
|
#include "shared/source/command_stream/submission_status.h"
|
2022-02-22 20:51:29 +08:00
|
|
|
#include "shared/source/command_stream/wait_status.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/array_count.h"
|
2020-11-02 22:54:01 +08:00
|
|
|
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
2021-05-13 21:27:50 +08:00
|
|
|
#include "shared/source/memory_manager/page_table.h"
|
2020-10-15 01:22:01 +08:00
|
|
|
#include "shared/source/memory_manager/physical_address_allocator.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/spinlock.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-08-27 04:36:51 +08:00
|
|
|
#include "aub_mapper.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-06-13 02:33:03 +08:00
|
|
|
|
|
|
|
class AubSubCaptureManager;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2018-09-26 04:47:03 +08:00
|
|
|
class AUBCommandStreamReceiverHw : 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-08-17 19:38:09 +08:00
|
|
|
using ExternalAllocationsContainer = std::vector<AllocationView>;
|
2019-02-06 20:32:49 +08:00
|
|
|
using BaseClass::getParametersForWriteMemory;
|
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;
|
2019-01-07 21:50:54 +08:00
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::aubManager;
|
2019-02-07 20:21:58 +08:00
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::hardwareContextController;
|
2019-03-20 15:55:02 +08:00
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::engineInfo;
|
2018-11-02 13:28:20 +08:00
|
|
|
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::stream;
|
|
|
|
|
2022-01-07 22:53:31 +08:00
|
|
|
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-02-04 00:50:53 +08:00
|
|
|
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) 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-11-02 13:28:20 +08:00
|
|
|
AubMemDump::AubFileStream *getAubStream() const {
|
|
|
|
return static_cast<AubMemDump::AubFileStream *>(this->stream);
|
|
|
|
}
|
|
|
|
|
2019-02-15 18:31:47 +08:00
|
|
|
void writeMemory(uint64_t gpuAddress, void *cpuAddress, size_t size, uint32_t memoryBank, uint64_t entryBits) override;
|
2019-02-11 16:04:16 +08:00
|
|
|
bool writeMemory(GraphicsAllocation &gfxAllocation) override;
|
2018-08-17 19:38:09 +08:00
|
|
|
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
|
2021-02-22 20:02:08 +08:00
|
|
|
void writeMMIO(uint32_t offset, uint32_t value) override;
|
2018-09-24 12:42:07 +08:00
|
|
|
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue);
|
2020-03-19 20:48:13 +08:00
|
|
|
bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override;
|
2018-01-11 05:03:23 +08:00
|
|
|
|
2021-09-23 03:25:21 +08:00
|
|
|
AubSubCaptureStatus checkAndActivateAubSubCapture(const std::string &kernelName) override;
|
2019-04-01 15:33:19 +08:00
|
|
|
void addAubComment(const char *message) override;
|
2018-06-13 02:33:03 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
// Family specific version
|
2021-06-21 23:24:14 +08:00
|
|
|
MOCKABLE_VIRTUAL void submitBatchBufferAub(uint64_t batchBufferGpuAddress, const void *batchBuffer, size_t batchBufferSize, uint32_t memoryBank, uint64_t entryBits);
|
2019-02-11 16:04:16 +08:00
|
|
|
void pollForCompletion() override;
|
|
|
|
void pollForCompletionImpl() override;
|
2022-03-23 22:36:07 +08:00
|
|
|
WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-10-31 02:08:09 +08:00
|
|
|
uint32_t getDumpHandle();
|
2018-10-20 02:32:05 +08:00
|
|
|
MOCKABLE_VIRTUAL void addContextToken(uint32_t dumpHandle);
|
2020-04-15 21:30:29 +08:00
|
|
|
void dumpAllocation(GraphicsAllocation &gfxAllocation) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-10-28 23:08:37 +08:00
|
|
|
static CommandStreamReceiver *create(const std::string &fileName,
|
|
|
|
bool standalone,
|
|
|
|
ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
2020-10-29 22:33:35 +08:00
|
|
|
const DeviceBitfield deviceBitfield);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-10-29 22:33:35 +08:00
|
|
|
AUBCommandStreamReceiverHw(const std::string &fileName,
|
|
|
|
bool standalone,
|
|
|
|
ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield);
|
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-09-20 06:36:44 +08:00
|
|
|
MOCKABLE_VIRTUAL void openFile(const std::string &fileName);
|
|
|
|
MOCKABLE_VIRTUAL bool reopenFile(const std::string &fileName);
|
2018-07-09 17:31:36 +08:00
|
|
|
MOCKABLE_VIRTUAL void initFile(const std::string &fileName);
|
|
|
|
MOCKABLE_VIRTUAL void closeFile();
|
2018-10-02 16:37:17 +08:00
|
|
|
MOCKABLE_VIRTUAL bool isFileOpen() const;
|
2019-02-20 05:50:52 +08:00
|
|
|
MOCKABLE_VIRTUAL const std::string getFileName();
|
2018-07-09 17:31:36 +08:00
|
|
|
|
2021-10-14 20:49:06 +08:00
|
|
|
MOCKABLE_VIRTUAL void initializeEngine() override;
|
2019-06-03 15:57:27 +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-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
|
2018-10-02 16:37:17 +08:00
|
|
|
AddressMapper *gttRemap;
|
2018-03-01 05:50:41 +08:00
|
|
|
|
2018-03-14 18:07:51 +08:00
|
|
|
MOCKABLE_VIRTUAL bool addPatchInfoComments();
|
2019-01-29 18:48:54 +08:00
|
|
|
void addGUCStartMessage(uint64_t batchBufferAddress);
|
|
|
|
uint32_t getGUCWorkQueueItemHeader();
|
2018-06-06 16:34:51 +08:00
|
|
|
|
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_AUB;
|
|
|
|
}
|
2018-07-09 17:31:36 +08:00
|
|
|
|
2018-09-21 10:33:21 +08:00
|
|
|
int getAddressSpaceFromPTEBits(uint64_t entryBits) const;
|
|
|
|
|
2018-07-09 17:31:36 +08:00
|
|
|
protected:
|
2019-01-25 16:27:11 +08:00
|
|
|
constexpr static uint32_t getMaskAndValueForPollForCompletion();
|
|
|
|
|
2018-07-09 17:31:36 +08:00
|
|
|
bool dumpAubNonWritable = false;
|
2021-10-14 19:47:16 +08:00
|
|
|
bool isEngineInitialized = false;
|
2018-08-17 19:38:09 +08:00
|
|
|
ExternalAllocationsContainer externalAllocations;
|
2019-01-29 17:39:34 +08:00
|
|
|
|
|
|
|
uint32_t pollForCompletionTaskCount = 0u;
|
|
|
|
SpinLock pollForCompletionLock;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|