Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
profiling.cpp
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
8 
9 #ifdef SMITH_USE_CALIPER
10 #include <optional>
11 #endif
12 
15 
16 namespace smith::profiling {
17 
18 #ifdef SMITH_USE_CALIPER
19 namespace {
20 std::optional<cali::ConfigManager> mgr;
21 } // namespace
22 #endif
23 
24 void initialize([[maybe_unused]] MPI_Comm comm, [[maybe_unused]] std::string options)
25 {
26 #ifdef SMITH_USE_ADIAK
27  // Initialize Adiak
28  adiak::init(&comm);
29 
30  adiak::launchdate();
31  adiak::executable();
32  adiak::cmdline();
33  adiak::clustername();
34  adiak::jobsize();
35  adiak::walltime();
36  adiak::cputime();
37  adiak::systime();
38  SMITH_SET_METADATA("smith_version", smith::version(true));
39  SMITH_SET_METADATA("smith_compiler", smith::compiler());
40 #endif
41 
42 #ifdef SMITH_USE_CALIPER
43  // Initialize Caliper
44  mgr = cali::ConfigManager();
45  auto check_result = mgr->check(options.c_str());
46 
47  if (check_result.empty()) {
48  mgr->add(options.c_str());
49  } else {
50  SLIC_WARNING_ROOT("Caliper options invalid, ignoring: " << check_result);
51  }
52 
53  // Defaults, should probably always be enabled
54  mgr->add("runtime-report,spot");
55  mgr->start();
56 #endif
57 }
58 
59 void finalize()
60 {
61 #ifdef SMITH_USE_ADIAK
62  // Finalize Adiak
63  adiak::fini();
64 #endif
65 
66 #ifdef SMITH_USE_CALIPER
67  // Finalize Caliper
68  if (mgr) {
69  mgr->stop();
70  mgr->flush();
71  }
72 
73  mgr.reset();
74 #endif
75 }
76 
77 } // namespace smith::profiling
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...
profiling namespace
Definition: profiling.cpp:16
void initialize([[maybe_unused]] MPI_Comm comm, [[maybe_unused]] std::string options)
Initializes performance monitoring using the Caliper and Adiak libraries.
Definition: profiling.cpp:24
void finalize()
Concludes performance monitoring and writes collected data to a file.
Definition: profiling.cpp:59
std::string version(bool add_SHA)
Returns a string for the version of Smith.
Definition: about.cpp:214
std::string compiler()
Returns a string for the current compiler name and version.
Definition: about.cpp:226
Various helper functions and macros for profiling using Caliper.
#define SMITH_SET_METADATA(name, data)
Definition: profiling.hpp:39