From abc3e6df5c4000bc51dd02b6e32b8f1b2e92e963 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 [ROCm/clr commit: 8be723e199495e41945bd0e490525b5685863603] --- .../clr/hipamd/include/hip/hip_runtime_api.h | 18 ++++++++++++++++- projects/clr/hipamd/vdi/hip_device.cpp | 5 +++++ .../clr/hipamd/vdi/hip_device_runtime.cpp | 12 +++++++++++ projects/clr/hipamd/vdi/hip_module.cpp | 20 +++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/include/hip/hip_runtime_api.h b/projects/clr/hipamd/include/hip/hip_runtime_api.h index 025688e98c..cf6a64ad65 100644 --- a/projects/clr/hipamd/include/hip/hip_runtime_api.h +++ b/projects/clr/hipamd/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;