AUB subcapture in filter mode to define start/end indexes to a given kernel

This commit introduces new controls to define start/end indexes
that apply only to the kernel specified by name for a sub-capture

Change-Id: I7ad7674d115f9addd35c44d824aee0731060881e
This commit is contained in:
Milczarek, Slawomir
2018-07-26 11:35:13 +02:00
parent ce8284bade
commit a7d41d95b4
6 changed files with 81 additions and 12 deletions

View File

@@ -53,6 +53,8 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const Hardware
this->subCaptureManager->subCaptureMode = static_cast<AubSubCaptureManager::SubCaptureMode>(DebugManager.flags.AUBDumpSubCaptureMode.get());
this->subCaptureManager->subCaptureFilter.dumpKernelStartIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelStartIdx.get());
this->subCaptureManager->subCaptureFilter.dumpKernelEndIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelEndIdx.get());
this->subCaptureManager->subCaptureFilter.dumpNamedKernelStartIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterNamedKernelStartIdx.get());
this->subCaptureManager->subCaptureFilter.dumpNamedKernelEndIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterNamedKernelEndIdx.get());
if (DebugManager.flags.AUBDumpFilterKernelName.get() != "unk") {
this->subCaptureManager->subCaptureFilter.dumpKernelName = DebugManager.flags.AUBDumpFilterKernelName.get();
}

View File

@@ -47,7 +47,7 @@ bool AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchI
subCaptureIsActive = isSubCaptureToggleActive();
break;
case SubCaptureMode::Filter:
subCaptureIsActive = isSubCaptureFilterActive(dispatchInfo, kernelCurrentIdx);
subCaptureIsActive = isSubCaptureFilterActive(dispatchInfo);
break;
default:
DEBUG_BREAK_IF(false);
@@ -85,9 +85,8 @@ const std::string &AubSubCaptureManager::getSubCaptureFileName(const MultiDispat
return currentFileName;
}
bool AubSubCaptureManager::isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const {
return ((subCaptureFilter.dumpKernelStartIdx <= kernelIdx) &&
(kernelIdx <= subCaptureFilter.dumpKernelEndIdx));
bool AubSubCaptureManager::isKernelIndexInSubCaptureRange(uint32_t kernelIdx, uint32_t rangeStartIdx, uint32_t rangeEndIdx) const {
return ((rangeStartIdx <= kernelIdx) && (kernelIdx <= rangeEndIdx));
}
bool AubSubCaptureManager::isSubCaptureToggleActive() const {
@@ -105,6 +104,8 @@ std::string AubSubCaptureManager::generateFilterFileName() const {
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 += ".aub";
return filterFileName;
@@ -121,18 +122,20 @@ std::string AubSubCaptureManager::generateToggleFileName(const MultiDispatchInfo
return toggleFileName;
}
bool AubSubCaptureManager::isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const {
DEBUG_BREAK_IF(dispatchInfo.size() > 1);
bool AubSubCaptureManager::isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo) {
auto kernelName = dispatchInfo.peekMainKernel()->getKernelInfo().name;
auto subCaptureIsActive = false;
if (isKernelIndexInSubCaptureRange(kernelIdx)) {
if (subCaptureFilter.dumpKernelName.empty()) {
if (subCaptureFilter.dumpKernelName.empty()) {
if (isKernelIndexInSubCaptureRange(kernelCurrentIdx, subCaptureFilter.dumpKernelStartIdx, subCaptureFilter.dumpKernelEndIdx)) {
subCaptureIsActive = true;
} else {
if (0 == kernelName.compare(subCaptureFilter.dumpKernelName)) {
}
} else {
if (0 == kernelName.compare(subCaptureFilter.dumpKernelName)) {
if (isKernelIndexInSubCaptureRange(kernelNameMatchesNum, subCaptureFilter.dumpNamedKernelStartIdx, subCaptureFilter.dumpNamedKernelEndIdx)) {
subCaptureIsActive = true;
}
kernelNameMatchesNum++;
}
}
return subCaptureIsActive;

View File

@@ -38,6 +38,8 @@ class AubSubCaptureManager {
struct SubCaptureFilter {
std::string dumpKernelName = "";
uint32_t dumpNamedKernelStartIdx = 0;
uint32_t dumpNamedKernelEndIdx = static_cast<uint32_t>(-1);
uint32_t dumpKernelStartIdx = 0;
uint32_t dumpKernelEndIdx = static_cast<uint32_t>(-1);
} subCaptureFilter;
@@ -62,16 +64,17 @@ class AubSubCaptureManager {
protected:
MOCKABLE_VIRTUAL bool isSubCaptureToggleActive() const;
bool isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const;
bool isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo);
MOCKABLE_VIRTUAL std::string getExternalFileName() const;
MOCKABLE_VIRTUAL std::string generateFilterFileName() const;
MOCKABLE_VIRTUAL std::string generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const;
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const;
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx, uint32_t rangeStartIdx, uint32_t rangeEndIdx) const;
void setDebugManagerFlags() const;
bool subCaptureIsActive = false;
bool subCaptureWasActive = false;
uint32_t kernelCurrentIdx = 0;
uint32_t kernelNameMatchesNum = 0;
bool useExternalFileName = true;
std::string initialFileName;
std::string currentFileName;

View File

@@ -25,6 +25,8 @@ DECLARE_DEBUG_VARIABLE(std::string, ProductFamilyOverride, std::string("unk"), "
DECLARE_DEBUG_VARIABLE(std::string, ForceCompilerUsePlatform, std::string("unk"), "Specify product for use in compiler interface")
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpCaptureFileName, std::string("unk"), "Name of file to save AUB capture into")
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpFilterKernelName, std::string("unk"), "Name of kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterNamedKernelStartIdx, 0, "Start index of named kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterNamedKernelEndIdx, -1, "End index of named kernel to AUB capture")
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpToggleFileName, std::string("unk"), "Name of file to save AUB in toggle mode")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpSubCaptureMode, 0, "AUB dump subcapture mode (off, toggle, filter)")
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelStartIdx, 0, "Start index of kernel to AUB capture")

View File

@@ -459,6 +459,15 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFil
EXPECT_EQ(1u, aubSubCaptureManager.generateToggleFileNameCount);
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledThenItGeneratesFileNameWithStartAndEndIndexes) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 123;
aubSubCaptureManager.subCaptureFilter.dumpKernelEndIdx = 456;
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
EXPECT_NE(std::string::npos, filterFileName.find("from_123_to_456"));
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledAndKernelNameIsSpecifiedInFilterThenItGeneratesFileNameWithNameOfKernel) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
std::string kernelName = "kernel_name";
@@ -468,6 +477,26 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFi
EXPECT_NE(std::string::npos, filterFileName.find(kernelName));
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledAndKernelNameIsSpecifiedInFilterThenItGeneratesFileNameWithStartAndEndIndexesOfKernel) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
std::string kernelName = "kernel_name";
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelStartIdx = 12;
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelEndIdx = 17;
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
EXPECT_NE(std::string::npos, filterFileName.find("from_12_to_17"));
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGenerateToggleFileNameIsCalledThenItGeneratesFileNameWithKernelCurrentIndex) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
std::string kernelCurrentIndex = "from_" + std::to_string(aubSubCaptureManager.getKernelCurrentIndex() - 1);
MultiDispatchInfo dispatchInfo;
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
std::string filterFileName = aubSubCaptureManager.generateToggleFileName(dispatchInfo);
EXPECT_NE(std::string::npos, filterFileName.find(kernelCurrentIndex));
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGenerateToggleFileNameIsCalledAndDispatchInfoIsEmptyThenItGeneratesFileNameWithoutNameOfKernel) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
std::string kernelName = "kernel_name";
@@ -504,3 +533,31 @@ TEST_F(AubSubCaptureTest, givenMultiDispatchInfoWithMultipleKernelsWhenGenerateT
EXPECT_NE(std::string::npos, toggleFileName.find(mainKernelInfo.name));
EXPECT_STREQ(toggleFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
}
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenKernelNameIsSpecifiedThenNamedKernelIndexesShouldApplyToTheSpecifiedKernel) {
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
std::string kernelName = "kernel_name";
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelStartIdx = 1;
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelEndIdx = 1;
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
DispatchInfo dispatchInfo;
MockKernel kernel(program.get(), kernelInfo, *pDevice);
dispatchInfo.setKernel(&kernel);
MultiDispatchInfo multiDispatchInfo;
multiDispatchInfo.push(dispatchInfo);
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
EXPECT_TRUE(active);
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
EXPECT_FALSE(active);
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
}

View File

@@ -74,6 +74,8 @@ AUBDumpSubCaptureMode = 0
AUBDumpToggleFileName = unk
AUBDumpToggleCaptureOnOff = 0
AUBDumpFilterKernelName = unk
AUBDumpFilterNamedKernelStartIdx = 0
AUBDumpFilterNamedKernelEndIdx = -1
AUBDumpFilterKernelStartIdx = 0
AUBDumpFilterKernelEndIdx = -1
RebuildPrecompiledKernels = false