diff --git a/src/common_io.c b/src/common_io.c index ca157afb01f11d7d8c19a44e90bb7d832dfad05c..a22964dbf1531bbbbf42aab6b7efe8ab9efbca37 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -356,6 +356,8 @@ void writeCodeDescription(hid_t h_file) { if (h_grpcode < 0) error("Error while creating code group"); writeAttribute_s(h_grpcode, "Code Version", package_version()); + writeAttribute_s(h_grpcode, "Compiler Name", compiler_name()); + writeAttribute_s(h_grpcode, "Compiler Version", compiler_version()); writeAttribute_s(h_grpcode, "Git Branch", git_branch()); writeAttribute_s(h_grpcode, "Git Revision", git_revision()); diff --git a/src/version.c b/src/version.c index 8fca8fae066da57f24203275f3845a4a1ebc4dbb..fc2bcec4ed831f5b4181f2d4f25de9b1b640877b 100644 --- a/src/version.c +++ b/src/version.c @@ -45,7 +45,6 @@ const char *git_branch(void) { return branch; } - /** * @brief The version of SWIFT */ @@ -61,13 +60,50 @@ const char *package_description(void) { static char buf[256]; static int initialised = 0; if (!initialised) { - sprintf(buf, "SWIFT version: %s, at revision: %s, branch: %s", + sprintf(buf, "SWIFT version: %s, at revision: %s, branch: %s", PACKAGE_VERSION, GIT_REVISION, GIT_BRANCH); initialised = 1; } return buf; } +const char *compiler_name(void) { +#if defined(__INTEL_COMPILER) + static const char *compiler = "ICC"; +#elif defined(__clang__) + static const char *compiler = "LLVM/Clang"; +#elif defined(__xlc__) + static const char *compiler = "IBM XL"; +#elif defined(__GNUC__) + static const char *compiler = "GCC"; +#else + static const char *compiler = "Unknown Compiler"; +#endif + return compiler; +} + +const char *compiler_version(void) { + static char version[256]; +#if defined(__INTEL_COMPILER) + const int major = __INTEL_COMPILER / 100; + const int minor = __INTEL_COMPILER - major * 100; + sprintf(version, "%i.%i.%i", major, minor, __INTEL_COMPILER_BUILD_DATE); +#elif defined(__clang__) + sprintf(version, "%i.%i.%i", __clang_major__, __clang_minor__, + __clang_patchlevel__); +#elif defined(__xlc__) + const int major = __IBMC__ / 100; + const int minor = (__IBMC__ - major * 100) / 10; + const int patch = (__IBMC__ - major * 100 - minor * 10); + sprintf(version, "%i.%i.%i", major, minor, patch); +#elif defined(__GNUC__) + sprintf(version, "%i.%i.%i", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); +#else + sprintf(version, "---"); +#endif + return version; +} + /** * @brief Prints a greeting message to the standard output containing code * version and revision number @@ -83,6 +119,7 @@ void greetings(void) { printf(" SPH With Inter-dependent Fine-grained Tasking\n\n"); printf(" Version : %s\n", package_version()); - printf(" Revision: %s, branch: %s\n", git_revision(), git_branch()); - printf(" Webpage : www.swiftsim.com\n\n"); + 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()); } diff --git a/src/version.h.in b/src/version.h.in index fbe6d5c82fa31302172a7e263a4e2382b8f77ae8..d29ab6d43784c0f64b37a9c0d1a99781c82770bd 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -22,7 +22,7 @@ /** * @file version.h - * @brief Package version and git revision sha. + * @brief Package version, git revision sha and compiler info. */ #define PACKAGE_VERSION "@PACKAGE_VERSION@" @@ -33,6 +33,8 @@ const char* package_description(void); const char* package_version(void); const char* git_revision(void); const char* git_branch(void); +const char* compiler_name(void); +const char* compiler_version(void); void greetings(void); #endif /* SWIFT_VERSION_H */