Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
about.cpp
1 // Copyright (c) 2019-2024, Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
8 
9 #include "serac/serac_config.hpp"
10 
11 #include "axom/config.hpp"
12 #include "axom/core.hpp"
13 #include "axom/fmt.hpp"
14 
15 #include "camp/config.hpp"
16 
17 #ifdef SERAC_USE_CALIPER
18 #include "caliper/caliper-config.h"
19 #endif
20 
21 #ifdef SERAC_USE_CONDUIT
22 #include "conduit_config.h"
23 #endif
24 
25 #ifdef SERAC_USE_HDF5
26 #include "hdf5.h"
27 #endif
28 
29 #ifdef SERAC_USE_LUA
30 #include "lua.h"
31 #endif
32 
33 #include "mfem.hpp"
34 
35 #ifdef SERAC_USE_RAJA
36 #include "RAJA/config.hpp"
37 #endif
38 
39 #ifdef SERAC_USE_UMPIRE
40 #include "umpire/Umpire.hpp"
41 #endif
42 
43 #ifdef SERAC_USE_TRIBOL
44 #include "tribol/config.hpp"
45 #endif
46 
47 #include "serac/infrastructure/git_sha.hpp"
50 
51 namespace serac {
52 
53 std::string about()
54 {
55  using namespace axom::fmt;
56  [[maybe_unused]] constexpr std::string_view on = "ON";
57  [[maybe_unused]] constexpr std::string_view off = "OFF";
58 
59  std::string about = "\n";
60 
61  // Version info
62  about += format("Serac Version: {0}\n", version(false));
63  about += format("Git Commit SHA: {0}\n", gitSHA());
64  about += "\n";
65 
66  // General configuration
67 #ifdef SERAC_DEBUG
68  about += format("Debug Build: {0}\n", on);
69 #else
70  about += format("Debug Build: {0}\n", off);
71 #endif
72 
73 #ifdef SERAC_USE_CUDA
74  about += format("CUDA: {0}\n", on);
75 #else
76  about += format("CUDA: {0}\n", off);
77 #endif
78 
79  about += "\n";
80 
81  //------------------------
82  // Libraries
83  //------------------------
84 
85  // Print out version of enabled libraries and list disabled ones by name
86 
87  std::vector<std::string> disabled_libs;
88 
89  about += "Enabled Libraries:\n";
90 
91  // Axom
92  about += format("Axom Version: {0}\n", axom::getVersion());
93 
94  // Camp
95  about += format("Camp Version: {0}\n", CAMP_VERSION);
96 
97  // Caliper
98 #ifdef SERAC_USE_CALIPER
99  about += format("Caliper Version: {0}\n", CALIPER_VERSION);
100 #else
101  disabled_libs.push_back("Caliper");
102 #endif
103 
104  // Conduit
105 #ifdef SERAC_USE_CONDUIT
106  about += format("Conduit Version: {0}\n", CONDUIT_VERSION);
107 #else
108  disabled_libs.push_back("Conduit");
109 #endif
110 
111  // HDF5
112 #ifdef SERAC_USE_HDF5
113  unsigned int h5_maj, h5_min, h5_rel;
114  std::string h5_version;
115  if (H5get_libversion(&h5_maj, &h5_min, &h5_rel) < 0) {
116  SLIC_ERROR("Failed to retrieve HDF5 version.");
117  } else {
118  h5_version = format("{0}.{1}.{2}", h5_maj, h5_min, h5_rel);
119  }
120  about += format("HDF5 Version: {0}\n", h5_version);
121 #else
122  disabled_libs.push_back("HDF5");
123 #endif
124 
125  // Lua
126 #ifdef SERAC_USE_LUA
127  std::string lua_version{LUA_RELEASE};
128  if (axom::utilities::string::startsWith(lua_version, "Lua ")) {
129  lua_version.erase(0, 4);
130  }
131  about += format("Lua Version: {0}\n", lua_version);
132 #else
133  disabled_libs.push_back("Lua");
134 #endif
135 
136  // MFEM
137  const char* mfem_version = mfem::GetVersionStr();
138  if (mfem_version == nullptr) {
139  SLIC_ERROR("Failed to retrieve MFEM version.");
140  }
141  const char* mfem_sha = mfem::GetGitStr();
142  if (mfem_sha == nullptr) {
143  SLIC_ERROR("Failed to retrieve MFEM Git SHA.");
144  }
145  std::string mfem_full_version = std::string(mfem_version);
146  if (axom::utilities::string::startsWith(mfem_full_version, "MFEM ")) {
147  mfem_full_version.erase(0, 5);
148  }
149  if (mfem_sha[0] != '\0') {
150  mfem_full_version += format(" (Git SHA: {0})", mfem_sha);
151  }
152  about += format("MFEM Version: {0}\n", mfem_full_version);
153 
154  // RAJA
155 #ifdef SERAC_USE_RAJA
156  about += format("RAJA Version: {0}.{1}.{2}\n", RAJA_VERSION_MAJOR, RAJA_VERSION_MINOR, RAJA_VERSION_PATCHLEVEL);
157 #else
158  disabled_libs.push_back("RAJA");
159 #endif
160 
161  // Tribol
162 #ifdef SERAC_USE_TRIBOL
163  about += format("Tribol Version: {0}\n", TRIBOL_VERSION_FULL);
164 #else
165  disabled_libs.push_back("Tribol");
166 #endif
167 
168  // Umpire
169 #ifdef SERAC_USE_UMPIRE
170  about += format("Umpire Version: {0}.{1}.{2}\n", umpire::get_major_version(), umpire::get_minor_version(),
171  umpire::get_patch_version());
172 #else
173  disabled_libs.push_back("Umpire");
174 #endif
175 
176  about += "\n";
177 
178  about += "Disabled Libraries:\n";
179  if (disabled_libs.size() == 0) {
180  about += "None\n";
181  } else {
182  for (auto& lib : disabled_libs) {
183  about += lib + "\n";
184  }
185  }
186 
187  return about;
188 }
189 
190 std::string gitSHA() { return SERAC_GIT_SHA; }
191 
193 {
194  // Add header
195  std::string infoMsg = axom::fmt::format("\n{:*^80}\n", "Run Information");
196 
197  infoMsg += axom::fmt::format("{0}: {1}\n", "Version", version());
198  infoMsg += axom::fmt::format("{0}: {1}\n", "User Name", axom::utilities::getUserName());
199  infoMsg += axom::fmt::format("{0}: {1}\n", "Host Name", axom::utilities::getHostName());
200 
201  auto [count, rank] = getMPIInfo();
202  infoMsg += axom::fmt::format("{0}: {1}\n", "MPI Rank Count", count);
203 
204  // Add footer
205  infoMsg += axom::fmt::format("{:*^80}\n", "*");
206 
207  SLIC_INFO_ROOT(infoMsg);
208  serac::logger::flush();
209 }
210 
211 std::string version(bool add_SHA)
212 {
213  std::string version =
214  axom::fmt::format("v{0}.{1}.{2}", SERAC_VERSION_MAJOR, SERAC_VERSION_MINOR, SERAC_VERSION_PATCH);
215 
216  std::string sha = gitSHA();
217  if (add_SHA && !sha.empty()) {
218  version += "-" + sha;
219  }
220 
221  return version;
222 }
223 
224 } // namespace serac
This file contains the interface used for retrieving information about how the driver is configured.
A function intended to be used as part of a driver to initialize common libraries.
This file contains the all the necessary functions and macros required for logging as well as a helpe...
Accelerator functionality.
Definition: serac.cpp:38
std::string version(bool add_SHA)
Returns a string for the version of Serac.
Definition: about.cpp:211
std::string gitSHA()
Returns a string for the Git SHA when the driver was built.
Definition: about.cpp:190
std::pair< int, int > getMPIInfo(MPI_Comm comm)
Returns the number of processes and rank for an MPI communicator.
Definition: initialize.cpp:26
std::string about()
Returns a string about the configuration of Serac.
Definition: about.cpp:53
void printRunInfo()
Outputs basic run information to the screen.
Definition: about.cpp:192