SWDEV-443567 - SWDEV-436126 - Fix Prohibited and Unhandled Operations during capture

=> hipDeviceSynchronize is not allowed during capture.
=> hipEventSynchronize during capture should return hipErrorCapturedEvent error
=> hipEventQuery during capture should return hipErrorCapturedEvent error
hipStreamSynchronize, hipEventSynchronize, hipStreamWaitEvent, hipStreamQuery
For Side Stream(Stream that is not currently under capture):
=> If current thread is capturing in relaxed mode, calls are allowed
=> If any stream in current/concurrent thread is capturing in global mode, calls are not allowed
=> If any stream in current thread is capturing in ThreadLocal mode, calls are not allowed
For Stream that is currently under capture
=> calls are not allowed
=> Any call that is not allowed during capture invalidates the capture sequence
=> It is invalid to call synchronous APIs during capture. Synchronous APIs,
such as hipMemcpy(), enqueue work to the legacy stream and synchronize it before returning.

Change-Id: I201c6e63e1a5d93fd416a3b520264c0fdbe31237
Dieser Commit ist enthalten in:
Anusha GodavarthySurya
2024-01-25 10:32:08 +00:00
committet von Anusha Godavarthy Surya
Ursprung 2f3ad43c4a
Commit 19b4660cbb
5 geänderte Dateien mit 72 neuen und 24 gelöschten Zeilen
+7 -5
Datei anzeigen
@@ -961,7 +961,7 @@ hipError_t hipStreamEndCapture_common(hipStream_t stream, hip::Graph** pGraph) {
if (s->GetCaptureStatus() == hipStreamCaptureStatusNone) {
return hipErrorIllegalState;
}
// Capture must be ended on the same stream in which it was initiated
// Capture must be ended on the same stream in which it was initiated
if (!s->IsOriginStream()) {
return hipErrorStreamCaptureUnmatched;
}
@@ -978,15 +978,17 @@ hipError_t hipStreamEndCapture_common(hipStream_t stream, hip::Graph** pGraph) {
amd::ScopedLock lock(g_captureStreamsLock);
g_captureStreams.erase(std::find(g_captureStreams.begin(), g_captureStreams.end(), s));
}
{
amd::ScopedLock lock(g_streamSetLock);
g_allCapturingStreams.erase(
std::find(g_allCapturingStreams.begin(), g_allCapturingStreams.end(), s));
}
// If capture was invalidated, due to a violation of the rules of stream capture
if (s->GetCaptureStatus() == hipStreamCaptureStatusInvalidated) {
*pGraph = nullptr;
return hipErrorStreamCaptureInvalidated;
}
{
amd::ScopedLock lock(g_streamSetLock);
g_allCapturingStreams.erase(std::find(g_allCapturingStreams.begin(), g_allCapturingStreams.end(), s));
}
// check if all parallel streams have joined
// Nodes that are removed from the dependency set via API hipStreamUpdateCaptureDependencies do
// not result in hipErrorStreamCaptureUnjoined