From 63c4020e491eb7611c355fb7ee1916f0584582fd Mon Sep 17 00:00:00 2001 From: "Stojiljkovic, Vladana" Date: Thu, 22 May 2025 17:22:37 +0200 Subject: [PATCH] Match hipLaunchCooperativeKernelMultiDevice behavior with nvidia (#385) Co-authored-by: Anusha GodavarthySurya --- hipamd/src/hip_module.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hipamd/src/hip_module.cpp b/hipamd/src/hip_module.cpp index 9886685efd..555df3fbd8 100644 --- a/hipamd/src/hip_module.cpp +++ b/hipamd/src/hip_module.cpp @@ -859,6 +859,20 @@ hipError_t ihipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsL if (!hip::isValid(launch.stream)) { return hipErrorInvalidValue; } + + if (launch.stream == nullptr || launch.stream == hipStreamLegacy) { + return hipErrorInvalidResourceHandle; + } + + // Not supported while stream is capturing + hip::Stream* s = reinterpret_cast(launch.stream); + if (s->GetCaptureStatus() == hipStreamCaptureStatusActive) { + s->SetCaptureStatus(hipStreamCaptureStatusInvalidated); + return hipErrorStreamCaptureUnsupported; + } + if (s->GetCaptureStatus() == hipStreamCaptureStatusInvalidated) { + return hipErrorStreamCaptureInvalidated; + } hip::Stream* hip_stream = hip::getStream(launch.stream); hipFunction_t func = nullptr;