timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::settings Struct Reference

#include "timemory/settings/settings.hpp"

+ Collaboration diagram for tim::settings:

Public Types

using data_type_list_t = tim::type_list< bool, string_t, int16_t, int32_t, int64_t, uint16_t, uint32_t, uint64_t, size_t, float, double >
 
using strvector_t = std::vector< std::string >
 
using value_type = std::shared_ptr< vsettings >
 
using data_type = std::unordered_map< string_view_t, value_type >
 
using iterator = typename data_type::iterator
 
using const_iterator = typename data_type::const_iterator
 
using pointer_t = std::shared_ptr< settings >
 
template<typename Tp , typename Vp >
using tsetting_pointer_t = std::shared_ptr< tsettings< Tp, Vp > >
 

Public Member Functions

 settings ()
 
 ~settings ()=default
 
 settings (const settings &)
 
 settings (settings &&) noexcept=default
 
settingsoperator= (const settings &)
 
settingsoperator= (settings &&) noexcept=default
 
void initialize ()
 
void set_tag (std::string _v)
 the "tag" for settings should generally be the basename of exe More...
 
std::string get_tag () const
 the "tag" for settings should generally be the basename of exe More...
 
bool get_initialized () const
 returns whether timemory_init has been invoked More...
 
 TIMEMORY_SETTINGS_MEMBER_DECL (string_t, config_file) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing TIMEMORY_SETTINGS_MEMBER_DECL (bool, suppress_config) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled TIMEMORY_SETTINGS_MEMBER_DECL (bool, auto_output) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output TIMEMORY_SETTINGS_MEMBER_DECL (bool, file_output) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output TIMEMORY_SETTINGS_MEMBER_DECL (bool, json_output) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output TIMEMORY_SETTINGS_MEMBER_DECL (bool, dart_output) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output TIMEMORY_SETTINGS_MEMBER_DECL (bool, plot_output) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output TIMEMORY_SETTINGS_MEMBER_DECL (bool, flamegraph_output) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes TIMEMORY_SETTINGS_MEMBER_DECL (int, verbose) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug TIMEMORY_SETTINGS_MEMBER_DECL (bool, banner) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads TIMEMORY_SETTINGS_MEMBER_DECL (bool, collapse_processes) TIMEMORY_SETTINGS_MEMBER_DECL(uint16_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth TIMEMORY_SETTINGS_MEMBER_DECL (string_t, time_format) TIMEMORY_SETTINGS_MEMBER_DECL(int16_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision TIMEMORY_SETTINGS_MEMBER_DECL (int16_t, width) TIMEMORY_SETTINGS_MEMBER_DECL(int32_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width TIMEMORY_SETTINGS_MEMBER_DECL (bool, scientific) TIMEMORY_SETTINGS_MEMBER_DECL(int16_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision TIMEMORY_SETTINGS_MEMBER_DECL (int16_t, timing_width) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units TIMEMORY_SETTINGS_MEMBER_DECL (bool, timing_scientific) TIMEMORY_SETTINGS_MEMBER_DECL(int16_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision TIMEMORY_SETTINGS_MEMBER_DECL (int16_t, memory_width) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units TIMEMORY_SETTINGS_MEMBER_DECL (bool, memory_scientific) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path TIMEMORY_SETTINGS_MEMBER_DECL (string_t, output_prefix) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path TIMEMORY_SETTINGS_MEMBER_DECL (string_t, input_prefix) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions TIMEMORY_SETTINGS_MEMBER_DECL (string_t, dart_type) TIMEMORY_SETTINGS_MEMBER_DECL(uint64_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count TIMEMORY_SETTINGS_MEMBER_DECL (bool, dart_label) TIMEMORY_SETTINGS_MEMBER_DECL(size_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks TIMEMORY_SETTINGS_MEMBER_DECL (bool, cpu_affinity) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing TIMEMORY_SETTINGS_MEMBER_DECL (bool, add_secondary) TIMEMORY_SETTINGS_MEMBER_DECL(size_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count TIMEMORY_SETTINGS_MEMBER_DECL (size_t, throttle_value) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components TIMEMORY_SETTINGS_MEMBER_DECL (string_t, tuple_components) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components TIMEMORY_SETTINGS_MEMBER_DECL (string_t, ompt_components) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components TIMEMORY_SETTINGS_MEMBER_DECL (string_t, ncclp_components) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components TIMEMORY_SETTINGS_MEMBER_DECL (string_t, profiler_components) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components TIMEMORY_SETTINGS_MEMBER_DECL (string_t, components) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init TIMEMORY_SETTINGS_MEMBER_DECL (bool, mpi_finalize) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread TIMEMORY_SETTINGS_MEMBER_DECL (string_t, mpi_thread_type) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init TIMEMORY_SETTINGS_MEMBER_DECL (bool, upcxx_finalize) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading TIMEMORY_SETTINGS_MEMBER_DECL (bool, papi_multiplexing) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error TIMEMORY_SETTINGS_MEMBER_DECL (bool, papi_quiet) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events TIMEMORY_SETTINGS_MEMBER_DECL (bool, papi_attach) TIMEMORY_SETTINGS_MEMBER_DECL(int
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, cuda_event_batch_size) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync TIMEMORY_SETTINGS_MEMBER_DECL (int32_t, cupti_activity_level) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds TIMEMORY_SETTINGS_MEMBER_DECL (string_t, cupti_events) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics TIMEMORY_SETTINGS_MEMBER_DECL (int, cupti_device) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode TIMEMORY_SETTINGS_MEMBER_DECL (string_t, cpu_roofline_mode) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode TIMEMORY_SETTINGS_MEMBER_DECL (string_t, cpu_roofline_events) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events TIMEMORY_SETTINGS_MEMBER_DECL (bool, roofline_type_labels) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu TIMEMORY_SETTINGS_MEMBER_DECL (bool, roofline_type_labels_gpu) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, ert_num_threads) TIMEMORY_SETTINGS_MEMBER_DECL(uint64_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, ert_num_threads_gpu) TIMEMORY_SETTINGS_MEMBER_DECL(uint64_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, ert_grid_size) TIMEMORY_SETTINGS_MEMBER_DECL(uint64_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, ert_alignment) TIMEMORY_SETTINGS_MEMBER_DECL(uint64_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, ert_min_working_size_cpu) TIMEMORY_SETTINGS_MEMBER_DECL(uint64_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, ert_max_data_size) TIMEMORY_SETTINGS_MEMBER_DECL(uint64_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu ert_max_data_size_cpu TIMEMORY_SETTINGS_MEMBER_DECL (uint64_t, ert_max_data_size_gpu) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu ert_max_data_size_cpu ert_skip_ops TIMEMORY_SETTINGS_MEMBER_DECL (string_t, craypat_categories) TIMEMORY_SETTINGS_MEMBER_DECL(int32_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu ert_max_data_size_cpu ert_skip_ops node_count TIMEMORY_SETTINGS_MEMBER_DECL (bool, destructor_report) TIMEMORY_SETTINGS_MEMBER_DECL(string_t
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu ert_max_data_size_cpu ert_skip_ops node_count python_exe TIMEMORY_SETTINGS_MEMBER_DECL (int64_t, separator_frequency) TIMEMORY_SETTINGS_MEMBER_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu ert_max_data_size_cpu ert_skip_ops node_count python_exe enable_signal_handler TIMEMORY_SETTINGS_REFERENCE_DECL (bool, allow_signal_handler) TIMEMORY_SETTINGS_REFERENCE_DECL(bool
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu ert_max_data_size_cpu ert_skip_ops node_count python_exe enable_signal_handler enable_all_signals TIMEMORY_SETTINGS_REFERENCE_DECL (bool, disable_all_signals) TIMEMORY_SETTINGS_REFERENCE_DECL(bool
 
strvector_tget_command_line ()
 
strvector_tget_environment ()
 
 TIMEMORY_STATIC_ACCESSOR (bool, use_output_suffix, get_env< bool >("TIMEMORY_USE_OUTPUT_SUFFIX", false)) TIMEMORY_STATIC_ACCESSOR(int32_t
 
 process::get_id ()) static strvector_t get_global_environment()
 
template<typename Archive >
void load (Archive &ar, unsigned int)
 
template<typename Archive >
void save (Archive &ar, unsigned int) const
 
bool read (const string_t &)
 read a configuration file More...
 
bool read (std::istream &, string_t="")
 
void init_config (bool search_default=true)
 
auto ordering () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
template<typename Sp = string_t>
auto find (Sp &&_key, bool _exact=true)
 
template<typename Tp , typename Sp = string_t>
Tp get (Sp &&_key, bool _exact=true)
 
template<typename Tp , typename Sp = string_t>
bool get (Sp &&_key, Tp &_val, bool _exact)
 
template<typename Tp , typename Sp = string_t>
bool set (Sp &&_key, Tp &&_val, bool _exact=true)
 
bool update (const std::string &_key, const std::string &_val, bool _exact=false)
 Update a setting via a string. Returns whether a matching setting for the identifier was found (NOT whether the value was actually updated) More...
 
template<typename Tp , typename Vp , typename Sp , typename... Args>
auto insert (Sp &&_env, const std::string &_name, const std::string &_desc, Vp _init, Args &&... _args)
 
template<typename Tp , typename Vp , typename Sp = string_t>
auto insert (tsetting_pointer_t< Tp, Vp > _ptr, Sp &&_env={})
 
template<typename Tag >
std::shared_ptr< settings > & private_shared_instance (enable_if_t< std::is_same< Tag, TIMEMORY_API >::value, int >)
 
template<typename Tag >
std::shared_ptr< settings > & private_shared_instance (enable_if_t<!std::is_same< Tag, TIMEMORY_API >::value, long >)
 
template<typename Tag >
std::shared_ptr< settingspush ()
 
template<typename Tag >
std::shared_ptr< settingspop ()
 
template<typename Tag >
std::shared_ptr< settingsshared_instance ()
 

Static Public Member Functions

template<typename Tag = TIMEMORY_API>
static std::time_t * get_launch_time (Tag={})
 
template<typename Tag >
static pointer_t shared_instance ()
 
template<typename Tag >
static settingsinstance ()
 
static pointer_t shared_instance ()
 
static settingsinstance ()
 
static std::string get_fallback_tag ()
 if the tag is not explicitly set, try to compute it. Otherwise use the TIMEMORY_SETTINGS_PREFIX_ More...
 
suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug collapse_threads max_depth precision max_width timing_precision timing_units memory_precision memory_units output_path input_path input_extensions dart_count max_thread_bookmarks stack_clearing throttle_count global_components list_components mpip_components trace_components kokkos_components mpi_init mpi_thread upcxx_init papi_threading papi_fail_on_error papi_events papi_overflow nvtx_marker_device_sync cupti_activity_kinds cupti_metrics roofline_mode gpu_roofline_mode gpu_roofline_events roofline_type_labels_cpu instruction_roofline ert_num_threads_cpu ert_num_streams ert_block_size ert_min_working_size ert_min_working_size_gpu ert_max_data_size_cpu ert_skip_ops node_count python_exe enable_signal_handler enable_all_signals flat_profile static TIMEMORY_SETTINGS_REFERENCE_DECL(bool, timeline_profile) TIMEMORY_SETTINGS_REFERENCE_DECL(process strvector_tenvironment ()
 
static string_t tolower (string_t str)
 
static string_t toupper (string_t str)
 
static string_t get_global_input_prefix ()
 
static string_t get_global_output_prefix (bool _make_dir=false)
 
static void store_command_line (int argc, char **argv)
 
static string_t compose_output_filename (string_t _tag, string_t _ext, bool _use_suffix=use_output_suffix(), int32_t _suffix=default_process_suffix(), bool _make_dir=false, std::string _explicit={})
 
static string_t compose_input_filename (string_t _tag, string_t _ext, bool _use_suffix=use_output_suffix(), int32_t _suffix=default_process_suffix(), std::string _explicit={})
 
static void parse (settings *=instance< TIMEMORY_API >())
 
static void parse (const std::shared_ptr< settings > &)
 
static std::string format (std::string _fpath, const std::string &_tag)
 
static std::string format (std::string _prefix, std::string _tag, std::string _suffix, std::string _ext)
 
template<typename Archive >
static void serialize_settings (Archive &)
 
template<typename Archive >
static void serialize_settings (Archive &, settings &)
 
template<size_t Idx = 0>
static int64_t indent_width (int64_t _w=settings::width())
 
template<typename Tp , size_t Idx = 0>
static int64_t indent_width (int64_t _w=indent_width< Idx >())
 
template<typename Tag >
static pointer_t push ()
 Make a copy of the current settings and return a new instance whose values can be modified, used, and then discarded. The values modified do not change any settings accessed through static methods or the non-templated instance method. E.g. tim::settings::enabled() will not be affected by changes to settings instance returned by this method. More...
 
template<typename Tag >
static pointer_t pop ()
 Restore the settings from a previous push operations. More...
 

Public Attributes

 default_process_suffix
 

Protected Member Functions

template<typename Archive , typename Tp >
auto get_serialize_pair () const
 
template<typename Archive , typename... Tail>
auto get_serialize_map (tim::type_list< Tail... >) const
 

Friends

class manager
 
void timemory_init (int, char **, const std::string &, const std::string &)
 initialization (creates manager and configures output path) More...
 
void timemory_finalize ()
 finalization of the specified types More...
 

Detailed Description

Definition at line 70 of file settings.hpp.

Member Typedef Documentation

◆ const_iterator

using tim::settings::const_iterator = typename data_type::const_iterator

Definition at line 84 of file settings.hpp.

◆ data_type

using tim::settings::data_type = std::unordered_map<string_view_t, value_type>

Definition at line 82 of file settings.hpp.

◆ data_type_list_t

using tim::settings::data_type_list_t = tim::type_list<bool, string_t, int16_t, int32_t, int64_t, uint16_t, uint32_t, uint64_t, size_t, float, double>

Definition at line 76 of file settings.hpp.

◆ iterator

using tim::settings::iterator = typename data_type::iterator

Definition at line 83 of file settings.hpp.

◆ pointer_t

using tim::settings::pointer_t = std::shared_ptr<settings>

Definition at line 85 of file settings.hpp.

◆ strvector_t

using tim::settings::strvector_t = std::vector<std::string>

Definition at line 80 of file settings.hpp.

◆ tsetting_pointer_t

template<typename Tp , typename Vp >
using tim::settings::tsetting_pointer_t = std::shared_ptr<tsettings<Tp, Vp> >

Definition at line 88 of file settings.hpp.

◆ value_type

using tim::settings::value_type = std::shared_ptr<vsettings>

Definition at line 81 of file settings.hpp.

Constructor & Destructor Documentation

◆ settings() [1/3]

TIMEMORY_SETTINGS_INLINE tim::settings::settings ( )

Definition at line 438 of file settings.cpp.

439: m_data(data_type{})
440{
441 // PRINT_HERE("%s", "");
442 initialize();
443}
void initialize()
Definition: settings.cpp:1303
std::unordered_map< string_view_t, value_type > data_type
Definition: settings.hpp:82

References initialize().

◆ ~settings()

tim::settings::~settings ( )
default

◆ settings() [2/3]

TIMEMORY_SETTINGS_INLINE tim::settings::settings ( const settings rhs)

Definition at line 448 of file settings.cpp.

449: m_data(data_type{})
450, m_order(rhs.m_order)
451, m_command_line(rhs.m_command_line)
452, m_environment(rhs.m_environment)
453{
454 for(const auto& itr : rhs.m_data)
455 m_data.emplace(itr.first, itr.second->clone());
456 for(auto& itr : m_order)
457 {
458 if(m_data.find(itr) == m_data.end())
459 {
460 auto ritr = rhs.m_data.find(itr);
461 if(ritr == rhs.m_data.end())
462 {
463 TIMEMORY_EXCEPTION(string_t("Error! Missing ordered entry: ") + itr)
464 }
465 else
466 {
467 m_data.emplace(itr, ritr->second->clone());
468 }
469 }
470 }
471}
std::string string_t
Definition: utility.hpp:98
#define TIMEMORY_EXCEPTION(...)
Definition: types.hpp:138

References TIMEMORY_EXCEPTION.

◆ settings() [3/3]

tim::settings::settings ( settings &&  )
defaultnoexcept

Member Function Documentation

◆ begin() [1/2]

iterator tim::settings::begin ( )
inline

Definition at line 320 of file settings.hpp.

320{ return m_data.begin(); }

Referenced by find().

◆ begin() [2/2]

const_iterator tim::settings::begin ( ) const
inline

Definition at line 322 of file settings.hpp.

322{ return m_data.cbegin(); }

◆ cbegin()

const_iterator tim::settings::cbegin ( ) const
inline

Definition at line 324 of file settings.hpp.

324{ return m_data.cbegin(); }

◆ cend()

const_iterator tim::settings::cend ( ) const
inline

Definition at line 325 of file settings.hpp.

325{ return m_data.cend(); }

◆ compose_input_filename()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::compose_input_filename ( string_t  _tag,
string_t  _ext,
bool  _use_suffix = use_output_suffix(),
int32_t  _suffix = default_process_suffix(),
std::string  _explicit = {} 
)
static

Definition at line 363 of file settings.cpp.

365{
366 if(settings::input_path().empty())
368
369 if(settings::input_prefix().empty())
371
372 auto _prefix =
373 (_explicit.length() > 0) ? std::move(_explicit) : get_global_input_prefix();
374
375 auto only_ascii = [](char c) { return isascii(c) == 0; };
376
377 _prefix.erase(std::remove_if(_prefix.begin(), _prefix.end(), only_ascii),
378 _prefix.end());
379
380 auto _suffix = (_use_suffix && _output_suffix >= 0)
381 ? (std::string("-") + std::to_string(_output_suffix))
382 : std::string("");
383
384 // create the path
385 std::string _fpath = format(_prefix, std::move(_tag), _suffix, std::move(_ext));
386
387 return filepath::osrepr(_fpath);
388}
input_path
Definition: settings.cpp:1664
input_prefix
Definition: settings.cpp:1665
char const std::string & _prefix
Definition: config.cpp:55
output_prefix
Definition: settings.cpp:1662
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
output_path
Definition: settings.cpp:1661
char const std::string const std::string & _suffix
Definition: config.cpp:57
static string_t get_global_input_prefix()
Definition: settings.cpp:157
static std::string format(std::string _fpath, const std::string &_tag)
Definition: settings.cpp:222

References tim::_prefix, tim::_suffix, format(), get_global_input_prefix(), tim::input_path, tim::input_prefix, tim::output_path, and tim::output_prefix.

Referenced by tim::operation::finalize::print< Tp, true >::setup().

◆ compose_output_filename()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::compose_output_filename ( string_t  _tag,
string_t  _ext,
bool  _use_suffix = use_output_suffix(),
int32_t  _suffix = default_process_suffix(),
bool  _make_dir = false,
std::string  _explicit = {} 
)
static

Definition at line 322 of file settings.cpp.

325{
326 bool _is_explicit = (!_explicit.empty());
327 // if there isn't an explicit prefix, get the <OUTPUT_PATH>/<OUTPUT_PREFIX>
328 auto _prefix =
329 (!_explicit.empty()) ? std::move(_explicit) : get_global_output_prefix(_make_dir);
330
331 // return on empty
332 if(_prefix.empty())
333 return "";
334
335 auto only_ascii = [](char c) { return isascii(c) == 0; };
336
337 _prefix.erase(std::remove_if(_prefix.begin(), _prefix.end(), only_ascii),
338 _prefix.end());
339
340 // if explicit prefix is provided, then make the directory
341 if(_is_explicit && _make_dir)
342 {
343 auto ret = makedir(_prefix);
344 if(ret != 0)
345 _prefix = filepath::osrepr(std::string("./"));
346 }
347
348 // add the mpi rank if not root
349 auto _suffix = (_use_suffix && _output_suffix >= 0)
350 ? (std::string("-") + std::to_string(_output_suffix))
351 : std::string("");
352
353 // create the path
354 std::string _fpath = format(_prefix, std::move(_tag), _suffix, std::move(_ext));
355
356 return filepath::osrepr(_fpath);
357}
int makedir(std::string _dir, int umask)
Definition: utility.cpp:67
static string_t get_global_output_prefix(bool _make_dir=false)
Definition: settings.cpp:169

References tim::_prefix, tim::_suffix, format(), get_global_output_prefix(), and tim::makedir().

Referenced by tim::operation::finalize::flamegraph< Type >::flamegraph(), tim::component::perfetto_trace::global_finalize(), tim::operation::finalize::ctest_notes_deleter::operator()(), tim::plotting::operation::plot(), tim::ert::serialize(), tim::operation::finalize::print< Tp, true >::setup(), tim::component::gperftools_cpu_profiler::start(), and tim::component::gperftools_heap_profiler::start().

◆ end() [1/2]

iterator tim::settings::end ( )
inline

Definition at line 321 of file settings.hpp.

321{ return m_data.end(); }

Referenced by find().

◆ end() [2/2]

const_iterator tim::settings::end ( ) const
inline

Definition at line 323 of file settings.hpp.

323{ return m_data.cend(); }

◆ environment()

TIMEMORY_SETTINGS_INLINE settings::strvector_t & tim::settings::environment ( )
static

Definition at line 91 of file settings.cpp.

92{
93 return instance()->get_environment();
94}
strvector_t & get_environment()
Definition: settings.hpp:250
static settings * instance()
Definition: settings.hpp:536

References get_environment(), and instance().

◆ find()

template<typename Sp >
auto tim::settings::find ( Sp &&  _key,
bool  _exact = true 
)
inline

Definition at line 652 of file settings.hpp.

653{
654 // exact match to map key
655 auto itr = m_data.find(std::forward<Sp>(_key));
656 if(itr != m_data.end())
657 return itr;
658
659 // match against env_name, name, command-line options
660 for(auto ditr = begin(); ditr != end(); ++ditr)
661 {
662 if(ditr->second && ditr->second->matches(std::forward<Sp>(_key), _exact))
663 return ditr;
664 }
665
666 // not found
667 return m_data.end();
668}
iterator end()
Definition: settings.hpp:321
iterator begin()
Definition: settings.hpp:320

References begin(), and end().

Referenced by get(), set(), and update().

◆ format() [1/2]

TIMEMORY_SETTINGS_INLINE std::string tim::settings::format ( std::string  _fpath,
const std::string &  _tag 
)
static

Definition at line 222 of file settings.cpp.

223{
224 auto& _cmdline = command_line();
225 std::string _arg0_string = {}; // only the first cmdline arg
226 std::string _argv_string = {}; // entire argv cmd
227 std::string _args_string = {}; // cmdline args
228 std::string _argt_string = _tag; // prefix + cmdline args
229 std::string _tag0_string = _tag; // only the basic prefix
230 if(!_cmdline.empty())
231 {
232 _arg0_string += _cmdline.at(0);
233 _argv_string += _cmdline.at(0);
234 for(size_t i = 1; i < _cmdline.size(); ++i)
235 {
236 _argv_string += _cmdline.at(i);
237 _argt_string += _cmdline.at(i);
238 _args_string += _cmdline.at(i);
239 }
240 }
241
242 auto _dmp_size = TIMEMORY_JOIN("", dmp::size());
243 auto _dmp_rank = TIMEMORY_JOIN("", dmp::rank());
244 auto _proc_id = TIMEMORY_JOIN("", process::get_id());
245 auto _slurm_job_id = get_env<std::string>("SLURM_JOB_ID", "0", false);
246 auto _slurm_proc_id = get_env<std::string>("SLURM_PROCID", _dmp_rank, false);
247
248 auto _replace = [&_fpath](const auto& itr) {
249 auto pos = std::string::npos;
250 while((pos = _fpath.find(itr.first)) != std::string::npos)
251 _fpath.replace(pos, itr.first.length(), itr.second);
252 };
253 using strpairinit_t = std::initializer_list<std::pair<std::string, std::string>>;
254 for(auto&& itr : strpairinit_t{ { "--", "-" }, { "__", "_" }, { "//", "/" } })
255 {
256 _replace(itr);
257 }
258
259 if(_fpath.find('%') == std::string::npos)
260 return _fpath;
261
262 for(auto&& itr : strpairinit_t{ { "%arg0%", _arg0_string },
263 { "%arg0_hash%", md5::compute_md5(_arg0_string) },
264 { "%argv%", _arg0_string },
265 { "%argv_hash%", md5::compute_md5(_argv_string) },
266 { "%argt%", _argt_string },
267 { "%argt_hash%", md5::compute_md5(_argt_string) },
268 { "%args%", _args_string },
269 { "%args_hash%", md5::compute_md5(_args_string) },
270 { "%tag%", _tag0_string },
271 { "%tag_hash%", md5::compute_md5(_tag0_string) },
272 { "%pid%", _proc_id },
273 { "%job%", _slurm_job_id },
274 { "%rank%", _slurm_proc_id },
275 { "%size%", _dmp_size },
276 { "%m", md5::compute_md5(_argt_string) },
277 { "%p", _proc_id },
278 { "%j", _slurm_job_id },
279 { "%r", _slurm_proc_id },
280 { "%s", _dmp_size } })
281 {
282 _replace(itr);
283 }
284 return _fpath;
285}
TIMEMORY_UTILITY_INLINE std::string compute_md5(const std::string &inp)
Definition: md5.cpp:404
size_t pos
Definition: config.cpp:102
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:90

References tim::md5::compute_md5(), tim::pos, process::get_id(), and TIMEMORY_JOIN.

Referenced by compose_input_filename(), compose_output_filename(), and format().

◆ format() [2/2]

TIMEMORY_SETTINGS_INLINE std::string tim::settings::format ( std::string  _prefix,
std::string  _tag,
std::string  _suffix,
std::string  _ext 
)
static

Definition at line 291 of file settings.cpp.

293{
294 // add period before extension
295 if(_ext.find('.') != 0)
296 _ext = std::string(".") + _ext;
297
298 // if the tag contains the extension, remove it
299 auto _ext_pos = _tag.length() - _ext.length();
300 if(_tag.find(_ext) == _ext_pos)
301 _tag = _tag.substr(0, _ext_pos);
302
303 auto plast = static_cast<intmax_t>(_prefix.length()) - 1;
304 // add dash if not empty, not ends in '/', and last char is alphanumeric
305 if(!_prefix.empty() && _prefix[plast] != '/' && isalnum(_prefix[plast]) != 0)
306 _prefix += "-";
307
308 settings* _instance = instance();
309 std::string _global_tag = {};
310 if(_instance)
311 _global_tag = _instance->get_tag();
312 else
313 _global_tag = get_fallback_tag();
314
315 return format(_prefix + _tag + std::move(_suffix) + _ext, _global_tag);
316}
static std::string get_fallback_tag()
if the tag is not explicitly set, try to compute it. Otherwise use the TIMEMORY_SETTINGS_PREFIX_
Definition: settings.cpp:510

References tim::_prefix, tim::_suffix, format(), get_fallback_tag(), get_tag(), and instance().

◆ get() [1/2]

template<typename Tp , typename Sp >
Tp tim::settings::get ( Sp &&  _key,
bool  _exact = true 
)

Definition at line 674 of file settings.hpp.

675{
676 auto itr = find(std::forward<Sp>(_key), _exact);
677 if(itr != m_data.end() && itr->second)
678 {
679 auto _vptr = itr->second;
680 auto _tidx = std::type_index(typeid(Tp));
681 auto _vidx = std::type_index(typeid(Tp&));
682 if(_vptr->get_type_index() == _tidx && _vptr->get_value_index() == _tidx)
683 return static_cast<tsettings<Tp, Tp>*>(_vptr.get())->get();
684 if(_vptr->get_type_index() == _tidx && _vptr->get_value_index() == _vidx)
685 return static_cast<tsettings<Tp, Tp&>*>(_vptr.get())->get();
686 }
687 return Tp{};
688}
Tp get(Sp &&_key, bool _exact=true)
Definition: settings.hpp:674
auto find(Sp &&_key, bool _exact=true)
Definition: settings.hpp:652

References find(), and get().

Referenced by get(), and instance().

◆ get() [2/2]

template<typename Tp , typename Sp >
bool tim::settings::get ( Sp &&  _key,
Tp &  _val,
bool  _exact 
)

Definition at line 694 of file settings.hpp.

695{
696 auto itr = find(std::forward<Sp>(_key), _exact);
697 if(itr != m_data.end() && itr->second)
698 {
699 auto _vptr = itr->second;
700 auto _tidx = std::type_index(typeid(Tp));
701 auto _vidx = std::type_index(typeid(Tp&));
702 if(_vptr->get_type_index() == _tidx && _vptr->get_value_index() == _tidx)
703 return ((_val = static_cast<tsettings<Tp, Tp>*>(_vptr.get())->get()), true);
704 if(_vptr->get_type_index() == _tidx && _vptr->get_value_index() == _vidx)
705 return ((_val = static_cast<tsettings<Tp, Tp&>*>(_vptr.get())->get()), true);
706 }
707 return false;
708}

References find(), and tim::tsettings< Tp, Vp >::get().

◆ get_command_line()

strvector_t & tim::settings::get_command_line ( )
inline

Definition at line 249 of file settings.hpp.

249{ return m_command_line; }

◆ get_environment()

strvector_t & tim::settings::get_environment ( )
inline

Definition at line 250 of file settings.hpp.

250{ return m_environment; }

Referenced by environment().

◆ get_fallback_tag()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::get_fallback_tag ( )
static

if the tag is not explicitly set, try to compute it. Otherwise use the TIMEMORY_SETTINGS_PREFIX_

Definition at line 510 of file settings.cpp.

511{
512 std::string _tag = {};
513
514 if(command_line().empty())
515 command_line() = read_command_line(process::get_id());
516
517 if(command_line().empty())
518 {
520 auto _pos = std::string::npos;
521 while((_pos = _tag.find_last_of('_')) == _tag.length() - 1)
522 _tag = _tag.substr(0, _tag.length() - 1);
523 return _tag;
524 }
525
526 _tag = command_line().front();
527
528 while(_tag.find('\\') != std::string::npos)
529 _tag = _tag.substr(_tag.find_last_of('\\') + 1);
530
531 while(_tag.find('/') != std::string::npos)
532 _tag = _tag.substr(_tag.find_last_of('/') + 1);
533
534 for(auto&& itr : { std::string{ ".py" }, std::string{ ".exe" } })
535 {
536 if(_tag.find(itr) != std::string::npos)
537 _tag.erase(_tag.find(itr), itr.length() + 1);
538 }
539
540 return _tag;
541}
std::vector< std::string > read_command_line(pid_t _pid)
Definition: utility.cpp:114
#define TIMEMORY_SETTINGS_PREFIX
Definition: macros.hpp:56

References process::get_id(), tim::read_command_line(), and TIMEMORY_SETTINGS_PREFIX.

Referenced by format(), and get_tag().

◆ get_global_input_prefix()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::get_global_input_prefix ( )
static

Definition at line 157 of file settings.cpp.

158{
159 auto _dir = input_path();
160 auto _prefix = input_prefix();
161
162 return filepath::osrepr(_dir + std::string("/") + _prefix);
163}
const string_t const string_t & _dir
Definition: definition.hpp:52

References tim::plotting::_dir, tim::_prefix, tim::input_path, and tim::input_prefix.

Referenced by compose_input_filename().

◆ get_global_output_prefix()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::get_global_output_prefix ( bool  _make_dir = false)
static

Definition at line 169 of file settings.cpp.

170{
171 static auto* _settings = instance();
172
173 auto _dir = (_settings)
174 ? _settings->get_output_path()
175 : get_env<std::string>(TIMEMORY_SETTINGS_KEY("OUTPUT_PATH"), ".");
176 auto _prefix = (_settings)
177 ? _settings->get_output_prefix()
178 : get_env<std::string>(TIMEMORY_SETTINGS_KEY("OUTPUT_PREFIX"), "");
179 auto _time_output = (_settings)
180 ? _settings->get_time_output()
181 : get_env<bool>(TIMEMORY_SETTINGS_KEY("TIME_OUTPUT"), false);
182 auto _time_format =
183 (_settings)
184 ? _settings->get_time_format()
185 : get_env<std::string>(TIMEMORY_SETTINGS_KEY("TIME_FORMAT"), "%F_%I.%M_%p");
186
187 if(_time_output)
188 {
189 // get the statically stored launch time
190 auto* _launch_time = get_launch_time(TIMEMORY_API{});
191 auto _local_datetime = get_local_datetime(_time_format.c_str(), _launch_time);
192 if(_dir.find(_local_datetime) == std::string::npos)
193 {
194 if(_dir.length() > 0 && _dir[_dir.length() - 1] != '/')
195 _dir += "/";
196 _dir += _local_datetime;
197 }
198 }
199
200 // always return zero if not making dir. if makedir failed, don't prefix with
201 // directory
202 auto ret = (_make_dir) ? makedir(_dir) : 0;
203 return (ret == 0) ? filepath::osrepr(_dir + std::string("/") + _prefix)
204 : filepath::osrepr(std::string("./") + _prefix);
205}
STL namespace.
TIMEMORY_SETTINGS_INLINE std::string get_local_datetime(const char *dt_format, std::time_t *dt_curr)
Definition: settings.cpp:120
char argparse::argument_parser tim::settings * _settings
Definition: config.cpp:255
TIMEMORY_SETTINGS_KEY("SUPPRESS_PARSING")) TIMEMORY_SETTINGS_MEMBER_DEF(bool
static std::time_t * get_launch_time(Tag={})
Definition: settings.hpp:456

References tim::plotting::_dir, tim::_prefix, tim::_settings, get_launch_time(), tim::get_local_datetime(), instance(), tim::makedir(), TIMEMORY_API, and tim::TIMEMORY_SETTINGS_KEY().

Referenced by tim::manager::add_finalizer(), and compose_output_filename().

◆ get_initialized()

bool tim::settings::get_initialized ( ) const
inline

returns whether timemory_init has been invoked

Definition at line 121 of file settings.hpp.

121{ return m_initialized; }

Referenced by insert().

◆ get_launch_time()

template<typename Tag >
std::time_t * tim::settings::get_launch_time ( Tag  = {})
static

Definition at line 456 of file settings.hpp.

457{
458 // statically store the launch time, intentional memory leak
459 static std::time_t* _time = new std::time_t{ std::time(nullptr) };
460 return _time;
461}

Referenced by get_global_output_prefix(), and tim::get_local_datetime().

◆ get_serialize_map()

template<typename Archive , typename... Tail>
auto tim::settings::get_serialize_map ( tim::type_list< Tail... >  ) const
inlineprotected

Definition at line 394 of file settings.hpp.

395 {
396 using serialize_func_t = std::function<void(Archive&, value_type)>;
397 using serialize_map_t = std::map<std::type_index, serialize_func_t>;
398
399 serialize_map_t _val{};
400 TIMEMORY_FOLD_EXPRESSION(_val.insert(get_serialize_pair<Archive, Tail>()));
401 return _val;
402 }
std::shared_ptr< vsettings > value_type
Definition: settings.hpp:81
#define TIMEMORY_FOLD_EXPRESSION(...)
Definition: types.hpp:56

References TIMEMORY_FOLD_EXPRESSION.

◆ get_serialize_pair()

template<typename Archive , typename Tp >
auto tim::settings::get_serialize_pair ( ) const
inlineprotected

Definition at line 379 of file settings.hpp.

380 {
381 using serialize_func_t = std::function<void(Archive&, value_type)>;
382 using serialize_pair_t = std::pair<std::type_index, serialize_func_t>;
383
384 auto _func = [](Archive& _ar, value_type _val) {
385 using Up = tsettings<Tp>;
386 if(!_val)
387 _val = std::make_shared<Up>();
388 _ar(cereal::make_nvp(_val->get_env_name(), *static_cast<Up*>(_val.get())));
389 };
390 return serialize_pair_t{ std::type_index(typeid(Tp)), _func };
391 }

◆ get_tag()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::get_tag ( ) const

the "tag" for settings should generally be the basename of exe

Definition at line 547 of file settings.cpp.

548{
549 if(m_tag.empty())
550 {
551 if(command_line().empty() && !m_command_line.empty())
552 command_line() = m_command_line;
553
554 const_cast<settings*>(this)->m_tag = get_fallback_tag();
555 }
556
557 return m_tag;
558}

References get_fallback_tag().

Referenced by format().

◆ indent_width() [1/2]

template<typename Tp , size_t Idx>
int64_t tim::settings::indent_width ( int64_t  _w = indent_width<Idx>())
static

Definition at line 557 of file settings.hpp.

558{
559 auto _tidx = std::type_index{ typeid(Tp) };
560 auto_lock_t _lk{ type_mutex<settings, TIMEMORY_API>() };
561 auto& _itr = indent_width_map()[Idx][_tidx];
562 return (_itr = std::max<int64_t>(_itr, _w));
563}
std::unique_lock< mutex_t > auto_lock_t
Unique lock type around mutex_t.
Definition: locking.hpp:42

◆ indent_width() [2/2]

template<size_t Idx>
int64_t tim::settings::indent_width ( int64_t  _w = settings::width())
static

Definition at line 545 of file settings.hpp.

546{
547 auto _tidx = std::type_index{ typeid(TIMEMORY_API) };
548 auto_lock_t _lk{ type_mutex<settings, TIMEMORY_API>() };
549 auto& _itr = indent_width_map()[Idx][_tidx];
550 return (_itr = std::max<int64_t>(_itr, _w));
551}

References TIMEMORY_API.

◆ init_config()

TIMEMORY_SETTINGS_INLINE void tim::settings::init_config ( bool  search_default = true)

Definition at line 1573 of file settings.cpp.

1574{
1575 if(get_debug() || get_verbose() > 3)
1576 PRINT_HERE("%s", "");
1577
1578 static const auto _dcfgs = std::set<std::string>{
1579 get_env<string_t>("HOME") + std::string("/.timemory.cfg"),
1580 get_env<string_t>("HOME") + std::string("/.timemory.json"),
1581 get_env<string_t>("HOME") + std::string("/.config/timemory.cfg"),
1582 get_env<string_t>("HOME") + std::string("/.config/timemory.json")
1583 };
1584
1585 auto _cfg = get_config_file();
1586 auto _files = tim::delimit(_cfg, ",;:");
1587 for(const auto& citr : _files)
1588 {
1589 // a previous config file may have suppressed it
1590 if(get_suppress_config())
1591 break;
1592
1593 // skip defaults
1594 if(!_search_default && _dcfgs.find(citr) != _dcfgs.end())
1595 continue;
1596
1597 if(m_read_configs.find(citr) != m_read_configs.end())
1598 continue;
1599
1600 std::ifstream ifs{ citr };
1601 if(ifs)
1602 {
1603 if(read(ifs, citr))
1604 m_read_configs.emplace(citr);
1605 }
1606 else if(_dcfgs.find(citr) == _dcfgs.end())
1607 {
1608 TIMEMORY_EXCEPTION(std::string("Error reading configuration file: ") + citr);
1609 }
1610 }
1611}
ContainerT delimit(const std::string &line, const std::string &delimiters="\"',;: ", PredicateT &&predicate=[](const std::string &s) -> std::string { return s;})
Definition: delimit.hpp:68
bool read(const string_t &)
read a configuration file
Definition: settings.cpp:1325
#define PRINT_HERE(...)
Definition: macros.hpp:152

References tim::delimit(), PRINT_HERE, read(), and TIMEMORY_EXCEPTION.

◆ initialize()

TIMEMORY_SETTINGS_INLINE void tim::settings::initialize ( )

Definition at line 1303 of file settings.cpp.

1304{
1305 // m_data.clear();
1306 if(m_data.empty())
1307 m_data.reserve(160);
1308
1309 initialize_core();
1310 initialize_components();
1311 initialize_io();
1312 initialize_format();
1313 initialize_parallel();
1314 initialize_tpls();
1315 initialize_roofline();
1316 initialize_miscellaneous();
1317 initialize_ert();
1318 initialize_dart();
1319}

Referenced by settings().

◆ insert() [1/2]

template<typename Tp , typename Vp , typename Sp , typename... Args>
auto tim::settings::insert ( Sp &&  _env,
const std::string &  _name,
const std::string &  _desc,
Vp  _init,
Args &&...  _args 
)
Template Parameters
TpData-type of the setting
VpValue-type of the setting (Tp or Tp&)
SpString-type

Definition at line 764 of file settings.hpp.

766{
767 static_assert(is_one_of<Tp, data_type_list_t>::value,
768 "Error! Data type is not supported. See settings::data_type_list_t");
769 static_assert(std::is_same<decay_t<Tp>, decay_t<Vp>>::value,
770 "Error! Initializing value is not the same as the declared type");
771
772 auto _sid = std::string{ std::forward<Sp>(_env) };
773 if(get_initialized()) // don't set env before timemory_init
774 set_env(_sid, _init, 0);
775 m_order.push_back(_sid);
776 return m_data.insert(
777 { string_view_t{ m_order.back() },
778 std::make_shared<tsettings<Tp, Vp>>(_init, _name, _sid, _desc,
779 std::forward<Args>(_args)...) });
780}
std::array< char *, 4 > _args
std::string string_view_t
Definition: language.hpp:102
void set_env(const std::string &env_var, const Tp &_val, int override)
bool get_initialized() const
returns whether timemory_init has been invoked
Definition: settings.hpp:121

References tim::_args, get_initialized(), and tim::set_env().

◆ insert() [2/2]

template<typename Tp , typename Vp , typename Sp >
auto tim::settings::insert ( tsetting_pointer_t< Tp, Vp >  _ptr,
Sp &&  _env = {} 
)
Template Parameters
TpData-type of the setting
VpValue-type of the setting (Tp or Tp&)
SpString-type

Definition at line 786 of file settings.hpp.

787{
788 static_assert(is_one_of<Tp, data_type_list_t>::value,
789 "Error! Data type is not supported. See settings::data_type_list_t");
790 if(_ptr)
791 {
792 auto _sid = std::string{ std::forward<Sp>(_env) };
793 if(_sid.empty())
794 _sid = _ptr->get_env_name();
795 if(!_sid.empty())
796 {
797 if(get_initialized()) // don't set env before timemory_init
798 set_env(_sid, _ptr->as_string(), 0);
799 m_order.push_back(_sid);
800 return m_data.insert({ string_view_t{ m_order.back() }, _ptr });
801 }
802 }
803
804 return std::make_pair(m_data.end(), false);
805}

References get_initialized(), and tim::set_env().

◆ instance() [1/2]

◆ instance() [2/2]

TIMEMORY_SETTINGS_INLINE settings * tim::settings::instance ( )
static

Definition at line 70 of file settings.cpp.

71{
72 // do not take reference to ensure push/pop w/o template parameters do not change
73 // the settings
74 static auto _instance = shared_instance();
75 return _instance.get();
76}
static pointer_t shared_instance()

References shared_instance().

◆ load()

template<typename Archive >
void tim::settings::load ( Archive &  ar,
unsigned int   
)

Definition at line 588 of file settings.hpp.

589{
590#if !defined(TIMEMORY_DISABLE_SETTINGS_SERIALIZATION)
591 using map_type = std::map<std::string, std::shared_ptr<vsettings>>;
592 map_type _data;
593 for(const auto& itr : m_data)
594 _data.insert({ std::string{ itr.first }, itr.second->clone() });
595 auto _map = get_serialize_map<Archive>(data_type_list_t{});
596 for(const auto& itr : _data)
597 {
598 auto mitr = _map.find(itr.second->get_type_index());
599 if(mitr != _map.end())
600 mitr->second(ar, itr.second);
601 }
602 ar(cereal::make_nvp("command_line", m_command_line),
603 cereal::make_nvp("environment", m_environment));
604 for(const auto& itr : _data)
605 {
606 auto ditr = m_data.find(itr.first);
607 if(ditr != m_data.end())
608 {
609 ditr->second->clone(itr.second);
610 }
611 else
612 {
613 m_order.push_back(itr.first);
614 m_data.insert({ m_order.back(), itr.second });
615 }
616 }
617#else
619#endif
620}
void consume_parameters(ArgsT &&...)
Definition: types.hpp:285
tim::type_list< bool, string_t, int16_t, int32_t, int64_t, uint16_t, uint32_t, uint64_t, size_t, float, double > data_type_list_t
Definition: settings.hpp:78

References tim::consume_parameters().

◆ operator=() [1/2]

TIMEMORY_SETTINGS_INLINE settings & tim::settings::operator= ( const settings rhs)

Definition at line 477 of file settings.cpp.

478{
479 // PRINT_HERE("%s", "");
480 if(this == &rhs)
481 return *this;
482
483 for(const auto& itr : rhs.m_data)
484 m_data[itr.first] = itr.second->clone();
485 m_order = rhs.m_order;
486 m_command_line = rhs.m_command_line;
487 m_environment = rhs.m_environment;
488 for(auto& itr : m_order)
489 {
490 if(m_data.find(itr) == m_data.end())
491 {
492 auto ritr = rhs.m_data.find(itr);
493 if(ritr == rhs.m_data.end())
494 {
495 TIMEMORY_EXCEPTION(string_t("Error! Missing ordered entry: ") + itr)
496 }
497 else
498 {
499 m_data.emplace(itr, ritr->second->clone());
500 }
501 }
502 }
503 return *this;
504}

References TIMEMORY_EXCEPTION.

◆ operator=() [2/2]

settings & tim::settings::operator= ( settings &&  )
defaultnoexcept

◆ ordering()

auto tim::settings::ordering ( ) const
inline

Definition at line 319 of file settings.hpp.

319{ return m_order; }

◆ parse() [1/2]

TIMEMORY_SETTINGS_INLINE void tim::settings::parse ( const std::shared_ptr< settings > &  _settings)
static

Definition at line 394 of file settings.cpp.

395{
396 if(_settings)
398}
arg_result get(size_t _idx, Tp &_value)
Definition: argparse.hpp:674
static void parse(settings *=instance< TIMEMORY_API >())
Definition: settings.cpp:410

References tim::_settings, tim::argparse::argument_parser::get(), and parse().

◆ parse() [2/2]

TIMEMORY_SETTINGS_INLINE void tim::settings::parse ( settings _settings = instance<TIMEMORY_API>())
static

Definition at line 410 of file settings.cpp.

411{
412 if(!_settings)
413 {
414 PRINT_HERE("%s", "nullptr to tim::settings");
415 return;
416 }
417
418 if(_settings->get_suppress_parsing())
419 {
420 static auto _once = false;
421 if(!_once)
422 {
423 PRINT_HERE("%s", "settings parsing has been suppressed");
424 _once = true;
425 }
426 return;
427 }
428
429 for(const auto& itr : *_settings)
430 {
431 itr.second->parse();
432 }
433}

References tim::_settings, and PRINT_HERE.

Referenced by tim::if(), parse(), timemory_set_environ(), and timemory_trace_set_env().

◆ pop() [1/2]

template<typename Tag >
static pointer_t tim::settings::pop ( )
static

Restore the settings from a previous push operations.

Template Parameters
APITagged type

◆ pop() [2/2]

template<typename Tag >
std::shared_ptr< settings > tim::settings::pop ( )

Definition at line 507 of file settings.hpp.

508{
509 auto& _stack = get_stack<Tag>();
510 if(_stack.empty())
511 {
512 PRINT_HERE("%s", "Ignoring settings::pop() on empty stack");
513 return shared_instance<Tag>();
514 }
515
516 auto _top = _stack.top();
517 private_shared_instance<Tag>() = _top;
518 _stack.pop();
519 return _top;
520}

References PRINT_HERE.

◆ private_shared_instance() [1/2]

template<typename Tag >
std::shared_ptr< settings > & tim::settings::private_shared_instance ( enable_if_t< std::is_same< Tag, TIMEMORY_API >::value, int >  )

Definition at line 466 of file settings.hpp.

468{
469 // this is the original
470 static std::shared_ptr<settings> _instance = std::make_shared<settings>();
471 return _instance;
472}

◆ private_shared_instance() [2/2]

template<typename Tag >
std::shared_ptr< settings > & tim::settings::private_shared_instance ( enable_if_t<!std::is_same< Tag, TIMEMORY_API >::value, long >  )

Definition at line 477 of file settings.hpp.

479{
480 // make a copy of the original
481 static std::shared_ptr<settings> _instance =
482 std::make_shared<settings>(*private_shared_instance<TIMEMORY_API>());
483 return _instance;
484}

◆ process::get_id()

tim::settings::process::get_id ( )

Referenced by format(), and get_fallback_tag().

◆ push() [1/2]

template<typename Tag >
static pointer_t tim::settings::push ( )
static

Make a copy of the current settings and return a new instance whose values can be modified, used, and then discarded. The values modified do not change any settings accessed through static methods or the non-templated instance method. E.g. tim::settings::enabled() will not be affected by changes to settings instance returned by this method.

Template Parameters
APITagged type

◆ push() [2/2]

template<typename Tag >
std::shared_ptr< settings > tim::settings::push ( )

Definition at line 490 of file settings.hpp.

491{
492 // ensure the non-template methods have their own static copies
493 static auto* _discard_ptr = instance();
494 static auto* _discard_sptr = instance<TIMEMORY_API>();
495 consume_parameters(_discard_ptr, _discard_sptr);
496
497 auto _old = shared_instance<Tag>();
498 get_stack<Tag>().push(_old);
499 private_shared_instance<Tag>() = std::make_shared<settings>(*_old);
500 return private_shared_instance<Tag>();
501}

References tim::consume_parameters(), and instance().

◆ read() [1/2]

TIMEMORY_SETTINGS_INLINE bool tim::settings::read ( const string_t inp)

read a configuration file

Definition at line 1325 of file settings.cpp.

1326{
1327#if defined(TIMEMORY_UNIX)
1328 auto file_exists = [](const std::string& _fname) {
1329 struct stat _buffer;
1330 if(stat(_fname.c_str(), &_buffer) == 0)
1331 return (S_ISREG(_buffer.st_mode) != 0 || S_ISLNK(_buffer.st_mode) != 0);
1332 return false;
1333 };
1334#else
1335 auto file_exists = [](const std::string&) { return true; };
1336#endif
1337
1338 if(file_exists(inp))
1339 {
1340 std::ifstream ifs{ inp };
1341 if(ifs.is_open())
1342 {
1343 return read(ifs, inp);
1344 }
1345 else
1346 {
1347 TIMEMORY_EXCEPTION(string_t("Error reading configuration file: ") + inp)
1348 }
1349 }
1350 return false;
1351}

References read(), and TIMEMORY_EXCEPTION.

Referenced by init_config(), and read().

◆ read() [2/2]

TIMEMORY_SETTINGS_INLINE bool tim::settings::read ( std::istream &  ifs,
string_t  inp = "" 
)

Definition at line 1357 of file settings.cpp.

1358{
1359 if(m_read_configs.find(inp) != m_read_configs.end())
1360 {
1361 PRINT_HERE("Warning! Re-reading config file: %s", inp.c_str());
1362 }
1363 m_read_configs.emplace(inp);
1364
1365 if(inp.find(".json") != std::string::npos || inp == "json")
1366 {
1367 using policy_type = policy::input_archive<cereal::JSONInputArchive, TIMEMORY_API>;
1368 auto ia = policy_type::get(ifs);
1369 try
1370 {
1371 ia->setNextName("timemory");
1372 ia->startNode();
1373 {
1374 try
1375 {
1376 ia->setNextName("metadata");
1377 ia->startNode();
1378 // settings
1379 (*ia)(cereal::make_nvp("settings", *this));
1380 ia->finishNode();
1381 } catch(...)
1382 {
1383 // settings
1384 (*ia)(cereal::make_nvp("settings", *this));
1385 }
1386 }
1387 ia->finishNode();
1388 } catch(tim::cereal::Exception& e)
1389 {
1390 PRINT_HERE("Exception reading %s :: %s", inp.c_str(), e.what());
1391#if defined(TIMEMORY_INTERNAL_TESTING)
1393#endif
1394 return false;
1395 }
1396 return true;
1397 }
1398#if defined(TIMEMORY_USE_XML)
1399 else if(inp.find(".xml") != std::string::npos || inp == "xml")
1400 {
1401 using policy_type = policy::input_archive<cereal::XMLInputArchive, TIMEMORY_API>;
1402 auto ia = policy_type::get(ifs);
1403 ia->setNextName("timemory");
1404 ia->startNode();
1405 {
1406 try
1407 {
1408 ia->setNextName("metadata");
1409 ia->startNode();
1410 // settings
1411 (*ia)(cereal::make_nvp("settings", *this));
1412 ia->finishNode();
1413 } catch(...)
1414 {
1415 // settings
1416 (*ia)(cereal::make_nvp("settings", *this));
1417 }
1418 }
1419 ia->finishNode();
1420 return true;
1421 }
1422#endif
1423 else
1424 {
1425 if(inp.empty())
1426 inp = "text";
1427
1428 auto _is_comment = [](std::string _s) {
1429 if(_s.empty())
1430 return true;
1431 {
1432 auto _spos = _s.find_first_of(" \t\n\r\v\f");
1433 auto _cpos = _s.find_first_not_of(" \t\n\r\v\f");
1434 if(_spos < _cpos && _cpos != std::string::npos)
1435 _s = _s.substr(_cpos);
1436 if(_s.empty())
1437 return true;
1438 }
1439 std::locale _lc{};
1440 for(const auto& itr : _s)
1441 {
1442 // if graphical character is # then it a comment
1443 if(std::isgraph(itr, _lc))
1444 return (itr == '#');
1445 }
1446 // if there were no printable characters, treat as comment
1447 return true;
1448 };
1449
1450 int expected = 0;
1451 int valid = 0;
1452 std::map<std::string, std::string> _variables{};
1453
1454 std::function<std::string(std::string)> _resolve_variable{};
1455 _resolve_variable = [&](std::string _v) {
1456 if(_v.empty())
1457 return _v;
1458 if(_v.at(0) != '$')
1459 return _v;
1460 static const char* _env_syntax = "$env:";
1461 if(_v.find(_env_syntax) == 0)
1462 return _resolve_variable(
1463 get_env<std::string>(_v.substr(strlen(_env_syntax)), ""));
1464 auto vitr = _variables.find(_v);
1465 if(vitr != _variables.end())
1466 return _resolve_variable(vitr->second);
1467 if(_v.at(0) == '$')
1468 _v = _v.substr(1);
1469 for(const auto& itr : *this)
1470 {
1471 if(itr.second->matches(_v))
1472 return _resolve_variable(itr.second->as_string());
1473 }
1474 return _v;
1475 };
1476
1477 while(ifs)
1478 {
1479 std::string line = {};
1480 std::getline(ifs, line);
1481 if(!ifs || line.empty())
1482 continue;
1483 if(line.empty())
1484 continue;
1485 if(get_debug() || get_verbose() > 4)
1486 fprintf(stderr, "[timemory::settings]['%s']> %s\n", inp.c_str(),
1487 line.c_str());
1488 if(_is_comment(line))
1489 continue;
1490 ++expected;
1491 // tokenize the string
1492 auto delim = tim::delimit(line, "\n\t=,; ");
1493 if(!delim.empty())
1494 {
1495 string_t key = delim.front();
1496 string_t val = {};
1497 // combine into another string separated by commas
1498 for(size_t i = 1; i < delim.size(); ++i)
1499 {
1500 if(delim.empty() || delim.at(i) == "#" || delim.at(i).at(0) == '#')
1501 continue;
1502 val += "," + _resolve_variable(delim.at(i));
1503 }
1504 // if there was any fields, remove the leading comma
1505 if(val.length() > 0)
1506 val = val.substr(1);
1507 // extremely unlikely
1508 if(key.empty())
1509 continue;
1510 // handle comment
1511 if(key == "#" || key.at(0) == '#')
1512 continue;
1513 // this is a variable, e.g.:
1514 // $MYVAR = ON # this is a variable
1515 // TIMEMORY_PRINT_STATS = $MYVAR
1516 // TIMEMORY_PRINT_MIN = $MYVAR
1517 if(key.at(0) == '$')
1518 {
1519 _variables.emplace(key, val);
1520 continue;
1521 }
1522
1523 auto incr = valid;
1524 for(const auto& itr : *this)
1525 {
1526 if(itr.second->matches(key))
1527 {
1528 if(get_debug() || get_verbose() > 0)
1529 fprintf(stderr, "[timemory::settings]['%s']> %-30s :: %s\n",
1530 inp.c_str(), key.c_str(), val.c_str());
1531 ++valid;
1532 itr.second->parse(val);
1533 }
1534 }
1535
1536 if(incr == valid)
1537 {
1538 auto _key = key;
1539 for(auto& itr : _key)
1540 itr = std::toupper(itr);
1541 if(_key.find(TIMEMORY_SETTINGS_PREFIX) == 0)
1542 {
1543 if(get_debug() || get_verbose() > 0)
1544 {
1545 fprintf(stderr,
1546 "[timemory::settings]['%s']> Unknown setting with "
1547 "recognized prefix ('%s') exported to environment: "
1548 "'%s' (value = '%s')\n",
1549 inp.c_str(), TIMEMORY_SETTINGS_PREFIX, _key.c_str(),
1550 val.c_str());
1551 }
1552 tim::set_env(key, val, 0);
1553 }
1554 else
1555 {
1556 fprintf(stderr,
1557 "[timemory::settings]['%s']> WARNING! Unknown setting "
1558 "ignored: '%s' (value = '%s')\n",
1559 inp.c_str(), key.c_str(), val.c_str());
1560 }
1561 }
1562 }
1563 }
1564 return (expected == valid);
1565 }
1566 return false;
1567}
std::string string_t
Definition: library.cpp:57
auto get(const auto_bundle< Tag, Types... > &_obj)
#define TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE(CONDITION, DEPTH)
Definition: macros.hpp:202

References tim::delimit(), tim::get(), PRINT_HERE, tim::set_env(), TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE, and TIMEMORY_SETTINGS_PREFIX.

◆ save()

template<typename Archive >
void tim::settings::save ( Archive &  ar,
unsigned int   
) const

Definition at line 626 of file settings.hpp.

627{
628#if !defined(TIMEMORY_DISABLE_SETTINGS_SERIALIZATION)
629 using map_type = std::map<std::string, std::shared_ptr<vsettings>>;
630 map_type _data;
631 for(const auto& itr : m_data)
632 _data.insert({ std::string{ itr.first }, itr.second->clone() });
633
634 auto _map = get_serialize_map<Archive>(data_type_list_t{});
635 for(const auto& itr : _data)
636 {
637 auto mitr = _map.find(itr.second->get_type_index());
638 if(mitr != _map.end())
639 mitr->second(ar, itr.second);
640 }
641 ar(cereal::make_nvp("command_line", m_command_line),
642 cereal::make_nvp("environment", m_environment));
643#else
645#endif
646}

References tim::consume_parameters().

◆ serialize_settings() [1/2]

template<typename Archive >
void tim::settings::serialize_settings ( Archive &  ar)
static

Definition at line 569 of file settings.hpp.

570{
572 ar(cereal::make_nvp("settings", *settings::instance()));
573}

References instance().

◆ serialize_settings() [2/2]

template<typename Archive >
void tim::settings::serialize_settings ( Archive &  ar,
settings _obj 
)
static

Definition at line 579 of file settings.hpp.

580{
581 ar(cereal::make_nvp("settings", _obj));
582}

◆ set()

template<typename Tp , typename Sp >
bool tim::settings::set ( Sp &&  _key,
Tp &&  _val,
bool  _exact = true 
)

Definition at line 714 of file settings.hpp.

715{
716 auto itr = find(std::forward<Sp>(_key), _exact);
717 if(itr != m_data.end() && itr->second)
718 {
719 using Up = decay_t<Tp>;
720 auto _tidx = std::type_index(typeid(Up));
721 auto _vidx = std::type_index(typeid(Up&));
722 auto _tobj = dynamic_cast<tsettings<Up>*>(itr->second.get());
723 auto _robj = dynamic_cast<tsettings<Up, Up&>*>(itr->second.get());
724 if(itr->second->get_type_index() == _tidx &&
725 itr->second->get_value_index() == _tidx && _tobj)
726 {
727 return (_tobj->set(std::forward<Tp>(_val)), true);
728 }
729 else if(itr->second->get_type_index() == _tidx &&
730 itr->second->get_value_index() == _vidx && _robj)
731 {
732 return (_robj->set(std::forward<Tp>(_val)), true);
733 }
734 else
735 {
736 throw std::runtime_error(std::string{ "tim::settings::set(" } +
737 std::string{ _key } + ", ...) failed");
738 }
739 }
740 return false;
741}

References find(), and tim::tsettings< Tp, Vp >::set().

◆ set_tag()

void tim::settings::set_tag ( std::string  _v)
inline

the "tag" for settings should generally be the basename of exe

Definition at line 111 of file settings.hpp.

111{ m_tag = std::move(_v); }

◆ shared_instance() [1/3]

template<typename Tag >
static pointer_t tim::settings::shared_instance ( )
static

Referenced by instance().

◆ shared_instance() [2/3]

TIMEMORY_SETTINGS_INLINE std::shared_ptr< settings > tim::settings::shared_instance ( )
static

Definition at line 58 of file settings.cpp.

59{
60 // do not take reference to ensure push/pop w/o template parameters do not change
61 // the settings
62 static auto _instance = shared_instance<TIMEMORY_API>();
63 return _instance;
64}

◆ shared_instance() [3/3]

template<typename Tag >
std::shared_ptr< settings > tim::settings::shared_instance ( )

Definition at line 526 of file settings.hpp.

527{
528 static std::shared_ptr<settings>& _instance = private_shared_instance<Tag>();
529 return _instance;
530}

◆ store_command_line()

TIMEMORY_SETTINGS_INLINE void tim::settings::store_command_line ( int  argc,
char **  argv 
)
static

Definition at line 211 of file settings.cpp.

212{
213 auto& _cmdline = command_line();
214 _cmdline.clear();
215 for(int i = 0; i < argc; ++i)
216 _cmdline.emplace_back(std::string(argv[i]));
217}
char ** argv
Definition: config.cpp:55

References tim::argv.

Referenced by tim::if().

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [1/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [2/54]

suppress_parsing enabled tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
auto_output   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [3/54]

suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes debug tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
banner   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [4/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [5/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [6/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [7/54]

suppress_parsing enabled cout_output text_output tree_output tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
dart_output   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [8/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [9/54]

suppress_parsing enabled cout_output tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
file_output   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [10/54]

suppress_parsing enabled cout_output text_output tree_output time_output diff_output tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
flamegraph_output   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [11/54]

suppress_parsing enabled cout_output text_output tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
json_output   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [12/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [13/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [14/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [15/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [16/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [17/54]

suppress_parsing enabled cout_output text_output tree_output time_output tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
plot_output   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [18/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [19/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [20/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [21/54]

suppress_parsing tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( bool  ,
suppress_config   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [22/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [23/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [24/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [25/54]

suppress_parsing enabled cout_output text_output tree_output time_output diff_output ctest_notes tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( int  ,
verbose   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [26/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [27/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [28/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [29/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [30/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [31/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [32/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [33/54]

tim::settings::TIMEMORY_SETTINGS_MEMBER_DECL ( string_t  ,
config_file   
)

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [34/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [35/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [36/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [37/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [38/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [39/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [40/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [41/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [42/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [43/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [44/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [45/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [46/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [47/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [48/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [49/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [50/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [51/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [52/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [53/54]

◆ TIMEMORY_SETTINGS_MEMBER_DECL() [54/54]

◆ TIMEMORY_SETTINGS_REFERENCE_DECL() [1/2]

◆ TIMEMORY_SETTINGS_REFERENCE_DECL() [2/2]

◆ TIMEMORY_STATIC_ACCESSOR()

tim::settings::TIMEMORY_STATIC_ACCESSOR ( bool  ,
use_output_suffix  ,
get_env< bool >  "TIMEMORY_USE_OUTPUT_SUFFIX", false 
)

◆ tolower()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::tolower ( string_t  str)
static

Definition at line 135 of file settings.cpp.

136{
137 for(auto& itr : str)
138 itr = ::tolower(itr);
139 return str;
140}
static string_t tolower(string_t str)
Definition: settings.cpp:135

References tolower().

Referenced by tim::runtime::enumerate(), and tolower().

◆ toupper()

TIMEMORY_SETTINGS_INLINE std::string tim::settings::toupper ( string_t  str)
static

Definition at line 146 of file settings.cpp.

147{
148 for(auto& itr : str)
149 itr = ::toupper(itr);
150 return str;
151}
static string_t toupper(string_t str)
Definition: settings.cpp:146

References toupper().

Referenced by toupper().

◆ update()

bool tim::settings::update ( const std::string &  key,
const std::string &  val,
bool  exact = false 
)
inline

Update a setting via a string. Returns whether a matching setting for the identifier was found (NOT whether the value was actually updated)

Parameters
keyIdentifier for the setting. Either name, env-name, or command-line opt
valUpdate value
exactIf true, match only options

Definition at line 746 of file settings.hpp.

747{
748 auto itr = find(_key, _exact);
749 if(itr == m_data.end())
750 {
751 if(get_verbose() > 0 || get_debug())
752 PRINT_HERE("Key: \"%s\" did not match any known setting", _key.c_str());
753 return false;
754 }
755
756 itr->second->parse(_val);
757 return true;
758}

References find(), and PRINT_HERE.

Friends And Related Function Documentation

◆ manager

friend class manager
friend

Definition at line 79 of file settings.hpp.

◆ timemory_finalize

void timemory_finalize ( )
friend

finalization of the specified types

◆ timemory_init

void timemory_init ( int  ,
char **  ,
const std::string &  ,
const std::string &   
)
friend

initialization (creates manager and configures output path)

Member Data Documentation

◆ default_process_suffix

tim::settings::default_process_suffix

Definition at line 258 of file settings.hpp.


The documentation for this struct was generated from the following files: