Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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