From f6c8bbf4dcc2ec0022ea4faa5a9d75afb2a58a11 Mon Sep 17 00:00:00 2001 From: Vladana Stojiljkovic Date: Mon, 21 Oct 2024 14:40:09 +0200 Subject: [PATCH] SWDEV-492768 - Match hipStreamAddCallback capture behavior with nvidia Change-Id: I7a084d8eeffe8b5095f7eb9969a565a40e76bb4b --- hipamd/src/hip_stream.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hipamd/src/hip_stream.cpp b/hipamd/src/hip_stream.cpp index 9373749772..c57ad72c89 100644 --- a/hipamd/src/hip_stream.cpp +++ b/hipamd/src/hip_stream.cpp @@ -609,6 +609,18 @@ hipError_t hipStreamAddCallback_common(hipStream_t stream, hipStreamCallback_t c if (callback == nullptr || flags != 0) { return hipErrorInvalidValue; } + + if (stream != nullptr) { + // Not supported while stream is capturing + if (hip::Stream::StreamCaptureOngoing(stream) == true) { + HIP_RETURN(hipErrorStreamCaptureUnsupported); + } + } else if (Stream::StreamCaptureBlocking() == true) { + // If any of the blocking streams is capturing, return error for implicit capture and invalidate + // capture for all capturing streams + CHECK_STREAM_CAPTURING(); + } + StreamCallback* cbo = new StreamAddCallback(stream, callback, userData); return streamCallback_common(stream, cbo, userData); }