diff --git a/projects/clr/hipamd/src/hip_graph.cpp b/projects/clr/hipamd/src/hip_graph.cpp index 6679c3d506..0e57a6f2ea 100644 --- a/projects/clr/hipamd/src/hip_graph.cpp +++ b/projects/clr/hipamd/src/hip_graph.cpp @@ -747,15 +747,20 @@ hipError_t hipStreamBeginCapture(hipStream_t stream, hipStreamCaptureMode mode) if (!hip::isValid(stream)) { HIP_RETURN(hipErrorInvalidValue); } - hip::Stream* s = reinterpret_cast(stream); // capture cannot be initiated on legacy stream - // It can be initiated if the stream is not already in capture mode - if (stream == nullptr || - mode < hipStreamCaptureModeGlobal || - mode > hipStreamCaptureModeRelaxed || - s->GetCaptureStatus() == hipStreamCaptureStatusActive) { + if (stream == nullptr) { + HIP_RETURN(hipErrorStreamCaptureUnsupported); + } + if (mode < hipStreamCaptureModeGlobal || + mode > hipStreamCaptureModeRelaxed) { HIP_RETURN(hipErrorInvalidValue); } + hip::Stream* s = reinterpret_cast(stream); + // It can be initiated if the stream is not already in capture mode + if (s->GetCaptureStatus() == hipStreamCaptureStatusActive) { + HIP_RETURN(hipErrorIllegalState); + } + s->SetCaptureGraph(new ihipGraph()); s->SetCaptureMode(mode); s->SetOriginStream();