refactor MPI library info query so it can be added to -help flag output

This commit is contained in:
Axel Kohlmeyer
2019-12-11 05:33:16 -05:00
parent e68824a392
commit 876032b762
3 changed files with 27 additions and 15 deletions

View File

@ -355,19 +355,7 @@ void Info::command(int narg, char **arg)
if (flags & COMM) {
int major,minor,len;
#if (defined(MPI_VERSION) && (MPI_VERSION > 2)) || defined(MPI_STUBS)
char version[MPI_MAX_LIBRARY_VERSION_STRING];
MPI_Get_library_version(version,&len);
#else
char version[] = "Undetected MPI implementation";
len = strlen(version);
#endif
MPI_Get_version(&major,&minor);
if (len > 80) {
char *ptr = strchr(version+80,'\n');
if (ptr) *ptr = '\0';
}
const char *version = get_mpi_info(major,minor);
fprintf(out,"\nCommunication information:\n");
fprintf(out,"MPI library level: MPI v%d.%d\n",major,minor);
@ -1209,6 +1197,25 @@ const char *Info::get_openmp_info()
#endif
}
const char *Info::get_mpi_info(int &major, int &minor)
{
int len;
#if (defined(MPI_VERSION) && (MPI_VERSION > 2)) || defined(MPI_STUBS)
static char version[MPI_MAX_LIBRARY_VERSION_STRING];
MPI_Get_library_version(version,&len);
#else
static char version[] = "Undetected MPI implementation";
len = strlen(version);
#endif
MPI_Get_version(&major,&minor);
if (len > 80) {
char *ptr = strchr(version+80,'\n');
if (ptr) *ptr = '\0';
}
return version;
}
const char *Info::get_cxx_info()
{
#if __cplusplus > 201703L