Skip to content

Commit a7d41d9

Browse files
committed
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
1 parent ce8284b commit a7d41d9

File tree

6 files changed

+81
-12
lines changed

6 files changed

+81
-12
lines changed

runtime/command_stream/aub_command_stream_receiver_hw.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const Hardware
5353
this->subCaptureManager->subCaptureMode = static_cast<AubSubCaptureManager::SubCaptureMode>(DebugManager.flags.AUBDumpSubCaptureMode.get());
5454
this->subCaptureManager->subCaptureFilter.dumpKernelStartIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelStartIdx.get());
5555
this->subCaptureManager->subCaptureFilter.dumpKernelEndIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterKernelEndIdx.get());
56+
this->subCaptureManager->subCaptureFilter.dumpNamedKernelStartIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterNamedKernelStartIdx.get());
57+
this->subCaptureManager->subCaptureFilter.dumpNamedKernelEndIdx = static_cast<uint32_t>(DebugManager.flags.AUBDumpFilterNamedKernelEndIdx.get());
5658
if (DebugManager.flags.AUBDumpFilterKernelName.get() != "unk") {
5759
this->subCaptureManager->subCaptureFilter.dumpKernelName = DebugManager.flags.AUBDumpFilterKernelName.get();
5860
}

runtime/command_stream/aub_subcapture.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool AubSubCaptureManager::activateSubCapture(const MultiDispatchInfo &dispatchI
4747
subCaptureIsActive = isSubCaptureToggleActive();
4848
break;
4949
case SubCaptureMode::Filter:
50-
subCaptureIsActive = isSubCaptureFilterActive(dispatchInfo, kernelCurrentIdx);
50+
subCaptureIsActive = isSubCaptureFilterActive(dispatchInfo);
5151
break;
5252
default:
5353
DEBUG_BREAK_IF(false);
@@ -85,9 +85,8 @@ const std::string &AubSubCaptureManager::getSubCaptureFileName(const MultiDispat
8585
return currentFileName;
8686
}
8787

88-
bool AubSubCaptureManager::isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const {
89-
return ((subCaptureFilter.dumpKernelStartIdx <= kernelIdx) &&
90-
(kernelIdx <= subCaptureFilter.dumpKernelEndIdx));
88+
bool AubSubCaptureManager::isKernelIndexInSubCaptureRange(uint32_t kernelIdx, uint32_t rangeStartIdx, uint32_t rangeEndIdx) const {
89+
return ((rangeStartIdx <= kernelIdx) && (kernelIdx <= rangeEndIdx));
9190
}
9291

9392
bool AubSubCaptureManager::isSubCaptureToggleActive() const {
@@ -105,6 +104,8 @@ std::string AubSubCaptureManager::generateFilterFileName() const {
105104
filterFileName += "_to_" + std::to_string(subCaptureFilter.dumpKernelEndIdx);
106105
if (!subCaptureFilter.dumpKernelName.empty()) {
107106
filterFileName += "_" + subCaptureFilter.dumpKernelName;
107+
filterFileName += "_from_" + std::to_string(subCaptureFilter.dumpNamedKernelStartIdx);
108+
filterFileName += "_to_" + std::to_string(subCaptureFilter.dumpNamedKernelEndIdx);
108109
}
109110
filterFileName += ".aub";
110111
return filterFileName;
@@ -121,18 +122,20 @@ std::string AubSubCaptureManager::generateToggleFileName(const MultiDispatchInfo
121122
return toggleFileName;
122123
}
123124

124-
bool AubSubCaptureManager::isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const {
125-
DEBUG_BREAK_IF(dispatchInfo.size() > 1);
125+
bool AubSubCaptureManager::isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo) {
126126
auto kernelName = dispatchInfo.peekMainKernel()->getKernelInfo().name;
127127
auto subCaptureIsActive = false;
128128

129-
if (isKernelIndexInSubCaptureRange(kernelIdx)) {
130-
if (subCaptureFilter.dumpKernelName.empty()) {
129+
if (subCaptureFilter.dumpKernelName.empty()) {
130+
if (isKernelIndexInSubCaptureRange(kernelCurrentIdx, subCaptureFilter.dumpKernelStartIdx, subCaptureFilter.dumpKernelEndIdx)) {
131131
subCaptureIsActive = true;
132-
} else {
133-
if (0 == kernelName.compare(subCaptureFilter.dumpKernelName)) {
132+
}
133+
} else {
134+
if (0 == kernelName.compare(subCaptureFilter.dumpKernelName)) {
135+
if (isKernelIndexInSubCaptureRange(kernelNameMatchesNum, subCaptureFilter.dumpNamedKernelStartIdx, subCaptureFilter.dumpNamedKernelEndIdx)) {
134136
subCaptureIsActive = true;
135137
}
138+
kernelNameMatchesNum++;
136139
}
137140
}
138141
return subCaptureIsActive;

runtime/command_stream/aub_subcapture.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class AubSubCaptureManager {
3838

3939
struct SubCaptureFilter {
4040
std::string dumpKernelName = "";
41+
uint32_t dumpNamedKernelStartIdx = 0;
42+
uint32_t dumpNamedKernelEndIdx = static_cast<uint32_t>(-1);
4143
uint32_t dumpKernelStartIdx = 0;
4244
uint32_t dumpKernelEndIdx = static_cast<uint32_t>(-1);
4345
} subCaptureFilter;
@@ -62,16 +64,17 @@ class AubSubCaptureManager {
6264

6365
protected:
6466
MOCKABLE_VIRTUAL bool isSubCaptureToggleActive() const;
65-
bool isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo, uint32_t kernelIdx) const;
67+
bool isSubCaptureFilterActive(const MultiDispatchInfo &dispatchInfo);
6668
MOCKABLE_VIRTUAL std::string getExternalFileName() const;
6769
MOCKABLE_VIRTUAL std::string generateFilterFileName() const;
6870
MOCKABLE_VIRTUAL std::string generateToggleFileName(const MultiDispatchInfo &dispatchInfo) const;
69-
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx) const;
71+
bool isKernelIndexInSubCaptureRange(uint32_t kernelIdx, uint32_t rangeStartIdx, uint32_t rangeEndIdx) const;
7072
void setDebugManagerFlags() const;
7173

7274
bool subCaptureIsActive = false;
7375
bool subCaptureWasActive = false;
7476
uint32_t kernelCurrentIdx = 0;
77+
uint32_t kernelNameMatchesNum = 0;
7578
bool useExternalFileName = true;
7679
std::string initialFileName;
7780
std::string currentFileName;

runtime/os_interface/DebugVariables_base.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ DECLARE_DEBUG_VARIABLE(std::string, ProductFamilyOverride, std::string("unk"), "
2525
DECLARE_DEBUG_VARIABLE(std::string, ForceCompilerUsePlatform, std::string("unk"), "Specify product for use in compiler interface")
2626
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpCaptureFileName, std::string("unk"), "Name of file to save AUB capture into")
2727
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpFilterKernelName, std::string("unk"), "Name of kernel to AUB capture")
28+
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterNamedKernelStartIdx, 0, "Start index of named kernel to AUB capture")
29+
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterNamedKernelEndIdx, -1, "End index of named kernel to AUB capture")
2830
DECLARE_DEBUG_VARIABLE(std::string, AUBDumpToggleFileName, std::string("unk"), "Name of file to save AUB in toggle mode")
2931
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpSubCaptureMode, 0, "AUB dump subcapture mode (off, toggle, filter)")
3032
DECLARE_DEBUG_VARIABLE(int32_t, AUBDumpFilterKernelStartIdx, 0, "Start index of kernel to AUB capture")

unit_tests/command_stream/aub_subcapture_tests.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,15 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGetSubCaptureFil
459459
EXPECT_EQ(1u, aubSubCaptureManager.generateToggleFileNameCount);
460460
}
461461

462+
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledThenItGeneratesFileNameWithStartAndEndIndexes) {
463+
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
464+
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
465+
aubSubCaptureManager.subCaptureFilter.dumpKernelStartIdx = 123;
466+
aubSubCaptureManager.subCaptureFilter.dumpKernelEndIdx = 456;
467+
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
468+
EXPECT_NE(std::string::npos, filterFileName.find("from_123_to_456"));
469+
}
470+
462471
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledAndKernelNameIsSpecifiedInFilterThenItGeneratesFileNameWithNameOfKernel) {
463472
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
464473
std::string kernelName = "kernel_name";
@@ -468,6 +477,26 @@ TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFi
468477
EXPECT_NE(std::string::npos, filterFileName.find(kernelName));
469478
}
470479

480+
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenGenerateFilterFileNameIsCalledAndKernelNameIsSpecifiedInFilterThenItGeneratesFileNameWithStartAndEndIndexesOfKernel) {
481+
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
482+
std::string kernelName = "kernel_name";
483+
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
484+
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
485+
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelStartIdx = 12;
486+
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelEndIdx = 17;
487+
std::string filterFileName = aubSubCaptureManager.generateFilterFileName();
488+
EXPECT_NE(std::string::npos, filterFileName.find("from_12_to_17"));
489+
}
490+
491+
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGenerateToggleFileNameIsCalledThenItGeneratesFileNameWithKernelCurrentIndex) {
492+
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
493+
std::string kernelCurrentIndex = "from_" + std::to_string(aubSubCaptureManager.getKernelCurrentIndex() - 1);
494+
MultiDispatchInfo dispatchInfo;
495+
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Toggle;
496+
std::string filterFileName = aubSubCaptureManager.generateToggleFileName(dispatchInfo);
497+
EXPECT_NE(std::string::npos, filterFileName.find(kernelCurrentIndex));
498+
}
499+
471500
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInToggleModeWhenGenerateToggleFileNameIsCalledAndDispatchInfoIsEmptyThenItGeneratesFileNameWithoutNameOfKernel) {
472501
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
473502
std::string kernelName = "kernel_name";
@@ -504,3 +533,31 @@ TEST_F(AubSubCaptureTest, givenMultiDispatchInfoWithMultipleKernelsWhenGenerateT
504533
EXPECT_NE(std::string::npos, toggleFileName.find(mainKernelInfo.name));
505534
EXPECT_STREQ(toggleFileName.c_str(), aubSubCaptureManager.getSubCaptureFileName(multiDispatchInfo).c_str());
506535
}
536+
537+
TEST_F(AubSubCaptureTest, givenSubCaptureManagerInFilterModeWhenKernelNameIsSpecifiedThenNamedKernelIndexesShouldApplyToTheSpecifiedKernel) {
538+
AubSubCaptureManagerMock aubSubCaptureManager("aubfile.aub");
539+
std::string kernelName = "kernel_name";
540+
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
541+
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelStartIdx = 1;
542+
aubSubCaptureManager.subCaptureFilter.dumpNamedKernelEndIdx = 1;
543+
aubSubCaptureManager.subCaptureFilter.dumpKernelName = kernelName;
544+
545+
DispatchInfo dispatchInfo;
546+
MockKernel kernel(program.get(), kernelInfo, *pDevice);
547+
dispatchInfo.setKernel(&kernel);
548+
MultiDispatchInfo multiDispatchInfo;
549+
multiDispatchInfo.push(dispatchInfo);
550+
551+
aubSubCaptureManager.subCaptureMode = AubSubCaptureManager::SubCaptureMode::Filter;
552+
bool active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
553+
EXPECT_FALSE(active);
554+
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
555+
556+
active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
557+
EXPECT_TRUE(active);
558+
EXPECT_TRUE(aubSubCaptureManager.isSubCaptureActive());
559+
560+
active = aubSubCaptureManager.activateSubCapture(multiDispatchInfo);
561+
EXPECT_FALSE(active);
562+
EXPECT_FALSE(aubSubCaptureManager.isSubCaptureActive());
563+
}

unit_tests/test_files/igdrcl.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ AUBDumpSubCaptureMode = 0
7474
AUBDumpToggleFileName = unk
7575
AUBDumpToggleCaptureOnOff = 0
7676
AUBDumpFilterKernelName = unk
77+
AUBDumpFilterNamedKernelStartIdx = 0
78+
AUBDumpFilterNamedKernelEndIdx = -1
7779
AUBDumpFilterKernelStartIdx = 0
7880
AUBDumpFilterKernelEndIdx = -1
7981
RebuildPrecompiledKernels = false

0 commit comments

Comments
 (0)