Skip to content

Instantly share code, notes, and snippets.

@K-Wu
Last active April 25, 2023 20:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save K-Wu/6c353273aafe9a4eaaa344a8b74475b6 to your computer and use it in GitHub Desktop.
Save K-Wu/6c353273aafe9a4eaaa344a8b74475b6 to your computer and use it in GitHub Desktop.
Checking if MPI is installed with cuda-awareness
/*
* 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