SWDEV-184710

Support hipLaunchCooperativeKernelMultiDevice()

- Add hipCooperativeLaunchMultiDeviceNoPreSync and
hipCooperativeLaunchMultiDeviceNoPostSync support to pass a cuda test

Change-Id: If518f11ef2636a2235e5df9e77f879d8ced68102
This commit is contained in:
German Andryeyev
2020-04-06 11:33:53 -04:00
committed by Christophe Paquot
parent 7e051d8a96
commit da1444bfc8
+23 -4
View File
@@ -273,7 +273,6 @@ hipError_t hipFuncGetAttributes(hipFuncAttributes* attr, const void* func)
HIP_RETURN(hipSuccess);
}
hipError_t ihipModuleLaunchKernel(hipFunction_t f,
uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ,
uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ,
@@ -313,9 +312,10 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f,
return hipErrorCooperativeLaunchTooLarge;
}
}
if ((params & amd::NDRangeKernelCommand::CooperativeMultiDeviceGroups) &&
!device.info().cooperativeMultiDeviceGroups_) {
return hipErrorLaunchFailure;
if (params & amd::NDRangeKernelCommand::CooperativeMultiDeviceGroups) {
if (!device.info().cooperativeMultiDeviceGroups_) {
return hipErrorLaunchFailure;
}
}
if (!queue) {
return hipErrorOutOfMemory;
@@ -487,6 +487,16 @@ hipError_t ihipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsL
}
uint64_t prevGridSize = 0;
uint32_t firstDevice = 0;
// Sync the execution streams on all devices
if ((flags & hipCooperativeLaunchMultiDeviceNoPreSync) == 0) {
for (int i = 0; i < numDevices; ++i) {
amd::HostQueue* queue =
reinterpret_cast<hip::Stream*>(launchParamsList[i].stream)->asHostQueue();
queue->finish();
}
}
for (int i = 0; i < numDevices; ++i) {
const hipLaunchParams& launch = launchParamsList[i];
amd::HostQueue* queue = reinterpret_cast<hip::Stream*>(launch.stream)->asHostQueue();
@@ -521,6 +531,15 @@ hipError_t ihipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsL
prevGridSize += launch.gridDim.x * launch.gridDim.y * launch.gridDim.z;
}
// Sync the execution streams on all devices
if ((flags & hipCooperativeLaunchMultiDeviceNoPostSync) == 0) {
for (int i = 0; i < numDevices; ++i) {
amd::HostQueue* queue =
reinterpret_cast<hip::Stream*>(launchParamsList[i].stream)->asHostQueue();
queue->finish();
}
}
return result;
}