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,2018, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
38 * \brief Implements functionality for printing information about the
39 * currently running binary
41 * \ingroup module_utility
45 #include "binaryinformation.h"
49 #if GMX_FFT_FFTW3 || GMX_FFT_ARMPL_FFTW3
50 // Needed for construction of the FFT library description string
59 #include <extrae_user_events.h>
73 /* This file is completely threadsafe - keep it that way! */
75 #include "buildinfo.h"
76 #include "gromacs/utility/arraysize.h"
77 #include "gromacs/utility/baseversion.h"
78 #include "gromacs/utility/exceptions.h"
79 #include "gromacs/utility/gmxassert.h"
80 #include "gromacs/utility/path.h"
81 #include "gromacs/utility/programcontext.h"
82 #include "gromacs/utility/stringutil.h"
83 #include "gromacs/utility/sysinfo.h"
84 #include "gromacs/utility/textwriter.h"
86 #include "cuda_version_information.h"
91 using gmx::formatString;
93 //! \cond Doxygen does not need to care about most of this stuff, and the macro usage is painful to document
95 int centeringOffset(int width, int length)
97 return std::max(width - length, 0) / 2;
100 std::string formatCentered(int width, const char *text)
102 const int offset = centeringOffset(width, std::strlen(text));
103 return formatString("%*s%s", offset, "", text);
106 void printCopyright(gmx::TextWriter *writer)
108 static const char * const Contributors[] = {
112 "Herman J.C. Berendsen",
115 "Viacheslav Bolnykh",
123 "Vincent Hindriksen",
126 "Christoph Junghans",
128 "Dimitrios Karkoulis",
149 "Christian Wennberg",
152 static const char * const CopyrightText[] = {
153 "Copyright (c) 1991-2000, University of Groningen, The Netherlands.",
154 "Copyright (c) 2001-2018, The GROMACS development team at",
155 "Uppsala University, Stockholm University and",
156 "the Royal Institute of Technology, Sweden.",
157 "check out http://www.gromacs.org for more information."
160 #define NCONTRIBUTORS static_cast<int>(asize(Contributors))
161 #define NCR static_cast<int>(asize(CopyrightText))
163 // TODO a centering behaviour of TextWriter could be useful here
164 writer->writeLine(formatCentered(78, "GROMACS is written by:"));
165 for (int i = 0; i < NCONTRIBUTORS; )
167 for (int j = 0; j < 4 && i < NCONTRIBUTORS; ++j, ++i)
169 const int width = 18;
171 const int offset = centeringOffset(width, strlen(Contributors[i]));
172 GMX_RELEASE_ASSERT(strlen(Contributors[i]) + offset < asize(buf),
173 "Formatting buffer is not long enough");
174 std::fill(buf, buf+width, ' ');
175 std::strcpy(buf+offset, Contributors[i]);
176 writer->writeString(formatString(" %-*s", width, buf));
178 writer->ensureLineBreak();
180 writer->writeLine(formatCentered(78, "and the project leaders:"));
181 writer->writeLine(formatCentered(78, "Mark Abraham, Berk Hess, Erik Lindahl, and David van der Spoel"));
182 writer->ensureEmptyLine();
183 for (int i = 0; i < NCR; ++i)
185 writer->writeLine(CopyrightText[i]);
187 writer->ensureEmptyLine();
189 // Folding At Home has different licence to allow digital
190 // signatures in GROMACS, so does not need to show the normal
191 // license statement.
194 writer->writeLine("GROMACS is free software; you can redistribute it and/or modify it");
195 writer->writeLine("under the terms of the GNU Lesser General Public License");
196 writer->writeLine("as published by the Free Software Foundation; either version 2.1");
197 writer->writeLine("of the License, or (at your option) any later version.");
201 // Construct a string that describes the library that provides FFT support to this build
202 const char *getFftDescriptionString()
204 // Define the FFT description string
205 #if GMX_FFT_FFTW3 || GMX_FFT_ARMPL_FFTW3
206 # if GMX_NATIVE_WINDOWS
210 // Use the version string provided by libfftw3
214 return fftwf_version;
222 return "fftpack (built-in)";
226 void gmx_print_version_info(gmx::TextWriter *writer)
228 writer->writeLine(formatString("GROMACS version: %s", gmx_version()));
229 const char *const git_hash = gmx_version_git_full_hash();
230 if (git_hash[0] != '\0')
232 writer->writeLine(formatString("GIT SHA1 hash: %s", git_hash));
234 const char *const base_hash = gmx_version_git_central_base_hash();
235 if (base_hash[0] != '\0')
237 writer->writeLine(formatString("Branched from: %s", base_hash));
241 writer->writeLine("Precision: double");
243 writer->writeLine("Precision: single");
245 writer->writeLine(formatString("Memory model: %u bit", static_cast<unsigned>(8*sizeof(void *))));
248 writer->writeLine("MPI library: thread_mpi");
250 writer->writeLine("MPI library: MPI");
252 writer->writeLine("MPI library: none");
255 writer->writeLine(formatString("OpenMP support: enabled (GMX_OPENMP_MAX_THREADS = %d)", GMX_OPENMP_MAX_THREADS));
257 writer->writeLine("OpenMP support: disabled");
259 writer->writeLine(formatString("GPU support: %s", getGpuImplementationString()));
260 writer->writeLine(formatString("SIMD instructions: %s", GMX_SIMD_STRING));
261 writer->writeLine(formatString("FFT library: %s", getFftDescriptionString()));
262 writer->writeLine(formatString("RDTSCP usage: %s", HAVE_RDTSCP ? "enabled" : "disabled"));
264 writer->writeLine("TNG support: enabled");
266 writer->writeLine("TNG support: disabled");
269 writer->writeLine(formatString("Hwloc support: hwloc-%s", HWLOC_VERSION));
271 writer->writeLine("Hwloc support: disabled");
274 unsigned major, minor, revision;
275 Extrae_get_version(&major, &minor, &revision);
276 writer->writeLine(formatString("Tracing support: enabled. Using Extrae-%d.%d.%d", major, minor, revision));
278 writer->writeLine("Tracing support: disabled");
282 /* TODO: The below strings can be quite long, so it would be nice to wrap
283 * them. Can wait for later, as the master branch has ready code to do all
285 writer->writeLine(formatString("C compiler: %s", BUILD_C_COMPILER));
286 writer->writeLine(formatString("C compiler flags: %s", BUILD_CFLAGS));
287 writer->writeLine(formatString("C++ compiler: %s", BUILD_CXX_COMPILER));
288 writer->writeLine(formatString("C++ compiler flags: %s", BUILD_CXXFLAGS));
290 /* MKL might be used for LAPACK/BLAS even if FFTs use FFTW, so keep it separate */
291 writer->writeLine(formatString("Linked with Intel MKL version %d.%d.%d.",
292 __INTEL_MKL__, __INTEL_MKL_MINOR__, __INTEL_MKL_UPDATE__));
294 #if GMX_GPU == GMX_GPU_OPENCL
295 writer->writeLine(formatString("OpenCL include dir: %s", OPENCL_INCLUDE_DIR));
296 writer->writeLine(formatString("OpenCL library: %s", OPENCL_LIBRARY));
297 writer->writeLine(formatString("OpenCL version: %s", OPENCL_VERSION_STRING));
299 #if GMX_GPU == GMX_GPU_CUDA
300 writer->writeLine(formatString("CUDA compiler: %s", CUDA_COMPILER_INFO));
301 writer->writeLine(formatString("CUDA compiler flags:%s", CUDA_COMPILER_FLAGS));
302 writer->writeLine("CUDA driver: " + gmx::getCudaDriverVersionString());
303 writer->writeLine("CUDA runtime: " + gmx::getCudaRuntimeVersionString());
314 BinaryInformationSettings::BinaryInformationSettings()
315 : bExtendedInfo_(false), bCopyright_(false),
317 bGeneratedByHeader_(false), prefix_(""), suffix_("")
321 void printBinaryInformation(FILE *fp,
322 const IProgramContext &programContext)
324 TextWriter writer(fp);
325 printBinaryInformation(&writer, programContext, BinaryInformationSettings());
328 void printBinaryInformation(FILE *fp,
329 const IProgramContext &programContext,
330 const BinaryInformationSettings &settings)
334 TextWriter writer(fp);
335 printBinaryInformation(&writer, programContext, settings);
337 GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
340 void printBinaryInformation(TextWriter *writer,
341 const IProgramContext &programContext,
342 const BinaryInformationSettings &settings)
344 // TODO Perhaps the writer could be configured with the prefix and
345 // suffix strings from the settings?
346 const char *prefix = settings.prefix_;
347 const char *suffix = settings.suffix_;
348 const char *precisionString = "";
350 precisionString = " (double precision)";
352 const char *const name = programContext.displayName();
353 if (settings.bGeneratedByHeader_)
355 writer->writeLine(formatString("%sCreated by:%s", prefix, suffix));
357 // TODO: It would be nice to know here whether we are really running a
358 // Gromacs binary or some other binary that is calling Gromacs; we
359 // could then print "%s is part of GROMACS" or some alternative text.
361 = formatString(":-) GROMACS - %s, %s%s (-:", name, gmx_version(), precisionString);
363 = centeringOffset(78 - std::strlen(prefix) - std::strlen(suffix), title.length()) + 1;
364 writer->writeLine(formatString("%s%*c%s%s", prefix, indent, ' ', title.c_str(), suffix));
365 writer->writeLine(formatString("%s%s", prefix, suffix));
366 if (settings.bCopyright_)
368 GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0',
369 "Prefix/suffix not supported with copyright");
370 printCopyright(writer);
371 writer->ensureEmptyLine();
372 // This line is printed again after the copyright notice to make it
373 // appear together with all the other information, so that it is not
374 // necessary to read stuff above the copyright notice.
375 // The line above the copyright notice puts the copyright notice is
377 writer->writeLine(formatString("%sGROMACS: %s, version %s%s%s", prefix, name,
378 gmx_version(), precisionString, suffix));
380 const char *const binaryPath = programContext.fullBinaryPath();
381 if (!gmx::isNullOrEmpty(binaryPath))
383 writer->writeLine(formatString("%sExecutable: %s%s", prefix, binaryPath, suffix));
385 const gmx::InstallationPrefixInfo installPrefix = programContext.installationPrefix();
386 if (!gmx::isNullOrEmpty(installPrefix.path))
388 writer->writeLine(formatString("%sData prefix: %s%s%s", prefix, installPrefix.path,
389 installPrefix.bSourceLayout ? " (source tree)" : "", suffix));
391 const std::string workingDir = Path::getWorkingDirectory();
392 if (!workingDir.empty())
394 writer->writeLine(formatString("%sWorking dir: %s%s", prefix, workingDir.c_str(), suffix));
396 if (settings.bProcessId_)
398 writer->writeLine(formatString("%sProcess ID: %d%s", prefix, gmx_getpid(), suffix));
400 const char *const commandLine = programContext.commandLine();
401 if (!gmx::isNullOrEmpty(commandLine))
403 writer->writeLine(formatString("%sCommand line:%s\n%s %s%s",
404 prefix, suffix, prefix, commandLine, suffix));
406 if (settings.bExtendedInfo_)
408 GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0',
409 "Prefix/suffix not supported with extended info");
410 writer->ensureEmptyLine();
411 gmx_print_version_info(writer);