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