Last active
November 18, 2024 14:18
-
-
Save K-Wu/6c353273aafe9a4eaaa344a8b74475b6 to your computer and use it in GitHub Desktop.
Checking if MPI is installed with cuda-awareness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* From https://www.open-mpi.org/faq/?category=runcuda | |
* Command: | |
* $ mpic++ cuda_aware_check.cpp | |
* $ mpirun a.out | |
* Program that shows the use of CUDA-aware macro and runtime check. | |
* Requires Open MPI v2.0.0 or later. | |
*/ | |
#include <stdio.h> | |
#include "mpi.h" | |
#include "mpi-ext.h" | |
#if defined(MPIX_CUDA_AWARE_SUPPORT) | |
#include "mpi-ext.h" /* Needed for CUDA-aware check */ | |
#endif | |
int main(int argc, char *argv[]) | |
{ | |
printf("Compile time check:\n"); | |
if (1 == MPIX_Query_cuda_support()) { | |
printf("This MPI library has CUDA-aware support.\n"); | |
} else { | |
printf("This MPI library does not have CUDA-aware support.\n"); | |
} | |
#if defined(MPIX_CUDA_AWARE_SUPPORT) && MPIX_CUDA_AWARE_SUPPORT | |
printf("This MPI library has CUDA-aware support.\n", MPIX_CUDA_AWARE_SUPPORT); | |
#elif defined(MPIX_CUDA_AWARE_SUPPORT) && !MPIX_CUDA_AWARE_SUPPORT | |
printf("This MPI library does not have CUDA-aware support.\n"); | |
#else | |
printf("This MPI library cannot determine if there is CUDA-aware support.\n"); | |
#endif /* MPIX_CUDA_AWARE_SUPPORT */ | |
printf("Run time check:\n"); | |
#if defined(MPIX_CUDA_AWARE_SUPPORT) | |
if (1 == MPIX_Query_cuda_support()) { | |
printf("This MPI library has CUDA-aware support.\n"); | |
} else { | |
printf("This MPI library does not have CUDA-aware support.\n"); | |
} | |
#else /* !defined(MPIX_CUDA_AWARE_SUPPORT) */ | |
printf("This MPI library cannot determine if there is CUDA-aware support.\n"); | |
#endif /* MPIX_CUDA_AWARE_SUPPORT */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment