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


[ROCm/clr commit: 19b4660cbb]
This commit is contained in:
Anusha GodavarthySurya
2024-01-25 10:32:08 +00:00
committed by Anusha Godavarthy Surya
parent 4f123e9c10
commit ae296c8fad
5 changed files with 72 additions and 24 deletions
+7 -3
View File
@@ -434,9 +434,8 @@ hipError_t hipEventSynchronize(hipEvent_t event) {
hip::Event* e = reinterpret_cast<hip::Event*>(event);
hip::Stream* s = reinterpret_cast<hip::Stream*>(e->GetCaptureStream());
if ((s != nullptr) && (s->GetCaptureStatus() == hipStreamCaptureStatusActive)) {
if (s->IsEventCaptured(event) == false) {
return HIP_RETURN(hipErrorStreamCaptureUnsupported);
}
s->SetCaptureStatus(hipStreamCaptureStatusInvalidated);
return HIP_RETURN(hipErrorCapturedEvent);
}
if (hip::Stream::StreamCaptureOngoing(e->GetCaptureStream()) == true) {
HIP_RETURN(hipErrorStreamCaptureUnsupported);
@@ -455,6 +454,11 @@ hipError_t ihipEventQuery(hipEvent_t event) {
}
hip::Event* e = reinterpret_cast<hip::Event*>(event);
hip::Stream* s = reinterpret_cast<hip::Stream*>(e->GetCaptureStream());
if ((s != nullptr) && (s->GetCaptureStatus() == hipStreamCaptureStatusActive)) {
s->SetCaptureStatus(hipStreamCaptureStatusInvalidated);
return HIP_RETURN(hipErrorCapturedEvent);
}
return e->query();
}