Loading...
Searching...
No Matches
info.hpp
Go to the documentation of this file.
1
2#pragma once
3#include <filesystem>
4
6#include "table.hpp"
7
8namespace terra::util {
9
10/// @brief Prints some general information for this run to out.
11inline void print_general_info( int argc, char** argv, std::ostream& out = logroot )
12{
13 using clock = std::chrono::system_clock;
14 const auto now = clock::now();
15 const auto now_c = clock::to_time_t( now );
16
17 out << "=========================================\n";
18 out << " TerraNeo - Run Info \n";
19 out << "=========================================\n";
20
21 out << "Wall time start : " << std::put_time( std::localtime( &now_c ), "%Y-%m-%d %H:%M:%S" ) << "\n";
22
23 // Binary path and working directory
24 try
25 {
26 std::filesystem::path bin_path( argv[0] );
27 bin_path = std::filesystem::absolute( bin_path );
28 out << "Executable path : " << bin_path << "\n";
29 out << "Executable dir : " << bin_path.parent_path() << "\n";
30 out << "Working dir : " << std::filesystem::current_path() << "\n";
31 }
32 catch ( ... )
33 {
34 out << "Executable path : (unavailable)\n";
35 }
36
37 // Command-line arguments
38 out << "Command line :";
39 for ( int i = 0; i < argc; ++i )
40 {
41 out << " " << argv[i];
42 }
43 out << "\n";
44
45 // Parallel resources
46 const auto threads = Kokkos::num_threads();
47 const auto devices = Kokkos::num_devices();
48 const auto mpi_procs = mpi::num_processes();
49 const auto mpi_rank = mpi::rank();
50
51 out << "MPI processes : " << mpi_procs << "\n";
52 out << "MPI rank : " << mpi_rank << "\n";
53 out << "Kokkos threads : " << threads << "\n";
54 out << "Kokkos devices : " << devices << "\n";
55 // Kokkos defaults
56 using ExecSpace = Kokkos::DefaultExecutionSpace;
57 using MemSpace = ExecSpace::memory_space;
58 out << "ExecSpace : " << ExecSpace::name() << "\n";
59 out << "MemSpace : " << MemSpace::name() << "\n";
60
61 // Optional: print host/system info if available
62#if defined( __linux__ )
63 char hostname[256];
64 if ( gethostname( hostname, sizeof( hostname ) ) == 0 )
65 {
66 logall << "Rank " << mpi_rank << ": device id = " << Kokkos::device_id() << ", node = " << hostname << std::endl;
67 }
68#endif
69
70 // Separator footer
71 out << "=========================================\n" << std::endl;
72}
73
74} // namespace terra::util
int num_processes()
Definition mpi.hpp:17
MPIRank rank()
Definition mpi.hpp:10
Definition solver.hpp:9
detail::PrefixCout logall([]() { return detail::log_prefix();}, false)
std::ostream subclass that just logs on any process and adds a timestamp for each line.
void print_general_info(int argc, char **argv, std::ostream &out=logroot)
Prints some general information for this run to out.
Definition info.hpp:11
detail::PrefixCout logroot([]() { return detail::log_prefix();})
std::ostream subclass that just logs on root and adds a timestamp for each line.