From 5fa514fea0261b2b722945309fb7410be1761dd8 Mon Sep 17 00:00:00 2001 From: Sourabh Betigeri Date: Tue, 26 Apr 2022 09:32:18 -0700 Subject: [PATCH] SWDEV-329829 - Fixes to return right error codes for respective negative scenarios Change-Id: Icb615a336bb846df1cf2811316d88a0e88381da8 --- hipamd/src/hip_graph.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hipamd/src/hip_graph.cpp b/hipamd/src/hip_graph.cpp index c2378730cf..46c2a10944 100644 --- a/hipamd/src/hip_graph.cpp +++ b/hipamd/src/hip_graph.cpp @@ -776,10 +776,17 @@ hipError_t hipStreamBeginCapture(hipStream_t stream, hipStreamCaptureMode mode) hipError_t hipStreamEndCapture(hipStream_t stream, hipGraph_t* pGraph) { HIP_INIT_API(hipStreamEndCapture, stream, pGraph); - if (pGraph == nullptr || stream == nullptr || !hip::isValid(stream)) { - HIP_RETURN(hipErrorInvalidValue); + if (pGraph == nullptr || stream == nullptr) { + HIP_RETURN(hipErrorIllegalState); + } + if (!hip::isValid(stream)) { + HIP_RETURN(hipErrorContextIsDestroyed); } hip::Stream* s = reinterpret_cast(stream); + // Capture status must be active before endCapture can be initiated + if (s->GetCaptureStatus() == hipStreamCaptureStatusNone) { + HIP_RETURN(hipErrorIllegalState); + } // Capture must be ended on the same stream in which it was initiated if (!s->IsOriginStream()) { HIP_RETURN(hipErrorStreamCaptureUnmatched);