SWDEV-360031 - check for stream capture finish.

- stream capture should be done before any sync APIs.

Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
Change-Id: I3d65f67ee68777be71f97f48d460ccaefdd4e1af
This commit is contained in:
sdashmiz
2022-10-03 15:13:37 -04:00
committed by Shadi Dashmiz
parent 338307ef2c
commit be966acb0c
5 changed files with 43 additions and 1 deletions
+22 -1
View File
@@ -211,6 +211,10 @@ void Stream::destroyAllStreams(int deviceId) {
}
}
bool Stream::StreamCaptureOngoing(void) {
return (g_allCapturingStreams.empty() == true) ? false : true;
}
};// hip namespace
// ================================================================================================
@@ -442,6 +446,12 @@ hipError_t hipStreamSynchronize_common(hipStream_t stream) {
if (!hip::isValid(stream)) {
HIP_RETURN(hipErrorContextIsDestroyed);
}
if (stream != nullptr) {
// If still capturing return error
if (hip::Stream::StreamCaptureOngoing() == true) {
HIP_RETURN(hipErrorStreamCaptureUnsupported);
}
}
// Wait for the current host queue
hip::getQueue(stream)->finish();
return hipSuccess;
@@ -524,6 +534,12 @@ hipError_t hipStreamWaitEvent_common(hipStream_t stream, hipEvent_t event, unsig
return hipErrorContextIsDestroyed;
}
if (stream != nullptr) {
// If still capturing return error
if (hip::Stream::StreamCaptureOngoing() == true) {
HIP_RETURN(hipErrorStreamCaptureIsolation);
}
}
hip::Event* e = reinterpret_cast<hip::Event*>(event);
return e->streamWait(stream, flags);
}
@@ -546,7 +562,12 @@ hipError_t hipStreamQuery_common(hipStream_t stream) {
if (!hip::isValid(stream)) {
return hipErrorContextIsDestroyed;
}
if (stream != nullptr) {
// If still capturing return error
if (hip::Stream::StreamCaptureOngoing() == true) {
HIP_RETURN(hipErrorStreamCaptureUnsupported);
}
}
amd::HostQueue* hostQueue = hip::getQueue(stream);
amd::Command* command = hostQueue->getLastQueuedCommand(true);