mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Improve GPU breakpoint support
handle user confirmations in gpu modes: always, only before, only after handle multiple confirmations when pausing on each enqueue Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
7b7ad9a5cb
commit
a6d898a026
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 Intel Corporation
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -1175,6 +1175,180 @@ HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadWhenSettingFlagProgress
|
||||
EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue")));
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadBeforeWalkerOnlyWhenSettingFlagProgressThenFunctionAsksOnceForConfirmation) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PauseOnEnqueue.set(0);
|
||||
DebugManager.flags.PauseOnGpuMode.set(0);
|
||||
testing::internal::CaptureStdout();
|
||||
int32_t executionStamp = 0;
|
||||
auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
|
||||
uint32_t confirmationCounter = 0;
|
||||
|
||||
mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() {
|
||||
EXPECT_EQ(0u, confirmationCounter);
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
};
|
||||
|
||||
pDevice->resetCommandStreamReceiver(mockCSR);
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation;
|
||||
|
||||
EXPECT_EQ(1u, confirmationCounter);
|
||||
|
||||
auto output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Press enter to start workload")));
|
||||
EXPECT_THAT(output, testing::Not(testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue"))));
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadAfterWalkerOnlyWhenSettingFlagProgressThenFunctionAsksOnceForConfirmation) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PauseOnEnqueue.set(0);
|
||||
DebugManager.flags.PauseOnGpuMode.set(1);
|
||||
testing::internal::CaptureStdout();
|
||||
int32_t executionStamp = 0;
|
||||
auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
|
||||
uint32_t confirmationCounter = 0;
|
||||
|
||||
mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() {
|
||||
EXPECT_EQ(0u, confirmationCounter);
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
};
|
||||
|
||||
pDevice->resetCommandStreamReceiver(mockCSR);
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation;
|
||||
|
||||
EXPECT_EQ(1u, confirmationCounter);
|
||||
|
||||
auto output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, testing::Not(testing::HasSubstr(std::string("Debug break: Press enter to start workload"))));
|
||||
EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue")));
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadOnEachEnqueueWhenSettingFlagProgressThenFunctionAsksMultipleTimesForConfirmation) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PauseOnEnqueue.set(-2);
|
||||
testing::internal::CaptureStdout();
|
||||
int32_t executionStamp = 0;
|
||||
auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
|
||||
uint32_t confirmationCounter = 0;
|
||||
|
||||
mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() {
|
||||
if (confirmationCounter == 0) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
} else if (confirmationCounter == 1) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
} else if (confirmationCounter == 2) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
} else if (confirmationCounter == 3) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
DebugManager.flags.PauseOnEnqueue.set(-1);
|
||||
}
|
||||
};
|
||||
|
||||
pDevice->resetCommandStreamReceiver(mockCSR);
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation)
|
||||
;
|
||||
|
||||
EXPECT_EQ(4u, confirmationCounter);
|
||||
|
||||
auto output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Press enter to start workload")));
|
||||
EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue")));
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadOnEachBlitWhenSettingFlagProgressThenFunctionAsksMultipleTimesForConfirmation) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PauseOnBlitCopy.set(-2);
|
||||
testing::internal::CaptureStdout();
|
||||
int32_t executionStamp = 0;
|
||||
auto mockCSR = new MockCsr<FamilyType>(executionStamp, *pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield());
|
||||
|
||||
uint32_t confirmationCounter = 0;
|
||||
|
||||
mockCSR->debugConfirmationFunction = [&confirmationCounter, &mockCSR]() {
|
||||
if (confirmationCounter == 0) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
} else if (confirmationCounter == 1) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
} else if (confirmationCounter == 2) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserStartConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
} else if (confirmationCounter == 3) {
|
||||
EXPECT_TRUE(DebugPauseState::waitingForUserEndConfirmation == *mockCSR->debugPauseStateAddress);
|
||||
confirmationCounter++;
|
||||
DebugManager.flags.PauseOnBlitCopy.set(-1);
|
||||
}
|
||||
};
|
||||
|
||||
pDevice->resetCommandStreamReceiver(mockCSR);
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserStartConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserStartConfirmation)
|
||||
;
|
||||
|
||||
*mockCSR->debugPauseStateAddress = DebugPauseState::waitingForUserEndConfirmation;
|
||||
|
||||
while (*mockCSR->debugPauseStateAddress != DebugPauseState::hasUserEndConfirmation)
|
||||
;
|
||||
|
||||
EXPECT_EQ(4u, confirmationCounter);
|
||||
|
||||
auto output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Press enter to start workload")));
|
||||
EXPECT_THAT(output, testing::HasSubstr(std::string("Debug break: Workload ended, press enter to continue")));
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenDebugPauseThreadWhenTerminatingAtFirstStageThenFunctionEndsCorrectly) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.PauseOnEnqueue.set(0);
|
||||
|
Reference in New Issue
Block a user