From 2aa2212d9381c8e27242d1e09ecf079625558dd3 Mon Sep 17 00:00:00 2001 From: "Assiouras, Ioannis" Date: Wed, 13 Aug 2025 07:47:49 +0100 Subject: [PATCH] =?UTF-8?q?SWDEV-549247=20-=20Fix=20stream=20checks=20for?= =?UTF-8?q?=20hipModuleLaunchCooperativeKernel=E2=80=A6=20(#858)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SWDEV-549247 - Fix stream validation checks in hipModuleLaunchCooperativeKernelMultiDevice In CooperativeKernelMultiDevice mode, the stream's device should be validated against the grid's assigned device rather than the current device. --- hipamd/src/hip_module.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hipamd/src/hip_module.cpp b/hipamd/src/hip_module.cpp index 663ad00df6..5a33cd3e78 100644 --- a/hipamd/src/hip_module.cpp +++ b/hipamd/src/hip_module.cpp @@ -429,7 +429,11 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, amd::LaunchParams& launch_par uint64_t prevGridSum = 0, uint64_t allGridSum = 0, uint32_t firstDevice = 0) { int deviceId = hip::Stream::DeviceId(hStream); - if (deviceId != ihipGetDevice()) { + + // Ensure the stream's device matches the current device, + // or the grid's assigned device in CooperativeKernelMultiDevice mode + int targetDevice = (numGrids == 0) ? ihipGetDevice() : gridId; + if (deviceId != targetDevice) { return hipErrorInvalidResourceHandle; } HIP_RETURN_ONFAIL(PlatformState::instance().initStatManagedVarDevicePtr(deviceId));