2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
7 * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
8 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9 * and including many others, as listed in the AUTHORS file in the
10 * top-level source directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
39 * \brief Implements functionality for printing information about the
40 * currently running binary
42 * \ingroup module_utility
46 #include "binaryinformation.h"
50 #if GMX_FFT_FFTW3 || GMX_FFT_ARMPL_FFTW3
51 // Needed for construction of the FFT library description string
60 # include <extrae_user_events.h>
75 /* This file is completely threadsafe - keep it that way! */
77 #include "buildinfo.h"
78 #include "gromacs/utility/arraysize.h"
79 #include "gromacs/utility/baseversion.h"
80 #include "gromacs/utility/exceptions.h"
81 #include "gromacs/utility/gmxassert.h"
82 #include "gromacs/utility/path.h"
83 #include "gromacs/utility/programcontext.h"
84 #include "gromacs/utility/stringutil.h"
85 #include "gromacs/utility/sysinfo.h"
86 #include "gromacs/utility/textwriter.h"
88 #include "cuda_version_information.h"
93 using gmx::formatString;
95 //! \cond Doxygen does not need to care about most of this stuff, and the macro usage is painful to document
97 int centeringOffset(int width, int length)
99 return std::max(width - length, 0) / 2;
102 std::string formatCentered(int width, const char* text)
104 const int offset = centeringOffset(width, std::strlen(text));
105 return formatString("%*s%s", offset, "", text);
108 void printCopyright(gmx::TextWriter* writer)
110 // Contributors sorted alphabetically by last name
111 static const char* const Contributors[] = { "Andrey Alekseenko",
115 "Herman J.C. Berendsen",
118 "Viacheslav Bolnykh",
123 "Gilles Gouaillardet",
127 "Vincent Hindriksen",
130 "Christoph Junghans",
132 "Dimitrios Karkoulis",
153 "Christian Wennberg",
156 static const char* const CopyrightText[] = {
157 "Copyright (c) 1991-2000, University of Groningen, The Netherlands.",
158 "Copyright (c) 2001-2019, The GROMACS development team at",
159 "Uppsala University, Stockholm University and", "the Royal Institute of Technology, Sweden.",
160 "check out http://www.gromacs.org for more information."
163 #define NCONTRIBUTORS static_cast<int>(asize(Contributors))
164 #define NCR static_cast<int>(asize(CopyrightText))
166 // TODO a centering behaviour of TextWriter could be useful here
167 writer->writeLine(formatCentered(78, "GROMACS is written by:"));
168 for (int i = 0; i < NCONTRIBUTORS;)
170 for (int j = 0; j < 3 && i < NCONTRIBUTORS; ++j, ++i)
172 const int width = 26;
173 std::array<char, 30> buf;
174 const int offset = centeringOffset(width, strlen(Contributors[i]));
175 GMX_RELEASE_ASSERT(static_cast<int>(strlen(Contributors[i])) + offset < gmx::ssize(buf),
176 "Formatting buffer is not long enough");
177 std::fill(buf.begin(), buf.begin() + offset, ' ');
178 std::strncpy(buf.data() + offset, Contributors[i], gmx::ssize(buf) - offset);
179 writer->writeString(formatString(" %-*s", width, buf.data()));
181 writer->ensureLineBreak();
183 writer->writeLine(formatCentered(78, "and the project leaders:"));
185 formatCentered(78, "Mark Abraham, Berk Hess, Erik Lindahl, and David van der Spoel"));
186 writer->ensureEmptyLine();
187 for (int i = 0; i < NCR; ++i)
189 writer->writeLine(CopyrightText[i]);
191 writer->ensureEmptyLine();
193 // Folding At Home has different licence to allow digital
194 // signatures in GROMACS, so does not need to show the normal
195 // license statement.
198 writer->writeLine("GROMACS is free software; you can redistribute it and/or modify it");
199 writer->writeLine("under the terms of the GNU Lesser General Public License");
200 writer->writeLine("as published by the Free Software Foundation; either version 2.1");
201 writer->writeLine("of the License, or (at your option) any later version.");
205 // Construct a string that describes the library that provides FFT support to this build
206 const char* getFftDescriptionString()
208 // Define the FFT description string
209 #if GMX_FFT_FFTW3 || GMX_FFT_ARMPL_FFTW3
210 # if GMX_NATIVE_WINDOWS
214 // Use the version string provided by libfftw3
218 return fftwf_version;
226 return "fftpack (built-in)";
230 void gmx_print_version_info(gmx::TextWriter* writer)
232 writer->writeLine(formatString("GROMACS version: %s", gmx_version()));
233 const char* const git_hash = gmx_version_git_full_hash();
234 if (git_hash[0] != '\0')
236 writer->writeLine(formatString("GIT SHA1 hash: %s", git_hash));
238 const char* const base_hash = gmx_version_git_central_base_hash();
239 if (base_hash[0] != '\0')
241 writer->writeLine(formatString("Branched from: %s", base_hash));
243 const char* const releaseSourceChecksum = gmxReleaseSourceChecksum();
244 const char* const currentSourceChecksum = gmxCurrentSourceChecksum();
245 if (releaseSourceChecksum[0] != '\0')
247 if (std::strcmp(releaseSourceChecksum, "NoChecksumFile") == 0)
249 writer->writeLine(formatString(
250 "The source code this program was compiled from has not been verified because "
251 "the reference checksum was missing during compilation. This means you have an "
252 "incomplete GROMACS distribution, please make sure to download an intact "
253 "source distribution and compile that before proceeding."));
254 writer->writeLine(formatString("Computed checksum: %s", currentSourceChecksum));
256 else if (std::strcmp(releaseSourceChecksum, "NoPythonAvailable") == 0)
259 formatString("Build source could not be verified, because the checksum could "
260 "not be computed."));
262 else if (std::strcmp(releaseSourceChecksum, currentSourceChecksum) != 0)
264 writer->writeLine(formatString(
265 "This program has been built from source code that has been altered and does "
266 "not match the code released as part of the official GROMACS version %s. If "
267 "you did not intend to use an altered GROMACS version, make sure to download "
268 "an intact source distribution and compile that before proceeding.",
270 writer->writeLine(formatString(
271 "If you have modified the source code, you are strongly encouraged to set your "
272 "custom version suffix (using -DGMX_VERSION_STRING_OF_FORK) which will can "
273 "help later with scientific reproducibility but also when reporting bugs."));
274 writer->writeLine(formatString("Release checksum: %s", releaseSourceChecksum));
275 writer->writeLine(formatString("Computed checksum: %s", currentSourceChecksum));
279 writer->writeLine(formatString("Verified release checksum is %s", releaseSourceChecksum));
285 writer->writeLine("Precision: double");
287 writer->writeLine("Precision: mixed");
289 writer->writeLine(formatString("Memory model: %u bit", static_cast<unsigned>(8 * sizeof(void*))));
292 writer->writeLine("MPI library: thread_mpi");
294 writer->writeLine("MPI library: MPI");
296 writer->writeLine("MPI library: none");
299 writer->writeLine(formatString("OpenMP support: enabled (GMX_OPENMP_MAX_THREADS = %d)",
300 GMX_OPENMP_MAX_THREADS));
302 writer->writeLine("OpenMP support: disabled");
304 writer->writeLine(formatString("GPU support: %s", getGpuImplementationString()));
305 writer->writeLine(formatString("SIMD instructions: %s", GMX_SIMD_STRING));
306 writer->writeLine(formatString("FFT library: %s", getFftDescriptionString()));
308 writer->writeLine(formatString("RDTSCP usage: %s", GMX_USE_RDTSCP ? "enabled" : "disabled"));
311 writer->writeLine("TNG support: enabled");
313 writer->writeLine("TNG support: disabled");
316 writer->writeLine(formatString("Hwloc support: hwloc-%s", HWLOC_VERSION));
318 writer->writeLine("Hwloc support: disabled");
321 unsigned major, minor, revision;
322 Extrae_get_version(&major, &minor, &revision);
323 writer->writeLine(formatString("Tracing support: enabled. Using Extrae-%d.%d.%d", major,
326 writer->writeLine("Tracing support: disabled");
330 /* TODO: The below strings can be quite long, so it would be nice to wrap
331 * them. Can wait for later, as the master branch has ready code to do all
333 writer->writeLine(formatString("C compiler: %s", BUILD_C_COMPILER));
334 writer->writeLine(formatString("C compiler flags: %s %s", BUILD_CFLAGS,
335 CMAKE_BUILD_CONFIGURATION_C_FLAGS));
336 writer->writeLine(formatString("C++ compiler: %s", BUILD_CXX_COMPILER));
337 writer->writeLine(formatString("C++ compiler flags: %s %s", BUILD_CXXFLAGS,
338 CMAKE_BUILD_CONFIGURATION_CXX_FLAGS));
340 /* MKL might be used for LAPACK/BLAS even if FFTs use FFTW, so keep it separate */
341 writer->writeLine(formatString("Linked with Intel MKL version %d.%d.%d.", __INTEL_MKL__,
342 __INTEL_MKL_MINOR__, __INTEL_MKL_UPDATE__));
345 writer->writeLine(formatString("OpenCL include dir: %s", OPENCL_INCLUDE_DIR));
346 writer->writeLine(formatString("OpenCL library: %s", OPENCL_LIBRARY));
347 writer->writeLine(formatString("OpenCL version: %s", OPENCL_VERSION_STRING));
350 writer->writeLine(formatString("CUDA compiler: %s", CUDA_COMPILER_INFO));
351 writer->writeLine(formatString("CUDA compiler flags:%s %s", CUDA_COMPILER_FLAGS,
352 CMAKE_BUILD_CONFIGURATION_CXX_FLAGS));
353 writer->writeLine("CUDA driver: " + gmx::getCudaDriverVersionString());
354 writer->writeLine("CUDA runtime: " + gmx::getCudaRuntimeVersionString());
365 BinaryInformationSettings::BinaryInformationSettings() :
366 bExtendedInfo_(false),
369 bGeneratedByHeader_(false),
375 void printBinaryInformation(FILE* fp, const IProgramContext& programContext)
377 TextWriter writer(fp);
378 printBinaryInformation(&writer, programContext, BinaryInformationSettings());
381 void printBinaryInformation(FILE* fp,
382 const IProgramContext& programContext,
383 const BinaryInformationSettings& settings)
387 TextWriter writer(fp);
388 printBinaryInformation(&writer, programContext, settings);
390 GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR
393 void printBinaryInformation(TextWriter* writer,
394 const IProgramContext& programContext,
395 const BinaryInformationSettings& settings)
397 // TODO Perhaps the writer could be configured with the prefix and
398 // suffix strings from the settings?
399 const char* prefix = settings.prefix_;
400 const char* suffix = settings.suffix_;
401 const char* precisionString = "";
403 precisionString = " (double precision)";
405 const char* const name = programContext.displayName();
406 if (settings.bGeneratedByHeader_)
408 writer->writeLine(formatString("%sCreated by:%s", prefix, suffix));
410 // TODO: It would be nice to know here whether we are really running a
411 // Gromacs binary or some other binary that is calling Gromacs; we
412 // could then print "%s is part of GROMACS" or some alternative text.
413 std::string title = formatString(":-) GROMACS - %s, %s%s (-:", name, gmx_version(), precisionString);
415 centeringOffset(78 - std::strlen(prefix) - std::strlen(suffix), title.length()) + 1;
416 writer->writeLine(formatString("%s%*c%s%s", prefix, indent, ' ', title.c_str(), suffix));
417 writer->writeLine(formatString("%s%s", prefix, suffix));
418 if (settings.bCopyright_)
420 GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0',
421 "Prefix/suffix not supported with copyright");
422 printCopyright(writer);
423 writer->ensureEmptyLine();
424 // This line is printed again after the copyright notice to make it
425 // appear together with all the other information, so that it is not
426 // necessary to read stuff above the copyright notice.
427 // The line above the copyright notice puts the copyright notice is
429 writer->writeLine(formatString("%sGROMACS: %s, version %s%s%s", prefix, name,
430 gmx_version(), precisionString, suffix));
432 const char* const binaryPath = programContext.fullBinaryPath();
433 if (!gmx::isNullOrEmpty(binaryPath))
435 writer->writeLine(formatString("%sExecutable: %s%s", prefix, binaryPath, suffix));
437 const gmx::InstallationPrefixInfo installPrefix = programContext.installationPrefix();
438 if (!gmx::isNullOrEmpty(installPrefix.path))
440 writer->writeLine(formatString("%sData prefix: %s%s%s", prefix, installPrefix.path,
441 installPrefix.bSourceLayout ? " (source tree)" : "", suffix));
443 const std::string workingDir = Path::getWorkingDirectory();
444 if (!workingDir.empty())
446 writer->writeLine(formatString("%sWorking dir: %s%s", prefix, workingDir.c_str(), suffix));
448 if (settings.bProcessId_)
450 writer->writeLine(formatString("%sProcess ID: %d%s", prefix, gmx_getpid(), suffix));
452 const char* const commandLine = programContext.commandLine();
453 if (!gmx::isNullOrEmpty(commandLine))
455 writer->writeLine(formatString("%sCommand line:%s\n%s %s%s", prefix, suffix, prefix,
456 commandLine, suffix));
458 if (settings.bExtendedInfo_)
460 GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0',
461 "Prefix/suffix not supported with extended info");
462 writer->ensureEmptyLine();
463 gmx_print_version_info(writer);