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.
settings.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2020, The Regents of the University of California,
4// through Lawrence Berkeley National Laboratory (subject to receipt of any
5// required approvals from the U.S. Dept. of Energy). All rights reserved.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in all
15// copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23// SOFTWARE.
24
25#pragma once
26
27#include "timemory/api.hpp"
28#include "timemory/backends/dmp.hpp"
29#include "timemory/backends/process.hpp"
30#include "timemory/backends/threading.hpp"
33#include "timemory/macros.hpp"
39#include "timemory/tpls/cereal/cereal.hpp"
40
41#include <ctime>
42#include <map>
43#include <set>
44#include <string>
45#include <unordered_map>
46#include <vector>
47
48#if defined(TIMEMORY_UNIX)
49//
50# include <ctime>
51# include <unistd.h>
52//
53extern "C"
54{
55 extern char** environ;
56}
57#endif
58
59namespace tim
60{
61//
62class manager;
63//
64//--------------------------------------------------------------------------------------//
65//
66// settings
67//
68//--------------------------------------------------------------------------------------//
69//
71{
72 friend void timemory_init(int, char**, const std::string&, const std::string&);
73 friend void timemory_finalize();
74
75 // this is the list of the current and potentially used data types
77 tim::type_list<bool, string_t, int16_t, int32_t, int64_t, uint16_t, uint32_t,
78 uint64_t, size_t, float, double>;
79 friend class manager;
80 using strvector_t = std::vector<std::string>;
81 using value_type = std::shared_ptr<vsettings>;
82 using data_type = std::unordered_map<string_view_t, value_type>;
83 using iterator = typename data_type::iterator;
84 using const_iterator = typename data_type::const_iterator;
85 using pointer_t = std::shared_ptr<settings>;
86
87 template <typename Tp, typename Vp>
88 using tsetting_pointer_t = std::shared_ptr<tsettings<Tp, Vp>>;
89
90 template <typename Tag = TIMEMORY_API>
91 static std::time_t* get_launch_time(Tag = {});
92 template <typename Tag>
93 static TIMEMORY_HOT pointer_t shared_instance() TIMEMORY_VISIBILITY("default");
94 template <typename Tag>
95 static TIMEMORY_HOT settings* instance() TIMEMORY_VISIBILITY("default");
96 static TIMEMORY_HOT pointer_t shared_instance() TIMEMORY_VISIBILITY("default");
97 static TIMEMORY_HOT settings* instance() TIMEMORY_VISIBILITY("default");
98
99 settings();
100 ~settings() = default;
101
102 settings(const settings&);
103 settings(settings&&) noexcept = default;
104
105 settings& operator=(const settings&);
106 settings& operator=(settings&&) noexcept = default;
107
108 void initialize();
109
110 /// the "tag" for settings should generally be the basename of exe
111 void set_tag(std::string _v) { m_tag = std::move(_v); }
112
113 /// the "tag" for settings should generally be the basename of exe
114 std::string get_tag() const;
115
116 /// if the tag is not explicitly set, try to compute it. Otherwise use
117 /// the TIMEMORY_SETTINGS_PREFIX_
119
120 /// returns whether timemory_init has been invoked
121 bool get_initialized() const { return m_initialized; }
122
123 //==================================================================================//
124 //
125 // GENERAL SETTINGS THAT APPLY TO MULTIPLE COMPONENTS
126 //
127 //==================================================================================//
128
235 // stream
237 // signals
242 // miscellaneous ref
245 TIMEMORY_SETTINGS_REFERENCE_DECL(process::id_t, target_pid)
246
247 static strvector_t& command_line() TIMEMORY_VISIBILITY("default");
248 static strvector_t& environment() TIMEMORY_VISIBILITY("default");
249 strvector_t& get_command_line() { return m_command_line; }
250 strvector_t& get_environment() { return m_environment; }
251
252public:
253 TIMEMORY_STATIC_ACCESSOR(bool, use_output_suffix,
254 get_env<bool>("TIMEMORY_USE_OUTPUT_SUFFIX", false))
255#if defined(TIMEMORY_USE_MPI) || defined(TIMEMORY_USE_UPCXX)
257#else
259#endif
260
261 static strvector_t get_global_environment() TIMEMORY_VISIBILITY("default");
262 static string_t tolower(string_t str) TIMEMORY_VISIBILITY("default");
263 static string_t toupper(string_t str) TIMEMORY_VISIBILITY("default");
264 static string_t get_global_input_prefix() TIMEMORY_VISIBILITY("default");
265 static string_t get_global_output_prefix(bool _make_dir = false)
266 TIMEMORY_VISIBILITY("default");
267 static void store_command_line(int argc, char** argv) TIMEMORY_VISIBILITY("default");
269 bool _use_suffix = use_output_suffix(),
271 bool _make_dir = false,
272 std::string _explicit = {})
273 TIMEMORY_VISIBILITY("default");
275 bool _use_suffix = use_output_suffix(),
277 std::string _explicit = {})
278 TIMEMORY_VISIBILITY("default");
279
280 static void parse(settings* = instance<TIMEMORY_API>())
281 TIMEMORY_VISIBILITY("default");
282
283 static void parse(const std::shared_ptr<settings>&) TIMEMORY_VISIBILITY("default");
284
285 static std::string format(std::string _fpath, const std::string& _tag)
286 TIMEMORY_VISIBILITY("hidden");
287 static std::string format(std::string _prefix, std::string _tag, std::string _suffix,
288 std::string _ext) TIMEMORY_VISIBILITY("hidden");
289
290public:
291 template <typename Archive>
292 void load(Archive& ar, unsigned int);
293
294 template <typename Archive>
295 void save(Archive& ar, unsigned int) const;
296
297 template <typename Archive>
298 static void serialize_settings(Archive&);
299
300 template <typename Archive>
301 static void serialize_settings(Archive&, settings&);
302
303 /// read a configuration file
304 bool read(const string_t&);
305 bool read(std::istream&, string_t = "");
306
307 void init_config(bool search_default = true);
308
309public:
310 template <size_t Idx = 0>
311 static int64_t indent_width(int64_t _w = settings::width())
312 TIMEMORY_VISIBILITY("default");
313
314 template <typename Tp, size_t Idx = 0>
315 static int64_t indent_width(int64_t _w = indent_width<Idx>())
316 TIMEMORY_VISIBILITY("default");
317
318public:
319 auto ordering() const { return m_order; }
320 iterator begin() { return m_data.begin(); }
321 iterator end() { return m_data.end(); }
322 const_iterator begin() const { return m_data.cbegin(); }
323 const_iterator end() const { return m_data.cend(); }
324 const_iterator cbegin() const { return m_data.cbegin(); }
325 const_iterator cend() const { return m_data.cend(); }
326
327 template <typename Sp = string_t>
328 auto find(Sp&& _key, bool _exact = true);
329
330 template <typename Tp, typename Sp = string_t>
331 Tp get(Sp&& _key, bool _exact = true);
332
333 template <typename Tp, typename Sp = string_t>
334 bool get(Sp&& _key, Tp& _val, bool _exact);
335
336 template <typename Tp, typename Sp = string_t>
337 bool set(Sp&& _key, Tp&& _val, bool _exact = true);
338
339 /// \fn bool update(const std::string& key, const std::string& val, bool exact)
340 /// \param key Identifier for the setting. Either name, env-name, or command-line opt
341 /// \param val Update value
342 /// \param exact If true, match only options
343 ///
344 /// \brief Update a setting via a string. Returns whether a matching setting
345 /// for the identifier was found (NOT whether the value was actually updated)
346 bool update(const std::string& _key, const std::string& _val, bool _exact = false);
347
348 /// \tparam Tp Data-type of the setting
349 /// \tparam Vp Value-type of the setting (Tp or Tp&)
350 /// \tparam Sp String-type
351 template <typename Tp, typename Vp, typename Sp, typename... Args>
352 auto insert(Sp&& _env, const std::string& _name, const std::string& _desc, Vp _init,
353 Args&&... _args);
354
355 /// \tparam Tp Data-type of the setting
356 /// \tparam Vp Value-type of the setting (Tp or Tp&)
357 /// \tparam Sp String-type
358 template <typename Tp, typename Vp, typename Sp = string_t>
359 auto insert(tsetting_pointer_t<Tp, Vp> _ptr, Sp&& _env = {});
360
361 /// \tparam API Tagged type
362 ///
363 /// \brief Make a copy of the current settings and return a new instance whose values
364 /// can be modified, used, and then discarded. The values modified do not change
365 /// any settings accessed through static methods or the non-templated instance method.
366 /// E.g. `tim::settings::enabled()` will not be affected by changes to settings
367 /// instance returned by this method.
368 template <typename Tag>
369 static pointer_t push();
370
371 /// \tparam API Tagged type
372 ///
373 /// \brief Restore the settings from a previous push operations.
374 template <typename Tag>
375 static pointer_t pop();
376
377protected:
378 template <typename Archive, typename Tp>
379 auto get_serialize_pair() const // NOLINT
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 }
392
393 template <typename Archive, typename... Tail>
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 }
403
404private:
405 using settings_stack_t = std::stack<pointer_t>;
406
407 template <typename Tag>
408 static TIMEMORY_HOT pointer_t& private_shared_instance(
409 enable_if_t<std::is_same<Tag, TIMEMORY_API>::value, int> = 0);
410
411 template <typename Tag>
412 static TIMEMORY_HOT pointer_t& private_shared_instance(
413 enable_if_t<!std::is_same<Tag, TIMEMORY_API>::value, long> = 0);
414
415 template <typename Tag>
416 static settings_stack_t& get_stack()
417 {
418 static auto _instance = settings_stack_t{};
419 return _instance;
420 }
421
422private:
423 bool m_initialized = false;
424 data_type m_data = {};
425 std::string m_tag = {};
426 strvector_t m_order = {};
427 strvector_t m_command_line = {};
428 strvector_t m_environment = get_global_environment();
429 std::set<std::string> m_read_configs = {};
430
431 /// This is set by timemory_init
432 void set_initialized(bool _v) { m_initialized = _v; }
433
434private:
435 void initialize_core() TIMEMORY_VISIBILITY("hidden");
436 void initialize_components() TIMEMORY_VISIBILITY("hidden");
437 void initialize_io() TIMEMORY_VISIBILITY("hidden");
438 void initialize_format() TIMEMORY_VISIBILITY("hidden");
439 void initialize_parallel() TIMEMORY_VISIBILITY("hidden");
440 void initialize_tpls() TIMEMORY_VISIBILITY("hidden");
441 void initialize_roofline() TIMEMORY_VISIBILITY("hidden");
442 void initialize_miscellaneous() TIMEMORY_VISIBILITY("hidden");
443 void initialize_ert() TIMEMORY_VISIBILITY("hidden");
444 void initialize_dart() TIMEMORY_VISIBILITY("hidden");
445
446 static auto& indent_width_map()
447 {
448 static std::map<size_t, std::map<std::type_index, int64_t>> _instance{};
449 return _instance;
450 }
451};
452//
453//--------------------------------------------------------------------------------------//
454//
455template <typename Tag>
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}
462//
463//--------------------------------------------------------------------------------------//
464//
465template <typename Tag>
466std::shared_ptr<settings>& settings::private_shared_instance(
467 enable_if_t<std::is_same<Tag, TIMEMORY_API>::value, int>)
468{
469 // this is the original
470 static std::shared_ptr<settings> _instance = std::make_shared<settings>();
471 return _instance;
472}
473//
474//--------------------------------------------------------------------------------------//
475//
476template <typename Tag>
477std::shared_ptr<settings>& settings::private_shared_instance(
478 enable_if_t<!std::is_same<Tag, TIMEMORY_API>::value, long>)
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}
485//
486//--------------------------------------------------------------------------------------//
487//
488template <typename Tag>
489std::shared_ptr<settings>
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}
502//
503//--------------------------------------------------------------------------------------//
504//
505template <typename Tag>
506std::shared_ptr<settings>
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}
521//
522//--------------------------------------------------------------------------------------//
523//
524template <typename Tag>
525std::shared_ptr<settings>
527{
528 static std::shared_ptr<settings>& _instance = private_shared_instance<Tag>();
529 return _instance;
530}
531//
532//--------------------------------------------------------------------------------------//
533//
534template <typename Tag>
537{
538 return shared_instance<Tag>().get();
539}
540//
541//--------------------------------------------------------------------------------------//
542//
543template <size_t Idx>
544int64_t
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}
552//
553//--------------------------------------------------------------------------------------//
554//
555template <typename Tp, size_t Idx>
556int64_t
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}
564//
565//--------------------------------------------------------------------------------------//
566//
567template <typename Archive>
568void
570{
572 ar(cereal::make_nvp("settings", *settings::instance()));
573}
574//
575//--------------------------------------------------------------------------------------//
576//
577template <typename Archive>
578void
580{
581 ar(cereal::make_nvp("settings", _obj));
582}
583//
584//--------------------------------------------------------------------------------------//
585//
586template <typename Archive>
587void
588settings::load(Archive& ar, unsigned int)
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}
621//
622//--------------------------------------------------------------------------------------//
623//
624template <typename Archive>
625void
626settings::save(Archive& ar, unsigned int) const
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}
647//
648//--------------------------------------------------------------------------------------//
649//
650template <typename Sp>
651inline auto
652settings::find(Sp&& _key, bool _exact)
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}
669//
670//--------------------------------------------------------------------------------------//
671//
672template <typename Tp, typename Sp>
673Tp
674settings::get(Sp&& _key, bool _exact)
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}
689//
690//--------------------------------------------------------------------------------------//
691//
692template <typename Tp, typename Sp>
693bool
694settings::get(Sp&& _key, Tp& _val, bool _exact)
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}
709//
710//----------------------------------------------------------------------------------//
711//
712template <typename Tp, typename Sp>
713bool
714settings::set(Sp&& _key, Tp&& _val, bool _exact)
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}
742//
743//--------------------------------------------------------------------------------------//
744//
745inline bool
746settings::update(const std::string& _key, const std::string& _val, bool _exact)
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}
759//
760//--------------------------------------------------------------------------------------//
761//
762template <typename Tp, typename Vp, typename Sp, typename... Args>
763auto
764settings::insert(Sp&& _env, const std::string& _name, const std::string& _desc, Vp _init,
765 Args&&... _args)
766{
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}
781//
782//--------------------------------------------------------------------------------------//
783//
784template <typename Tp, typename Vp, typename Sp>
785auto
787{
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}
806//
807//--------------------------------------------------------------------------------------//
808//
809} // namespace tim
std::string string_t
Definition: library.cpp:57
STL namespace.
return false
Definition: definition.hpp:326
Definition: kokkosp.cpp:39
dart_count
Definition: settings.cpp:1670
cupti_events
Definition: settings.cpp:1727
timing_precision
Definition: settings.cpp:1647
roofline_mode
Definition: settings.cpp:1732
max_depth
Definition: settings.cpp:1641
diff_output
Definition: settings.cpp:1630
input_path
Definition: settings.cpp:1664
mpip_components
Definition: settings.cpp:1690
cpu_affinity
Definition: settings.cpp:1674
std::array< char *, 4 > _args
input_prefix
Definition: settings.cpp:1665
papi_multiplexing
Definition: settings.cpp:1711
upcxx_finalize
Definition: settings.cpp:1707
ert_num_streams
Definition: settings.cpp:1756
char const std::string & _prefix
Definition: config.cpp:55
mpi_thread_type
Definition: settings.cpp:1704
ert_min_working_size
Definition: settings.cpp:1764
separator_frequency
Definition: settings.cpp:1785
enable_signal_handler
Definition: settings.cpp:1788
std::string string_view_t
Definition: language.hpp:102
cpu_roofline_mode
Definition: settings.cpp:1734
ert_grid_size
Definition: settings.cpp:1758
throttle_value
Definition: settings.cpp:1680
flat_profile
Definition: settings.cpp:1797
max_thread_bookmarks
Definition: settings.cpp:1672
papi_events
Definition: settings.cpp:1716
void set_env(const std::string &env_var, const Tp &_val, int override)
std::unique_lock< mutex_t > auto_lock_t
Unique lock type around mutex_t.
Definition: locking.hpp:42
gpu_roofline_events
Definition: settings.cpp:1740
ert_max_data_size
Definition: settings.cpp:1770
ert_min_working_size_cpu
Definition: settings.cpp:1766
time_format
Definition: settings.cpp:1642
ert_num_threads_gpu
Definition: settings.cpp:1754
node_count
Definition: settings.cpp:1780
memory_scientific
Definition: settings.cpp:1659
add_secondary
Definition: settings.cpp:1677
tree_output
Definition: settings.cpp:1626
ert_max_data_size_gpu
Definition: settings.cpp:1774
profiler_components
Definition: settings.cpp:1696
papi_overflow
Definition: settings.cpp:1718
std::string string_t
Definition: utility.hpp:98
text_output
Definition: settings.cpp:1624
json_output
Definition: settings.cpp:1625
upcxx_init
Definition: settings.cpp:1706
list_components
Definition: settings.cpp:1686
timing_width
Definition: settings.cpp:1649
typename std::decay< T >::type decay_t
Alias template for decay.
Definition: types.hpp:194
cupti_activity_kinds
Definition: settings.cpp:1725
collapse_threads
Definition: settings.cpp:1637
allow_signal_handler
Definition: settings.cpp:1790
ert_alignment
Definition: settings.cpp:1762
cpu_roofline_events
Definition: settings.cpp:1738
typename std::enable_if< B, T >::type enable_if_t
Alias template for enable_if.
Definition: types.hpp:190
memory_units
Definition: settings.cpp:1657
instruction_roofline
Definition: settings.cpp:1748
suppress_parsing
Definition: settings.cpp:1616
papi_attach
Definition: settings.cpp:1717
scientific
Definition: settings.cpp:1646
tuple_components
Definition: settings.cpp:1684
ert_min_working_size_gpu
Definition: settings.cpp:1768
output_prefix
Definition: settings.cpp:1662
craypat_categories
Definition: settings.cpp:1778
char ** argv
Definition: config.cpp:55
timing_units
Definition: settings.cpp:1650
suppress_config
Definition: settings.cpp:1618
ompt_components
Definition: settings.cpp:1688
ert_block_size
Definition: settings.cpp:1760
cupti_activity_level
Definition: settings.cpp:1723
ert_num_threads_cpu
Definition: settings.cpp:1752
papi_threading
Definition: settings.cpp:1709
file_output
Definition: settings.cpp:1623
disable_all_signals
Definition: settings.cpp:1794
cupti_metrics
Definition: settings.cpp:1729
time_output
Definition: settings.cpp:1628
ert_max_data_size_cpu
Definition: settings.cpp:1772
enable_all_signals
Definition: settings.cpp:1792
tim::mpl::apply< std::string > string
Definition: macros.hpp:53
cupti_device
Definition: settings.cpp:1731
dart_label
Definition: settings.cpp:1671
roofline_type_labels_gpu
Definition: settings.cpp:1746
ncclp_components
Definition: settings.cpp:1692
dart_output
Definition: settings.cpp:1627
ert_num_threads
Definition: settings.cpp:1750
python_exe
Definition: settings.cpp:1783
output_path
Definition: settings.cpp:1661
roofline_type_labels
Definition: settings.cpp:1742
input_extensions
Definition: settings.cpp:1667
cuda_event_batch_size
Definition: settings.cpp:1719
auto_output
Definition: settings.cpp:1621
mpi_init
Definition: settings.cpp:1701
collapse_processes
Definition: settings.cpp:1639
precision
Definition: settings.cpp:1643
memory_precision
Definition: settings.cpp:1654
typename impl::is_one_of< Tp, Types > is_one_of
check if type is in expansion
Definition: types.hpp:777
stack_clearing
Definition: settings.cpp:1675
papi_fail_on_error
Definition: settings.cpp:1713
papi_quiet
Definition: settings.cpp:1715
roofline_type_labels_cpu
Definition: settings.cpp:1744
cout_output
Definition: settings.cpp:1622
ctest_notes
Definition: settings.cpp:1633
destructor_report
Definition: settings.cpp:1781
throttle_count
Definition: settings.cpp:1678
max_width
Definition: settings.cpp:1645
mpi_finalize
Definition: settings.cpp:1702
gpu_roofline_mode
Definition: settings.cpp:1736
timeline_profile
Definition: settings.cpp:1798
memory_width
Definition: settings.cpp:1656
dart_type
Definition: settings.cpp:1669
flamegraph_output
Definition: settings.cpp:1631
nvtx_marker_device_sync
Definition: settings.cpp:1721
timing_scientific
Definition: settings.cpp:1652
trace_components
Definition: settings.cpp:1694
global_components
Definition: settings.cpp:1682
components
Definition: settings.cpp:1700
ert_skip_ops
Definition: settings.cpp:1776
kokkos_components
Definition: settings.cpp:1698
plot_output
Definition: settings.cpp:1629
void consume_parameters(ArgsT &&...)
Definition: types.hpp:285
mpi_thread
Definition: settings.cpp:1703
char const std::string const std::string & _suffix
Definition: config.cpp:57
lightweight tuple-alternative for meta-programming logic
Definition: types.hpp:233
char ** environ
bool read(const string_t &)
read a configuration file
Definition: settings.cpp:1325
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 w...
Definition: settings.hpp:746
static pointer_t shared_instance()
void save(Archive &ar, unsigned int) const
Definition: settings.hpp:626
static void store_command_line(int argc, char **argv)
Definition: settings.cpp:211
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={})
Definition: settings.cpp:322
static string_t get_global_output_prefix(bool _make_dir=false)
Definition: settings.cpp:169
typename data_type::const_iterator const_iterator
Definition: settings.hpp:84
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={})
Definition: settings.cpp:363
Tp get(Sp &&_key, bool _exact=true)
Definition: settings.hpp:674
auto find(Sp &&_key, bool _exact=true)
Definition: settings.hpp:652
static std::time_t * get_launch_time(Tag={})
Definition: settings.hpp:456
TIMEMORY_STATIC_ACCESSOR(bool, use_output_suffix, get_env< bool >("TIMEMORY_USE_OUTPUT_SUFFIX", false)) TIMEMORY_STATIC_ACCESSOR(int32_t
const_iterator end() const
Definition: settings.hpp:323
std::shared_ptr< settings > pointer_t
Definition: settings.hpp:85
iterator end()
Definition: settings.hpp:321
auto ordering() const
Definition: settings.hpp:319
static void serialize_settings(Archive &)
Definition: settings.hpp:569
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
void initialize()
Definition: settings.cpp:1303
static string_t toupper(string_t str)
Definition: settings.cpp:146
static string_t get_global_input_prefix()
Definition: settings.cpp:157
typename data_type::iterator iterator
Definition: settings.hpp:83
auto insert(Sp &&_env, const std::string &_name, const std::string &_desc, Vp _init, Args &&... _args)
Definition: settings.hpp:764
const_iterator cend() const
Definition: settings.hpp:325
auto get_serialize_pair() const
Definition: settings.hpp:379
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
friend void timemory_finalize()
finalization of the specified types
iterator begin()
Definition: settings.hpp:320
static pointer_t pop()
Restore the settings from a previous push operations.
bool get_initialized() const
returns whether timemory_init has been invoked
Definition: settings.hpp:121
strvector_t & get_command_line()
Definition: settings.hpp:249
TIMEMORY_SETTINGS_MEMBER_DECL(string_t, config_file) TIMEMORY_SETTINGS_MEMBER_DECL(bool
std::shared_ptr< tsettings< Tp, Vp > > tsetting_pointer_t
Definition: settings.hpp:88
std::shared_ptr< vsettings > value_type
Definition: settings.hpp:81
std::unordered_map< string_view_t, value_type > data_type
Definition: settings.hpp:82
bool set(Sp &&_key, Tp &&_val, bool _exact=true)
Definition: settings.hpp:714
static int64_t indent_width(int64_t _w=settings::width())
Definition: settings.hpp:545
void set_tag(std::string _v)
the "tag" for settings should generally be the basename of exe
Definition: settings.hpp:111
strvector_t & get_environment()
Definition: settings.hpp:250
static void parse(settings *=instance< TIMEMORY_API >())
Definition: settings.cpp:410
const_iterator begin() const
Definition: settings.hpp:322
const_iterator cbegin() const
Definition: settings.hpp:324
static settings * instance()
Definition: settings.hpp:536
friend void timemory_init(int, char **, const std::string &, const std::string &)
initialization (creates manager and configures output path)
static std::string format(std::string _fpath, const std::string &_tag)
Definition: settings.cpp:222
auto get_serialize_map(tim::type_list< Tail... >) const
Definition: settings.hpp:394
void init_config(bool search_default=true)
Definition: settings.cpp:1573
static pointer_t push()
Make a copy of the current settings and return a new instance whose values can be modified,...
std::vector< std::string > strvector_t
Definition: settings.hpp:80
void load(Archive &ar, unsigned int)
Definition: settings.hpp:588
static string_t tolower(string_t str)
Definition: settings.cpp:135
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_t & environment()
Definition: settings.cpp:91
std::string get_tag() const
the "tag" for settings should generally be the basename of exe
Definition: settings.cpp:547
Implements a specific setting.
Definition: tsettings.hpp:56
void set(Tp)
Definition: tsettings.hpp:220
#define PRINT_HERE(...)
Definition: macros.hpp:152
#define TIMEMORY_FOLD_EXPRESSION(...)
Definition: types.hpp:56
typename typename typename
Definition: types.hpp:226