mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
AUB subcapture to work with multi CSRs
Related-To: NEO-2747 Change-Id: I2149cafb59bd1a6374da140e3f7e76a4cb3bb417 Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
2504772fd3
commit
8e210941f8
@@ -55,7 +55,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
||||
void expectMMIO(uint32_t mmioRegister, uint32_t expectedValue);
|
||||
cl_int expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override;
|
||||
|
||||
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
||||
AubSubCaptureStatus checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
||||
void addAubComment(const char *message) override;
|
||||
|
||||
// Family specific version
|
||||
@@ -84,7 +84,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
||||
MOCKABLE_VIRTUAL const std::string getFileName();
|
||||
|
||||
MOCKABLE_VIRTUAL void initializeEngine();
|
||||
AubSubCaptureManager *subCaptureManager = nullptr;
|
||||
std::unique_ptr<AubSubCaptureManager> subCaptureManager;
|
||||
uint32_t aubDeviceId;
|
||||
bool standalone;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "runtime/aub_mem_dump/page_table_entry_bits.h"
|
||||
#include "runtime/command_stream/aub_stream_provider.h"
|
||||
#include "runtime/command_stream/aub_subcapture.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/debug_helpers.h"
|
||||
@@ -46,7 +47,10 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const std::str
|
||||
auto aubCenter = executionEnvironment.aubCenter.get();
|
||||
UNRECOVERABLE_IF(nullptr == aubCenter);
|
||||
|
||||
subCaptureManager = aubCenter->getSubCaptureManager();
|
||||
auto subCaptureCommon = aubCenter->getSubCaptureCommon();
|
||||
UNRECOVERABLE_IF(nullptr == subCaptureCommon);
|
||||
subCaptureManager = std::make_unique<AubSubCaptureManager>(fileName, *subCaptureCommon);
|
||||
|
||||
aubManager = aubCenter->getAubManager();
|
||||
|
||||
if (!aubCenter->getPhysicalAddressAllocator()) {
|
||||
@@ -758,9 +762,9 @@ void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void AUBCommandStreamReceiverHw<GfxFamily>::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {
|
||||
bool active = subCaptureManager->activateSubCapture(dispatchInfo);
|
||||
if (active) {
|
||||
AubSubCaptureStatus AUBCommandStreamReceiverHw<GfxFamily>::checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {
|
||||
auto status = subCaptureManager->checkAndActivateSubCapture(dispatchInfo);
|
||||
if (status.isActive) {
|
||||
std::string subCaptureFile = subCaptureManager->getSubCaptureFileName(dispatchInfo);
|
||||
auto isReopened = reopenFile(subCaptureFile);
|
||||
if (isReopened) {
|
||||
@@ -768,13 +772,9 @@ void AUBCommandStreamReceiverHw<GfxFamily>::activateAubSubCapture(const MultiDis
|
||||
}
|
||||
}
|
||||
if (this->standalone) {
|
||||
if (DebugManager.flags.ForceCsrFlushing.get()) {
|
||||
this->flushBatchedSubmissions();
|
||||
}
|
||||
if (DebugManager.flags.ForceCsrReprogramming.get()) {
|
||||
this->initProgrammingFlags();
|
||||
}
|
||||
this->programForAubSubCapture(status.wasActiveInPreviousEnqueue, status.isActive);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
AubSubCaptureManager::AubSubCaptureManager(const std::string &fileName)
|
||||
: initialFileName(fileName) {
|
||||
AubSubCaptureManager::AubSubCaptureManager(const std::string &fileName, AubSubCaptureCommon &subCaptureCommon)
|
||||
: initialFileName(fileName), subCaptureCommon(subCaptureCommon) {
|
||||
settingsReader.reset(SettingsReader::createOsReader(true));
|
||||
}
|
||||
|
||||
@@ -23,26 +23,28 @@ AubSubCaptureManager::~AubSubCaptureManager() = default;
|
||||
bool AubSubCaptureManager::isSubCaptureEnabled() const {
|
||||
auto guard = this->lock();
|
||||
|
||||
return subCaptureIsActive || subCaptureWasActive;
|
||||
return subCaptureIsActive || subCaptureWasActiveInPreviousEnqueue;
|
||||
}
|
||||
|
||||
void AubSubCaptureManager::disableSubCapture() {
|
||||
auto guard = this->lock();
|
||||
|
||||
subCaptureIsActive = subCaptureWasActive = false;
|
||||
subCaptureIsActive = subCaptureWasActiveInPreviousEnqueue = false;
|
||||
};
|
||||
|
||||
bool AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchInfo) {
|
||||
AubSubCaptureStatus AubSubCaptureManager::checkAndActivateSubCapture(const MultiDispatchInfo &dispatchInfo) {
|
||||
if (dispatchInfo.empty()) {
|
||||
return false;
|
||||
return {false, false};
|
||||
}
|
||||
|
||||
auto guard = this->lock();
|
||||
|
||||
subCaptureWasActive = subCaptureIsActive;
|
||||
kernelCurrentIdx = subCaptureCommon.getKernelCurrentIndexAndIncrement();
|
||||
|
||||
subCaptureWasActiveInPreviousEnqueue = subCaptureIsActive;
|
||||
subCaptureIsActive = false;
|
||||
|
||||
switch (subCaptureMode) {
|
||||
switch (subCaptureCommon.subCaptureMode) {
|
||||
case SubCaptureMode::Toggle:
|
||||
subCaptureIsActive = isSubCaptureToggleActive();
|
||||
break;
|
||||
@@ -54,10 +56,7 @@ bool AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchI
|
||||
break;
|
||||
}
|
||||
|
||||
kernelCurrentIdx++;
|
||||
setDebugManagerFlags();
|
||||
|
||||
return subCaptureIsActive;
|
||||
return {subCaptureIsActive, subCaptureWasActiveInPreviousEnqueue};
|
||||
}
|
||||
|
||||
const std::string &AubSubCaptureManager::getSubCaptureFileName(const MultiDispatchInfo &dispatchInfo) {
|
||||
@@ -66,7 +65,7 @@ const std::string &AubSubCaptureManager::getSubCaptureFileName(const MultiDispat
|
||||
if (useExternalFileName) {
|
||||
currentFileName = getExternalFileName();
|
||||
}
|
||||
switch (subCaptureMode) {
|
||||
switch (subCaptureCommon.subCaptureMode) {
|
||||
case SubCaptureMode::Filter:
|
||||
if (currentFileName.empty()) {
|
||||
currentFileName = generateFilterFileName();
|
||||
@@ -102,12 +101,12 @@ std::string AubSubCaptureManager::getExternalFileName() const {
|
||||
std::string AubSubCaptureManager::generateFilterFileName() const {
|
||||
std::string baseFileName = initialFileName.substr(0, initialFileName.length() - strlen(".aub"));
|
||||
std::string filterFileName = baseFileName + "_filter";
|
||||
filterFileName += "_from_" + std::to_string(subCaptureFilter.dumpKernelStartIdx);
|
||||
filterFileName += "_to_" + std::to_string(subCaptureFilter.dumpKernelEndIdx);
|
||||
if (!subCaptureFilter.dumpKernelName.empty()) {
|
||||
filterFileName += "_" + subCaptureFilter.dumpKernelName;
|
||||
filterFileName += "_from_" + std::to_string(subCaptureFilter.dumpNamedKernelStartIdx);
|
||||
filterFileName += "_to_" + std::to_string(subCaptureFilter.dumpNamedKernelEndIdx);
|
||||
filterFileName += "_from_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpKernelStartIdx);
|
||||
filterFileName += "_to_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpKernelEndIdx);
|
||||
if (!subCaptureCommon.subCaptureFilter.dumpKernelName.empty()) {
|
||||
filterFileName += "_" + subCaptureCommon.subCaptureFilter.dumpKernelName;
|
||||
filterFileName += "_from_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpNamedKernelStartIdx);
|
||||
filterFileName += "_to_" + std::to_string(subCaptureCommon.subCaptureFilter.dumpNamedKernelEndIdx);
|
||||
}
|
||||
filterFileName += ".aub";
|
||||
return filterFileName;
|
||||
@@ -116,7 +115,7 @@ std::string AubSubCaptureManager::generateFilterFileName() const {
|
||||
std::string AubSubCaptureManager::generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const {
|
||||
std::string baseFileName = initialFileName.substr(0, initialFileName.length() - strlen(".aub"));
|
||||
std::string toggleFileName = baseFileName + "_toggle";
|
||||
toggleFileName += "_from_" + std::to_string(kernelCurrentIdx - 1);
|
||||
toggleFileName += "_from_" + std::to_string(kernelCurrentIdx);
|
||||
if (!dispatchInfo.empty()) {
|
||||
toggleFileName += "_" + dispatchInfo.peekMainKernel()->getKernelInfo().name;
|
||||
}
|
||||
@@ -128,35 +127,21 @@ bool AubSubCaptureManager::isSubCaptureFilterActive(const MultiDispatchInfo &dis
|
||||
auto kernelName = dispatchInfo.peekMainKernel()->getKernelInfo().name;
|
||||
auto subCaptureIsActive = false;
|
||||
|
||||
if (subCaptureFilter.dumpKernelName.empty()) {
|
||||
if (isKernelIndexInSubCaptureRange(kernelCurrentIdx, subCaptureFilter.dumpKernelStartIdx, subCaptureFilter.dumpKernelEndIdx)) {
|
||||
if (subCaptureCommon.subCaptureFilter.dumpKernelName.empty()) {
|
||||
if (isKernelIndexInSubCaptureRange(kernelCurrentIdx, subCaptureCommon.subCaptureFilter.dumpKernelStartIdx, subCaptureCommon.subCaptureFilter.dumpKernelEndIdx)) {
|
||||
subCaptureIsActive = true;
|
||||
}
|
||||
} else {
|
||||
if (0 == kernelName.compare(subCaptureFilter.dumpKernelName)) {
|
||||
if (isKernelIndexInSubCaptureRange(kernelNameMatchesNum, subCaptureFilter.dumpNamedKernelStartIdx, subCaptureFilter.dumpNamedKernelEndIdx)) {
|
||||
if (0 == kernelName.compare(subCaptureCommon.subCaptureFilter.dumpKernelName)) {
|
||||
kernelNameMatchesNum = subCaptureCommon.getKernelNameMatchesNumAndIncrement();
|
||||
if (isKernelIndexInSubCaptureRange(kernelNameMatchesNum, subCaptureCommon.subCaptureFilter.dumpNamedKernelStartIdx, subCaptureCommon.subCaptureFilter.dumpNamedKernelEndIdx)) {
|
||||
subCaptureIsActive = true;
|
||||
}
|
||||
kernelNameMatchesNum++;
|
||||
}
|
||||
}
|
||||
return subCaptureIsActive;
|
||||
}
|
||||
|
||||
void AubSubCaptureManager::setDebugManagerFlags() const {
|
||||
DebugManager.flags.MakeEachEnqueueBlocking.set(!subCaptureIsActive);
|
||||
DebugManager.flags.ForceCsrFlushing.set(false);
|
||||
if (!subCaptureIsActive && subCaptureWasActive) {
|
||||
DebugManager.flags.ForceCsrFlushing.set(true);
|
||||
}
|
||||
DebugManager.flags.ForceCsrReprogramming.set(false);
|
||||
DebugManager.flags.OmitTimestampPacketDependencies.set(false);
|
||||
if (subCaptureIsActive && !subCaptureWasActive) {
|
||||
DebugManager.flags.ForceCsrReprogramming.set(true);
|
||||
DebugManager.flags.OmitTimestampPacketDependencies.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> AubSubCaptureManager::lock() const {
|
||||
return std::unique_lock<std::mutex>{mutex};
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@@ -15,7 +16,12 @@ namespace NEO {
|
||||
struct MultiDispatchInfo;
|
||||
class SettingsReader;
|
||||
|
||||
class AubSubCaptureManager {
|
||||
struct AubSubCaptureStatus {
|
||||
bool isActive;
|
||||
bool wasActiveInPreviousEnqueue;
|
||||
};
|
||||
|
||||
class AubSubCaptureCommon {
|
||||
public:
|
||||
enum class SubCaptureMode {
|
||||
Off = 0, //subcapture off
|
||||
@@ -31,19 +37,32 @@ class AubSubCaptureManager {
|
||||
uint32_t dumpKernelEndIdx = static_cast<uint32_t>(-1);
|
||||
} subCaptureFilter;
|
||||
|
||||
inline uint32_t getKernelCurrentIndexAndIncrement() { return kernelCurrentIdx.fetch_add(1); }
|
||||
inline uint32_t getKernelNameMatchesNumAndIncrement() { return kernelNameMatchesNum.fetch_add(1); }
|
||||
|
||||
protected:
|
||||
std::atomic<uint32_t> kernelCurrentIdx{0};
|
||||
std::atomic<uint32_t> kernelNameMatchesNum{0};
|
||||
};
|
||||
|
||||
class AubSubCaptureManager {
|
||||
public:
|
||||
using SubCaptureMode = AubSubCaptureCommon::SubCaptureMode;
|
||||
using SubCaptureFilter = AubSubCaptureCommon::SubCaptureFilter;
|
||||
|
||||
inline bool isSubCaptureMode() const {
|
||||
return subCaptureMode > SubCaptureMode::Off;
|
||||
return subCaptureCommon.subCaptureMode > SubCaptureMode::Off;
|
||||
}
|
||||
|
||||
bool isSubCaptureEnabled() const;
|
||||
|
||||
void disableSubCapture();
|
||||
|
||||
bool activateSubCapture(const MultiDispatchInfo &dispatchInfo);
|
||||
AubSubCaptureStatus checkAndActivateSubCapture(const MultiDispatchInfo &dispatchInfo);
|
||||
|
||||
const std::string &getSubCaptureFileName(const MultiDispatchInfo &dispatchInfo);
|
||||
|
||||
AubSubCaptureManager(const std::string &fileName);
|
||||
AubSubCaptureManager(const std::string &fileName, AubSubCaptureCommon &subCaptureCommon);
|
||||
virtual ~AubSubCaptureManager();
|
||||
|
||||
protected:
|
||||
@@ -53,17 +72,17 @@ class AubSubCaptureManager {
|
||||
MOCKABLE_VIRTUAL std::string generateFilterFileName() const;
|
||||
MOCKABLE_VIRTUAL std::string generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const;
|
||||
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx, uint32_t rangeStartIdx, uint32_t rangeEndIdx) const;
|
||||
void setDebugManagerFlags() const;
|
||||
MOCKABLE_VIRTUAL std::unique_lock<std::mutex> lock() const;
|
||||
|
||||
bool subCaptureIsActive = false;
|
||||
bool subCaptureWasActive = false;
|
||||
bool subCaptureWasActiveInPreviousEnqueue = false;
|
||||
uint32_t kernelCurrentIdx = 0;
|
||||
uint32_t kernelNameMatchesNum = 0;
|
||||
bool useExternalFileName = true;
|
||||
std::string initialFileName;
|
||||
std::string currentFileName;
|
||||
std::unique_ptr<SettingsReader> settingsReader;
|
||||
AubSubCaptureCommon &subCaptureCommon;
|
||||
mutable std::mutex mutex;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -237,6 +237,17 @@ void CommandStreamReceiver::initProgrammingFlags() {
|
||||
latestSentStatelessMocsConfig = 0;
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::programForAubSubCapture(bool wasActiveInPreviousEnqueue, bool isActive) {
|
||||
if (!wasActiveInPreviousEnqueue && isActive) {
|
||||
// force CSR reprogramming upon subcapture activation
|
||||
this->initProgrammingFlags();
|
||||
}
|
||||
if (wasActiveInPreviousEnqueue && !isActive) {
|
||||
// flush BB upon subcapture deactivation
|
||||
this->flushBatchedSubmissions();
|
||||
}
|
||||
}
|
||||
|
||||
ResidencyContainer &CommandStreamReceiver::getResidencyAllocations() {
|
||||
return this->residencyAllocations;
|
||||
}
|
||||
@@ -245,7 +256,7 @@ ResidencyContainer &CommandStreamReceiver::getEvictionAllocations() {
|
||||
return this->evictionAllocations;
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {}
|
||||
AubSubCaptureStatus CommandStreamReceiver::checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo) { return {false, false}; }
|
||||
|
||||
void CommandStreamReceiver::addAubComment(const char *comment) {}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/command_stream/aub_subcapture.h"
|
||||
#include "runtime/command_stream/csr_definitions.h"
|
||||
#include "runtime/command_stream/linear_stream.h"
|
||||
#include "runtime/command_stream/submissions_aggregator.h"
|
||||
@@ -133,7 +134,8 @@ class CommandStreamReceiver {
|
||||
void overwriteFlatBatchBufferHelper(FlatBatchBufferHelper *newHelper) { flatBatchBufferHelper.reset(newHelper); }
|
||||
|
||||
MOCKABLE_VIRTUAL void initProgrammingFlags();
|
||||
virtual void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo);
|
||||
virtual AubSubCaptureStatus checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo);
|
||||
void programForAubSubCapture(bool wasActiveInPreviousEnqueue, bool isActive);
|
||||
virtual void addAubComment(const char *comment);
|
||||
|
||||
IndirectHeap &getIndirectHeap(IndirectHeap::Type heapType, size_t minRequiredSize);
|
||||
|
||||
@@ -26,7 +26,7 @@ class CommandStreamReceiverWithAUBDump : public BaseCSR {
|
||||
FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
||||
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
||||
AubSubCaptureStatus checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
||||
void setupContext(OsContext &osContext) override;
|
||||
|
||||
std::unique_ptr<CommandStreamReceiver> aubCSR;
|
||||
|
||||
@@ -46,11 +46,13 @@ void CommandStreamReceiverWithAUBDump<BaseCSR>::makeNonResident(GraphicsAllocati
|
||||
}
|
||||
|
||||
template <typename BaseCSR>
|
||||
void CommandStreamReceiverWithAUBDump<BaseCSR>::activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {
|
||||
BaseCSR::activateAubSubCapture(dispatchInfo);
|
||||
AubSubCaptureStatus CommandStreamReceiverWithAUBDump<BaseCSR>::checkAndActivateAubSubCapture(const MultiDispatchInfo &dispatchInfo) {
|
||||
auto status = BaseCSR::checkAndActivateAubSubCapture(dispatchInfo);
|
||||
if (aubCSR) {
|
||||
aubCSR->activateAubSubCapture(dispatchInfo);
|
||||
status = aubCSR->checkAndActivateAubSubCapture(dispatchInfo);
|
||||
}
|
||||
BaseCSR::programForAubSubCapture(status.wasActiveInPreviousEnqueue, status.isActive);
|
||||
return status;
|
||||
}
|
||||
|
||||
template <typename BaseCSR>
|
||||
|
||||
Reference in New Issue
Block a user