From bca0438b691af760ecba60e7e111ced29f4c602b Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 20 Jun 2019 18:13:20 -0400
Subject: [PATCH] P4 to Git Change 1879857 by gandryey@gera-win10 on 2019/06/20
18:06:07
SWDEV-184710 - Support hipLaunchCooperativeKernelMultiDevice()
- Clean-up the loop for the launch on each device
- Add hipExtLaunchMultiKernelMultiDevice()
http://ocltc.amd.com/reviews/r/17573/
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_module.cpp#29 edit
---
hipamd/api/hip/hip_module.cpp | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/hipamd/api/hip/hip_module.cpp b/hipamd/api/hip/hip_module.cpp
index edc3ba4384..eb6aec8e08 100644
--- a/hipamd/api/hip/hip_module.cpp
+++ b/hipamd/api/hip/hip_module.cpp
@@ -333,16 +333,23 @@ hipError_t hipLaunchCooperativeKernel(const void* f,
amd::NDRangeKernelCommand::CooperativeGroups));
}
-hipError_t hipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsList,
- int numDevices, unsigned int flags)
+hipError_t ihipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsList,
+ int numDevices, unsigned int flags, uint32_t extFlags)
{
- int deviceId = ihipGetDevice();
+ int currentDevice = ihipGetDevice();
+ int numActiveGPUs = 0;
+ ihipDeviceGetCount(&numActiveGPUs);
+ if ((numDevices > numActiveGPUs) || (launchParamsList == nullptr)) {
+ return hipErrorInvalidValue;
+ }
+
hipError_t result = hipErrorUnknown;
for (int i = 0; i < numDevices; ++i) {
+ hipSetDevice(i);
const hipLaunchParams& launch = launchParamsList[i];
amd::HostQueue* queue = as_amd(reinterpret_cast(launch.stream))->asHostQueue();
- hipFunction_t func = PlatformState::instance().getFunc(launch.func, deviceId);
+ hipFunction_t func = PlatformState::instance().getFunc(launch.func, i);
if (func == nullptr) {
HIP_RETURN(result);
}
@@ -352,8 +359,22 @@ hipError_t hipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsLi
launch.gridDim.z * launch.blockDim.z,
launch.blockDim.x, launch.blockDim.y, launch.blockDim.z,
launch.sharedMem, launch.stream,
- launch.args, nullptr, nullptr, nullptr, flags,
- (amd::NDRangeKernelCommand::CooperativeGroups | amd::NDRangeKernelCommand::CooperativeMultiDeviceGroups));
+ launch.args, nullptr, nullptr, nullptr, flags, extFlags);
}
+
+ hipSetDevice(currentDevice);
return result;
}
+
+hipError_t hipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsList,
+ int numDevices, unsigned int flags)
+{
+ return ihipLaunchCooperativeKernelMultiDevice(launchParamsList, numDevices, flags,
+ (amd::NDRangeKernelCommand::CooperativeGroups |
+ amd::NDRangeKernelCommand::CooperativeMultiDeviceGroups));
+}
+
+hipError_t hipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList,
+ int numDevices, unsigned int flags) {
+ return ihipLaunchCooperativeKernelMultiDevice(launchParamsList, numDevices, flags, 0);
+}