SWDEV-352197 - Destroy virtual device in thread destructor

Windows kills threads on exit without any notification. However,
runtime can still destroy VirtualGPU object from the host thread with
HostQueue destruction.
This change also forces RGP trace transfer on the last capture without
any delays.

Change-Id: I768e87e99e1d23a021e63c12f36e450817743759


[ROCm/clr commit: ad33a021cb]
This commit is contained in:
German
2023-01-30 13:11:14 -05:00
committed by German Andryeyev
parent 9eeb99a842
commit f857dcc48d
4 changed files with 28 additions and 10 deletions
@@ -278,6 +278,21 @@ void RgpCaptureMgr::PostDispatch(VirtualGPU* gpu) {
// continue until we find the right queue...
} else if (Pal::Result::Success == res) {
trace_.sqtt_disp_count_ = 0;
// Stop the trace and save the result. Currently runtime can't delay upload in HIP,
// because default stream doesn't have explicit destruction and
// OS kills all threads on exit without any notification. That includes PAL RGP threads.
{
if (trace_.status_ == TraceStatus::WaitingForSqtt) {
auto result = EndRGPTrace(gpu);
}
// Check if runtime is waiting for the final trace results
if (trace_.status_ == TraceStatus::WaitingForResults) {
// If results are ready, then finish the trace
if (CheckForTraceResults() == Pal::Result::Success) {
FinishRGPTrace(gpu, false);
}
}
}
} else {
FinishRGPTrace(gpu, true);
}