From 0288eeef75fbf7c96bd10b91befdc18cd64657a4 Mon Sep 17 00:00:00 2001 From: Gilbert Lee Date: Thu, 11 Jul 2019 15:36:21 +0000 Subject: [PATCH] Checking that number of requested GPUs is not more than number of available GPUs [ROCm/rccl-tests commit: 043eef69996a825698c5679d8419ee12768740d0] --- projects/rccl-tests/src/common.cu | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/projects/rccl-tests/src/common.cu b/projects/rccl-tests/src/common.cu index d708a7a916..d4d528ea7c 100644 --- a/projects/rccl-tests/src/common.cu +++ b/projects/rccl-tests/src/common.cu @@ -738,6 +738,15 @@ int main(int argc, char* argv[]) { return 0; } } + + int numDevices; + HIPCHECK(hipGetDeviceCount(&numDevices)); + if (nGpus > numDevices) + { + fprintf(stderr, "[ERROR] The number of requested GPUs (%d) is greater than the number of GPUs available (%d)\n", nGpus, numDevices); + return testNcclError; + } + #ifdef MPI_SUPPORT MPI_Init(&argc, &argv); #endif