Commit 0b33a4ca authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'cosmetics' into 'master'

Print information about the libraries used in the greeting message

I had nothing better to do whilst sitting at the back of the room during the DEX workshop...

See merge request !72
parents 461885a4 c7f0a621
......@@ -60,6 +60,7 @@ AC_ARG_ENABLE([mpi],
good_mpi="yes"
if test "$enable_mpi" = "yes"; then
AX_MPI([CC="$MPICC" AC_DEFINE(HAVE_MPI, 1, [Define if you have the MPI library.]) ])
MPI_LIBRARY="Unknown MPI"
# Various MPI implementations require additional libraries when also using
# threads. Use mpirun (on PATH) as that seems to be only command with
......@@ -83,14 +84,17 @@ if test "$enable_mpi" = "yes"; then
case "$version" in
*Intel*MPI*)
MPI_THREAD_LIBS="-mt_mpi"
MPI_LIBRARY="Intel MPI"
AC_MSG_RESULT([Intel MPI])
;;
*Platform*)
MPI_THREAD_LIBS="-lmtmpi"
MPI_LIBRARY="PLATFORM MPI"
AC_MSG_RESULT([PLATFORM MPI])
;;
*"Open MPI"*)
MPI_THREAD_LIBS=""
MPI_LIBRARY="Open MPI"
AC_MSG_RESULT([Open MPI])
# OpenMPI should be 1.8.6 or later, if not complain.
# Version is last word on first line of -version output.
......@@ -109,6 +113,7 @@ if test "$enable_mpi" = "yes"; then
esac
AC_SUBST([MPI_THREAD_LIBS])
fi
AC_DEFINE_UNQUOTED([SWIFT_MPI_LIBRARY], ["$MPI_LIBRARY"], [The MPI library name, if known.])
fi
AM_CONDITIONAL([HAVEMPI],[test $enable_mpi = "yes"])
......
......@@ -18,6 +18,21 @@
*
******************************************************************************/
/* Config parameters. */
#include "../config.h"
/* MPI headers. */
#ifdef WITH_MPI
#include <mpi.h>
#ifdef HAVE_METIS
#include <metis.h>
#endif
#endif
#ifdef HAVE_HDF5
#include <hdf5.h>
#endif
/* Some standard headers. */
#include <stdio.h>
#include <string.h>
......@@ -28,15 +43,17 @@
/**
* @brief Return the source code git revision
*
* @details The SHA of the code checked out when the library was last built.
* The SHA of the code checked out when the library was last built.
* Will include -dirty if they are local modifications.
*
* @result the git version.
*/
const char *git_revision(void) {
static char buf[256];
static int initialised = 0;
static const char *revision = GIT_REVISION;
if(!initialised) {
if(strlen(revision) == 0)
if (!initialised) {
if (strlen(revision) == 0)
sprintf(buf, "%s", "unknown");
else
sprintf(buf, "%s", revision);
......@@ -48,14 +65,16 @@ const char *git_revision(void) {
/**
* @brief Return the source code git branch
*
* @details The name of the current branch when the code was last built.
* The name of the current branch when the code was last built.
*
* @result git branch
*/
const char *git_branch(void) {
static char buf[256];
static int initialised = 0;
static const char *branch = GIT_BRANCH;
if(!initialised) {
if(strlen(branch) == 0)
if (!initialised) {
if (strlen(branch) == 0)
sprintf(buf, "%s", "unknown");
else
sprintf(buf, "%s", branch);
......@@ -66,6 +85,8 @@ const char *git_branch(void) {
/**
* @brief The version of SWIFT
*
* @result the package version
*/
const char *package_version(void) {
static const char *version = PACKAGE_VERSION;
......@@ -74,6 +95,8 @@ const char *package_version(void) {
/**
* @brief A description of the package version and code status.
*
* @result description of the package version
*/
const char *package_description(void) {
static char buf[256];
......@@ -86,6 +109,11 @@ const char *package_description(void) {
return buf;
}
/**
* @brief return the name of the compiler used to build SWIFT.
*
* @result description of the compiler.
*/
const char *compiler_name(void) {
static char compiler[256] = {0};
#if defined(__INTEL_COMPILER)
......@@ -101,6 +129,11 @@ const char *compiler_name(void) {
return compiler;
}
/**
* @brief return compiler version used to build SWIFT.
*
* @result description of the compiler.
*/
const char *compiler_version(void) {
static char version[256] = {0};
#if defined(__INTEL_COMPILER)
......@@ -122,6 +155,87 @@ const char *compiler_version(void) {
return version;
}
/**
* @brief return the MPI version, runtime if possible otherwise that used when
* built.
*
* @result description of the MPI version.
*/
const char *mpi_version(void) {
static char version[80] = {0};
#ifdef WITH_MPI
int std_version, std_subversion;
/* Check that the library implements the version string routine */
#ifdef MPI_MAX_LIBRARY_VERSION_STRING
static char lib_version[MPI_MAX_LIBRARY_VERSION_STRING] = {0};
int len;
MPI_Get_library_version(lib_version, &len);
/* Find first \n and truncate string to this length, can get many lines from
* some MPIs (MPICH). */
char *ptr = strchr(lib_version, '\n');
if (ptr != NULL) *ptr = '\0';
/* Also arbitrarily truncate to keep down to one line, Open MPI,
* check for last comma and keep to ~60 chars max. */
strcpy(lib_version+60, "...");
ptr = strrchr(lib_version, ',');
if (ptr != NULL) *ptr = '\0';
#else
/* Use autoconf guessed value. */
static char lib_version[60] = {0};
snprintf(lib_version, 60, "%s", SWIFT_MPI_LIBRARY);
#endif
/* Numeric version. */
MPI_Get_version(&std_version, &std_subversion);
snprintf(version, 80, "%s (MPI std v%i.%i)", lib_version,
std_version, std_subversion);
#else
sprintf(version, "Code was not compiled with MPI support");
#endif
return version;
}
/**
* @brief return the HDF5 version in use at runtime.
*
* @result description of the current HDF5 version.
*/
const char *hdf5_version(void) {
static char version[256] = {0};
#ifdef HAVE_HDF5
unsigned int majnum, minnum, relnum;
H5get_libversion(&majnum, &minnum, &relnum);
sprintf(version, "%i.%i.%i", majnum, minnum, relnum);
#else
sprintf(version, "Unknown version");
#endif
return version;
}
/**
* @brief return the METIS version used when SWIFT was built.
*
* @result description of the METIS version.
*/
const char *metis_version(void) {
static char version[256] = {0};
#if defined(WITH_MPI) && defined(HAVE_METIS)
sprintf(version, "%i.%i.%i", METIS_VER_MAJOR, METIS_VER_MINOR,
METIS_VER_SUBMINOR);
#else
sprintf(version, "Unknown version");
#endif
return version;
}
/**
* @brief Prints a greeting message to the standard output containing code
* version and revision number
......@@ -138,6 +252,16 @@ void greetings(void) {
printf(" Version : %s\n", package_version());
printf(" Revision: %s, Branch: %s\n", git_revision(), git_branch());
printf(" Webpage : www.swiftsim.com\n");
printf(" Compiler: %s, Version: %s\n\n", compiler_name(), compiler_version());
printf(" Webpage : www.swiftsim.com\n\n");
printf(" Compiler: %s, Version: %s\n", compiler_name(), compiler_version());
#ifdef HAVE_HDF5
printf(" HDF5 library version: %s\n", hdf5_version());
#endif
#ifdef WITH_MPI
printf(" MPI library: %s\n", mpi_version());
#ifdef HAVE_METIS
printf(" METIS library version: %s\n", metis_version());
#endif
#endif
printf("\n");
}
......@@ -35,6 +35,9 @@ const char* git_revision(void);
const char* git_branch(void);
const char* compiler_name(void);
const char* compiler_version(void);
const char* mpi_version(void);
const char *hdf5_version(void);
const char *metis_version(void);
void greetings(void);
#endif /* SWIFT_VERSION_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment