From 5fe91ccb1baf3fe49ff9caebc93d14193f9bc4e1 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Mon, 6 Apr 2020 13:54:03 -0400 Subject: [PATCH] SWDEV-184710 Support hipLaunchCooperativeKernelMultiDevice() - Add validation logic for MGPU launches to pass a cuda test Change-Id: Iccca7fde43493fc3bc6685512d39202271ae3e92 --- include/hip/hip_runtime_api.h | 18 +++++++++++++++++- vdi/hip_device.cpp | 5 +++++ vdi/hip_device_runtime.cpp | 12 ++++++++++++ vdi/hip_module.cpp | 20 ++++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/include/hip/hip_runtime_api.h b/include/hip/hip_runtime_api.h index 025688e98c..cf6a64ad65 100644 --- a/include/hip/hip_runtime_api.h +++ b/include/hip/hip_runtime_api.h @@ -128,6 +128,14 @@ typedef struct hipDeviceProp_t { int kernelExecTimeoutEnabled; /// mgpu_list(numDevices); + for (int i = 0; i < numDevices; ++i) { const hipLaunchParams& launch = launchParamsList[i]; allGridSize += launch.gridDim.x * launch.gridDim.y * launch.gridDim.z; + + // Make sure block dimensions are valid + if (0 == launch.blockDim.x * launch.blockDim.y * launch.blockDim.z) { + return hipErrorInvalidConfiguration; + } + if (launch.stream != nullptr) { + // Validate devices to make sure it dosn't have duplicates + amd::HostQueue* queue = reinterpret_cast(launch.stream)->asHostQueue(); + auto device = &queue->vdev()->device(); + for (int j = 0; j < numDevices; ++j) { + if (mgpu_list[j] == device) { + return hipErrorInvalidDevice; + } + } + mgpu_list[i] = device; + } else { + return hipErrorInvalidResourceHandle; + } } uint64_t prevGridSize = 0; uint32_t firstDevice = 0;