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.cpp
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#ifndef TIMEMORY_SETTINGS_SETTINGS_CPP_
26#define TIMEMORY_SETTINGS_SETTINGS_CPP_ 1
27
29
30#include "timemory/backends/dmp.hpp"
31#include "timemory/backends/process.hpp"
32#include "timemory/defines.h"
36#include "timemory/tpls/cereal/archives.hpp"
44
45#include <cctype>
46#include <fstream>
47#include <initializer_list>
48#include <locale>
49#include <string>
50
51namespace tim
52{
53//
54//--------------------------------------------------------------------------------------//
55//
57std::shared_ptr<settings>
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}
65//
66//--------------------------------------------------------------------------------------//
67//
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}
77//
78//--------------------------------------------------------------------------------------//
79//
82settings::command_line()
83{
84 return instance()->get_environment();
85}
86//
87//--------------------------------------------------------------------------------------//
88//
92{
93 return instance()->get_environment();
94}
95//
96//--------------------------------------------------------------------------------------//
97//
100settings::get_global_environment()
101{
102#if defined(TIMEMORY_UNIX)
103 strvector_t _environ;
104 if(environ != nullptr)
105 {
106 int idx = 0;
107 while(environ[idx] != nullptr)
108 _environ.push_back(environ[idx++]);
109 }
110 return _environ;
111#else
112 return std::vector<std::string>();
113#endif
114}
115//
116//--------------------------------------------------------------------------------------//
117//
120get_local_datetime(const char* dt_format, std::time_t* dt_curr)
121{
122 char mbstr[512];
123 if(!dt_curr)
125
126 if(std::strftime(mbstr, sizeof(mbstr), dt_format, std::localtime(dt_curr)) != 0)
127 return std::string{ mbstr };
128 return std::string{};
129}
130//
131//--------------------------------------------------------------------------------------//
132//
136{
137 for(auto& itr : str)
138 itr = ::tolower(itr);
139 return str;
140}
141//
142//--------------------------------------------------------------------------------------//
143//
147{
148 for(auto& itr : str)
149 itr = ::toupper(itr);
150 return str;
151}
152//
153//--------------------------------------------------------------------------------------//
154//
158{
159 auto _dir = input_path();
160 auto _prefix = input_prefix();
161
162 return filepath::osrepr(_dir + std::string("/") + _prefix);
163}
164//
165//--------------------------------------------------------------------------------------//
166//
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}
206//
207//--------------------------------------------------------------------------------------//
208//
210void
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}
218//
219//--------------------------------------------------------------------------------------//
220//
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}
286//
287//--------------------------------------------------------------------------------------//
288//
292 std::string _ext)
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}
317//
318//--------------------------------------------------------------------------------------//
319//
323 int32_t _output_suffix, bool _make_dir,
324 std::string _explicit)
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}
358//
359//--------------------------------------------------------------------------------------//
360//
364 int32_t _output_suffix, std::string _explicit)
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}
389//
390//--------------------------------------------------------------------------------------//
391//
393void
394settings::parse(const std::shared_ptr<settings>& _settings)
395{
396 if(_settings)
398}
399//
400//--------------------------------------------------------------------------------------//
401//
402// function to parse the environment for settings
403//
404// Nearly all variables will parse env when first access but this allows provides a
405// way to reparse the environment so that default settings (possibly from previous
406// invocation) can be overwritten
407//
409void
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}
434//
435//--------------------------------------------------------------------------------------//
436//
439: m_data(data_type{})
440{
441 // PRINT_HERE("%s", "");
442 initialize();
443}
444//
445//--------------------------------------------------------------------------------------//
446//
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}
472//
473//--------------------------------------------------------------------------------------//
474//
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}
505//
506//--------------------------------------------------------------------------------------//
507//
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}
542//
543//--------------------------------------------------------------------------------------//
544//
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}
559//
560//--------------------------------------------------------------------------------------//
561//
563void
564settings::initialize_core()
565{
566 // PRINT_HERE("%s", "");
567 auto homedir = get_env<string_t>("HOME");
568
570 string_t, config_file, TIMEMORY_SETTINGS_KEY("CONFIG_FILE"),
571 "Configuration file for timemory",
572 TIMEMORY_JOIN(';', TIMEMORY_JOIN('/', homedir, ".timemory.cfg"),
573 TIMEMORY_JOIN('/', homedir, ".timemory.json"),
574 TIMEMORY_JOIN('/', homedir, ".config", "timemory.cfg"),
575 TIMEMORY_JOIN('/', homedir, ".config", "timemory.json")),
576 strvector_t({ "-C", "--timemory-config" }));
577
579 bool, suppress_config, TIMEMORY_SETTINGS_KEY("SUPPRESS_CONFIG"),
580 "Disable processing of setting configuration files", false,
581 strvector_t({ "--timemory-suppress-config", "--timemory-no-config" }));
582
584 bool, suppress_parsing, TIMEMORY_SETTINGS_KEY("SUPPRESS_PARSING"),
585 "Disable parsing environment", false,
586 strvector_t({ "--timemory-suppress-parsing" }), -1, 1);
587
589 bool, enabled, TIMEMORY_SETTINGS_KEY("ENABLED"), "Activation state of timemory",
590 TIMEMORY_DEFAULT_ENABLED, strvector_t({ "--timemory-enabled" }), -1, 1);
591
593 "Verbosity level", 0,
594 strvector_t({ "--timemory-verbose" }), 1);
595
597 "Enable debug output", false,
598 strvector_t({ "--timemory-debug" }), -1, 1);
599
601 bool, flat_profile, TIMEMORY_SETTINGS_KEY("FLAT_PROFILE"),
602 "Set the label hierarchy mode to default to "
603 "flat",
604 scope::get_fields()[scope::flat::value],
605 strvector_t({ "--timemory-flat-profile" }), -1, 1);
606
608 bool, timeline_profile, TIMEMORY_SETTINGS_KEY("TIMELINE_PROFILE"),
609 "Set the label hierarchy mode to default to timeline",
610 scope::get_fields()[scope::timeline::value],
611 strvector_t({ "--timemory-timeline-profile" }), -1, 1);
612
614 uint16_t, max_depth, TIMEMORY_SETTINGS_KEY("MAX_DEPTH"),
615 "Set the maximum depth of label hierarchy reporting",
616 std::numeric_limits<uint16_t>::max(), strvector_t({ "--timemory-max-depth" }), 1);
617}
618//
619//--------------------------------------------------------------------------------------//
620//
622void
623settings::initialize_components()
624{
625 // PRINT_HERE("%s", "");
627 string_t, global_components, TIMEMORY_SETTINGS_KEY("GLOBAL_COMPONENTS"),
628 "A specification of components which is used by multiple variadic bundlers "
629 "and "
630 "user_bundles as the fall-back set of components if their specific variable "
631 "is "
632 "not set. E.g. user_mpip_bundle will use this if TIMEMORY_MPIP_COMPONENTS is "
633 "not "
634 "specified",
635 "", strvector_t({ "--timemory-global-components" }));
636
639 "A specification of components which will be added "
640 "to structures containing the 'user_ompt_bundle'. Priority: TRACE_COMPONENTS "
641 "-> "
642 "PROFILER_COMPONENTS -> COMPONENTS -> GLOBAL_COMPONENTS",
643 "", strvector_t({ "--timemory-ompt-components" }));
644
647 "A specification of components which will be added "
648 "to structures containing the 'user_mpip_bundle'. Priority: TRACE_COMPONENTS "
649 "-> "
650 "PROFILER_COMPONENTS -> COMPONENTS -> GLOBAL_COMPONENTS",
651 "", strvector_t({ "--timemory-mpip-components" }));
652
654 string_t, ncclp_components, TIMEMORY_SETTINGS_KEY("NCCLP_COMPONENTS"),
655 "A specification of components which will be added "
656 "to structures containing the 'user_ncclp_bundle'. Priority: MPIP_COMPONENTS "
657 "-> "
658 "TRACE_COMPONENTS -> PROFILER_COMPONENTS -> COMPONENTS -> GLOBAL_COMPONENTS",
659 "", strvector_t({ "--timemory-ncclp-components" }));
660
662 string_t, trace_components, TIMEMORY_SETTINGS_KEY("TRACE_COMPONENTS"),
663 "A specification of components which will be used by the interfaces which "
664 "are "
665 "designed for full profiling. These components will be subjected to "
666 "throttling. "
667 "Priority: COMPONENTS -> GLOBAL_COMPONENTS",
668 "", strvector_t({ "--timemory-trace-components" }));
669
671 string_t, profiler_components, TIMEMORY_SETTINGS_KEY("PROFILER_COMPONENTS"),
672 "A specification of components which will be used by the interfaces which "
673 "are "
674 "designed for full python profiling. This specification will be overridden "
675 "by a "
676 "trace_components specification. Priority: COMPONENTS -> GLOBAL_COMPONENTS",
677 "", strvector_t({ "--timemory-profiler-components" }));
678
680 string_t, kokkos_components, TIMEMORY_SETTINGS_KEY("KOKKOS_COMPONENTS"),
681 "A specification of components which will be used by the interfaces which "
682 "are "
683 "designed for kokkos profiling. Priority: TRACE_COMPONENTS -> "
684 "PROFILER_COMPONENTS -> COMPONENTS -> GLOBAL_COMPONENTS",
685 "", strvector_t({ "--timemory-kokkos-components" }));
686
688 TIMEMORY_SETTINGS_KEY("COMPONENTS"),
689 "A specification of components which is used by "
690 "the library interface. This "
691 "falls back to TIMEMORY_GLOBAL_COMPONENTS.",
692 "", strvector_t({ "--timemory-components" }));
693}
694//
695//--------------------------------------------------------------------------------------//
696//
698void
699settings::initialize_io()
700{
701 // PRINT_HERE("%s", "");
703 TIMEMORY_SETTINGS_KEY("AUTO_OUTPUT"),
704 "Generate output at application termination", true,
705 strvector_t({ "--timemory-auto-output" }), -1, 1);
706
708 bool, cout_output, TIMEMORY_SETTINGS_KEY("COUT_OUTPUT"), "Write output to stdout",
709 true, strvector_t({ "--timemory-cout-output" }), -1, 1);
710
712 bool, file_output, TIMEMORY_SETTINGS_KEY("FILE_OUTPUT"), "Write output to files",
713 true, strvector_t({ "--timemory-file-output" }), -1, 1);
714
716 TIMEMORY_SETTINGS_KEY("TEXT_OUTPUT"),
717 "Write text output files", true,
718 strvector_t({ "--timemory-text-output" }), -1, 1);
719
721 TIMEMORY_SETTINGS_KEY("JSON_OUTPUT"),
722 "Write json output files", true,
723 strvector_t({ "--timemory-json-output" }), -1, 1);
724
726 TIMEMORY_SETTINGS_KEY("TREE_OUTPUT"),
727 "Write hierarchical json output files", true,
728 strvector_t({ "--timemory-tree-output" }), -1, 1);
729
731 TIMEMORY_SETTINGS_KEY("DART_OUTPUT"),
732 "Write dart measurements for CDash", false,
733 strvector_t({ "--timemory-dart-output" }), -1, 1);
734
736 bool, time_output, TIMEMORY_SETTINGS_KEY("TIME_OUTPUT"),
737 "Output data to subfolder w/ a timestamp (see also: TIMEMORY_TIME_FORMAT)", false,
738 strvector_t({ "--timemory-time-output" }), -1, 1);
739
741 bool, plot_output, TIMEMORY_SETTINGS_KEY("PLOT_OUTPUT"),
742 "Generate plot outputs from json outputs", TIMEMORY_DEFAULT_PLOTTING,
743 strvector_t({ "--timemory-plot-output" }), -1, 1);
744
746 bool, diff_output, TIMEMORY_SETTINGS_KEY("DIFF_OUTPUT"),
747 "Generate a difference output vs. a pre-existing output (see also: "
748 "TIMEMORY_INPUT_PATH and TIMEMORY_INPUT_PREFIX)",
749 false, strvector_t({ "--timemory-diff-output" }), -1, 1);
750
752 bool, flamegraph_output, TIMEMORY_SETTINGS_KEY("FLAMEGRAPH_OUTPUT"),
753 "Write a json output for flamegraph visualization (use chrome://tracing)", true,
754 strvector_t({ "--timemory-flamegraph-output" }), -1, 1);
755
757 bool, ctest_notes, TIMEMORY_SETTINGS_KEY("CTEST_NOTES"),
758 "Write a CTestNotes.txt for each text output", false,
759 strvector_t({ "--timemory-ctest-notes" }), -1, 1);
760
763 "Explicitly specify the output folder for results", "timemory-output",
764 strvector_t({ "--timemory-output-path" }),
765 1); // folder
766
768 TIMEMORY_SETTINGS_KEY("OUTPUT_PREFIX"),
769 "Explicitly specify a prefix for all output files",
770 "", strvector_t({ "--timemory-output-prefix" }),
771 1); // file prefix
772
775 "Explicitly specify the input folder for difference "
776 "comparisons (see also: TIMEMORY_DIFF_OUTPUT)",
777 "", strvector_t({ "--timemory-input-path" }), 1); // folder
778
781 "Explicitly specify the prefix for input files used in difference "
782 "comparisons "
783 "(see also: TIMEMORY_DIFF_OUTPUT)",
784 "", strvector_t({ "--timemory-input-prefix" }), 1); // file prefix
785
787 string_t, input_extensions, TIMEMORY_SETTINGS_KEY("INPUT_EXTENSIONS"),
788 "File extensions used when searching for input files used in difference "
789 "comparisons (see also: TIMEMORY_DIFF_OUTPUT)",
790 "json,xml", strvector_t({ "--timemory-input-extensions" })); // extensions
791}
792//
793//--------------------------------------------------------------------------------------//
794//
796void
797settings::initialize_format()
798{
799 // PRINT_HERE("%s", "");
802 "Customize the folder generation when TIMEMORY_TIME_OUTPUT is enabled (see "
803 "also: "
804 "strftime)",
805 "%F_%I.%M_%p", strvector_t({ "--timemory-time-format" }), 1);
806
808 TIMEMORY_SETTINGS_KEY("PRECISION"),
809 "Set the global output precision for components",
810 -1, strvector_t({ "--timemory-precision" }), 1);
811
813 "Set the global output width for components", -1,
814 strvector_t({ "--timemory-width" }), 1);
815
817 TIMEMORY_SETTINGS_KEY("MAX_WIDTH"),
818 "Set the maximum width for component label outputs",
819 120, strvector_t({ "--timemory-max-width" }), 1);
820
822 bool, scientific, TIMEMORY_SETTINGS_KEY("SCIENTIFIC"),
823 "Set the global numerical reporting to scientific format", false,
824 strvector_t({ "--timemory-scientific" }), -1, 1);
825
827 int16_t, timing_precision, TIMEMORY_SETTINGS_KEY("TIMING_PRECISION"),
828 "Set the precision for components with 'is_timing_category' type-trait", -1);
829
831 int16_t, timing_width, TIMEMORY_SETTINGS_KEY("TIMING_WIDTH"),
832 "Set the output width for components with 'is_timing_category' type-trait", -1);
833
835 TIMEMORY_SETTINGS_KEY("TIMING_UNITS"),
836 "Set the units for components with "
837 "'uses_timing_units' type-trait",
838 "", strvector_t({ "--timemory-timing-units" }), 1);
839
841 TIMEMORY_SETTINGS_KEY("TIMING_SCIENTIFIC"),
842 "Set the numerical reporting format for components "
843 "with 'is_timing_category' type-trait",
844 false);
845
847 int16_t, memory_precision, TIMEMORY_SETTINGS_KEY("MEMORY_PRECISION"),
848 "Set the precision for components with 'is_memory_category' type-trait", -1);
849
851 int16_t, memory_width, TIMEMORY_SETTINGS_KEY("MEMORY_WIDTH"),
852 "Set the output width for components with 'is_memory_category' type-trait", -1);
853
855 TIMEMORY_SETTINGS_KEY("MEMORY_UNITS"),
856 "Set the units for components with "
857 "'uses_memory_units' type-trait",
858 "", strvector_t({ "--timemory-memory-units" }), 1);
859
861 TIMEMORY_SETTINGS_KEY("MEMORY_SCIENTIFIC"),
862 "Set the numerical reporting format for components "
863 "with 'is_memory_category' type-trait",
864 false);
865
867 int64_t, separator_frequency, TIMEMORY_SETTINGS_KEY("SEPARATOR_FREQ"),
868 "Frequency of dashed separator lines in text output", 0);
869}
870//
871//--------------------------------------------------------------------------------------//
872//
874void
875settings::initialize_parallel()
876{
877 // PRINT_HERE("%s", "");
879 TIMEMORY_SETTINGS_KEY("MAX_THREAD_BOOKMARKS"),
880 "Maximum number of times a worker thread bookmarks "
881 "the call-graph location w.r.t."
882 " the master thread. Higher values tend to "
883 "increase the finalization merge time",
884 50);
885
887 bool, collapse_threads, TIMEMORY_SETTINGS_KEY("COLLAPSE_THREADS"),
888 "Enable/disable combining thread-specific data", true,
889 strvector_t({ "--timemory-collapse-threads" }), -1, 1);
890
892 bool, collapse_processes, TIMEMORY_SETTINGS_KEY("COLLAPSE_PROCESSES"),
893 "Enable/disable combining process-specific data", true,
894 strvector_t({ "--timemory-collapse-processes" }), -1, 1);
895
897 bool, cpu_affinity, TIMEMORY_SETTINGS_KEY("CPU_AFFINITY"),
898 "Enable pinning threads to CPUs (Linux-only)", false,
899 strvector_t({ "--timemory-cpu-affinity" }), -1, 1);
900
902 process::id_t, target_pid, TIMEMORY_SETTINGS_KEY("TARGET_PID"),
903 "Process ID for the components which require this", process::get_target_id());
904
906 "Enable/disable timemory calling MPI_Init / "
907 "MPI_Init_thread during certain "
908 "timemory_init(...) invocations",
909 false, strvector_t({ "--timemory-mpi-init" }), -1,
910 1);
911
913 bool, mpi_finalize, TIMEMORY_SETTINGS_KEY("MPI_FINALIZE"),
914 "Enable/disable timemory calling MPI_Finalize during "
915 "timemory_finalize(...) invocations",
916 false, strvector_t({ "--timemory-mpi-finalize" }), -1, 1);
917
919 bool, mpi_thread, TIMEMORY_SETTINGS_KEY("MPI_THREAD"),
920 "Call MPI_Init_thread instead of MPI_Init (see also: TIMEMORY_MPI_INIT)",
921 mpi::use_mpi_thread(), strvector_t({ "--timemory-mpi-thread" }), -1, 1);
922
925 "MPI_Init_thread mode: 'single', 'serialized', "
926 "'funneled', or 'multiple' (see also: "
927 "TIMEMORY_MPI_INIT and TIMEMORY_MPI_THREAD)",
928 mpi::use_mpi_thread_type(), strvector_t({ "--timemory-mpi-thread-type" }), 1);
929
931 bool, upcxx_init, TIMEMORY_SETTINGS_KEY("UPCXX_INIT"),
932 "Enable/disable timemory calling upcxx::init() during certain "
933 "timemory_init(...) invocations",
934 false, strvector_t({ "--timemory-upcxx-init" }), -1, 1);
935
937 bool, upcxx_finalize, TIMEMORY_SETTINGS_KEY("UPCXX_FINALIZE"),
938 "Enable/disable timemory calling upcxx::finalize() during "
939 "timemory_finalize()",
940 false, strvector_t({ "--timemory-upcxx-finalize" }), -1, 1);
941
943 int32_t, node_count, TIMEMORY_SETTINGS_KEY("NODE_COUNT"),
944 "Total number of nodes used in application. Setting this value > 1 will "
945 "result "
946 "in aggregating N processes into groups of N / NODE_COUNT",
947 0, strvector_t({ "--timemory-node-count" }), 1);
948}
949//
950//--------------------------------------------------------------------------------------//
951//
953void
954settings::initialize_tpls()
955{
956 // PRINT_HERE("%s", "");
958 bool, papi_threading, TIMEMORY_SETTINGS_KEY("PAPI_THREADING"),
959 "Enable multithreading support when using PAPI", true,
960 strvector_t({ "--timemory-papi-threading" }), -1, 1);
961
963 bool, papi_multiplexing, TIMEMORY_SETTINGS_KEY("PAPI_MULTIPLEXING"),
964 "Enable multiplexing when using PAPI", false,
965 strvector_t({ "--timemory-papi-multiplexing" }), -1, 1);
966
968 bool, papi_fail_on_error, TIMEMORY_SETTINGS_KEY("PAPI_FAIL_ON_ERROR"),
969 "Configure PAPI errors to trigger a runtime error", false,
970 strvector_t({ "--timemory-papi-fail-on-error" }), -1, 1);
971
973 bool, papi_quiet, TIMEMORY_SETTINGS_KEY("PAPI_QUIET"),
974 "Configure suppression of reporting PAPI errors/warnings", false,
975 strvector_t({ "--timemory-papi-quiet" }), -1, 1);
976
978 TIMEMORY_SETTINGS_KEY("PAPI_EVENTS"),
979 "PAPI presets and events to collect (see also: "
980 "papi_avail)",
981 "", strvector_t({ "--timemory-papi-events" }));
982
984 "Configure PAPI to attach to another process (see "
985 "also: TIMEMORY_TARGET_PID)",
986 false);
987
989 TIMEMORY_SETTINGS_KEY("PAPI_OVERFLOW"),
990 "Value at which PAPI hw counters trigger an "
991 "overflow callback",
992 0, strvector_t({ "--timemory-papi-overflow" }), 1);
993
995 uint64_t, cuda_event_batch_size, TIMEMORY_SETTINGS_KEY("CUDA_EVENT_BATCH_SIZE"),
996 "Batch size for create cudaEvent_t in cuda_event components", 5);
997
999 bool, nvtx_marker_device_sync, TIMEMORY_SETTINGS_KEY("NVTX_MARKER_DEVICE_SYNC"),
1000 "Use cudaDeviceSync when stopping NVTX marker (vs. cudaStreamSychronize)", true);
1001
1003 int32_t, cupti_activity_level, TIMEMORY_SETTINGS_KEY("CUPTI_ACTIVITY_LEVEL"),
1004 "Default group of kinds tracked via CUpti Activity API", 1,
1005 strvector_t({ "--timemory-cupti-activity-level" }), 1);
1006
1008 TIMEMORY_SETTINGS_KEY("CUPTI_ACTIVITY_KINDS"),
1009 "Specific cupti activity kinds to track", "",
1010 strvector_t({ "--timemory-cupti-activity-kinds" }));
1011
1013 TIMEMORY_SETTINGS_KEY("CUPTI_EVENTS"),
1014 "Hardware counter event types to collect on NVIDIA "
1015 "GPUs",
1016 "", strvector_t({ "--timemory-cupti-events" }));
1017
1019 TIMEMORY_SETTINGS_KEY("CUPTI_METRICS"),
1020 "Hardware counter metric types to collect on "
1021 "NVIDIA GPUs",
1022 "", strvector_t({ "--timemory-cupti-metrics" }));
1023
1025 TIMEMORY_SETTINGS_KEY("CUPTI_DEVICE"),
1026 "Target device for CUPTI data collection", 0,
1027 strvector_t({ "--timemory-cupti-device" }), 1);
1028
1029 insert<int>("TIMEMORY_CUPTI_PCSAMPLING_PERIOD", "cupti_pcsampling_period",
1030 "The period for PC sampling. Must be >= 5 and <= 31", 8,
1031 strvector_t{ "--timemory-cupti-pcsampling-period" });
1032
1033 insert<bool>("TIMEMORY_CUPTI_PCSAMPLING_PER_LINE", "cupti_pcsampling_per_line",
1034 "Report the PC samples per-line or collapse into one entry for entire "
1035 "function",
1036 false, strvector_t{ "--timemory-cupti-pcsampling-per-line" });
1037
1038 insert<bool>("TIMEMORY_CUPTI_PCSAMPLING_REGION_TOTALS",
1039 "cupti_pcsampling_region_totals",
1040 "When enabled, region markers will report total samples from all child "
1041 "functions",
1042 true, strvector_t{ "--timemory-cupti-pcsampling-region-totals" });
1043
1044 insert<bool>("TIMEMORY_CUPTI_PCSAMPLING_SERIALIZED", "cupti_pcsampling_serialized",
1045 "Serialize all the kernel functions", false,
1046 strvector_t{ "--timemory-cupti-pcsampling-serialize" });
1047
1048 insert<size_t>("TIMEMORY_CUPTI_PCSAMPLING_NUM_COLLECT",
1049 "cupti_pcsampling_num_collect", "Number of PCs to be collected",
1050 size_t{ 100 },
1051 strvector_t{ "--timemory-cupti-pcsampling-num-collect" });
1052
1053 insert<std::string>("TIMEMORY_CUPTI_PCSAMPLING_STALL_REASONS",
1054 "cupti_pcsampling_stall_reasons",
1055 "The PC sampling stall reasons to count", std::string{},
1056 strvector_t{ "--timemory-cupti-pcsampling-stall-reasons" });
1057
1060 "Configure the CrayPAT categories to collect (same as PAT_RT_PERFCTR)",
1061 get_env<std::string>("PAT_RT_PERFCTR", "", false))
1062
1065 "Configure the python executable to use", TIMEMORY_PYTHON_PLOTTER,
1066 strvector_t({ "--timemory-python-exe" }));
1067}
1068//
1069//--------------------------------------------------------------------------------------//
1070//
1072void
1073settings::initialize_roofline()
1074{
1075 // PRINT_HERE("%s", "");
1077 string_t, roofline_mode, TIMEMORY_SETTINGS_KEY("ROOFLINE_MODE"),
1078 "Configure the roofline collection mode. Options: 'op' 'ai'.", "op",
1079 strvector_t({ "--timemory-roofline-mode" }), 1, 1, strvector_t({ "op", "ai" }));
1080
1082 string_t, cpu_roofline_mode, TIMEMORY_SETTINGS_KEY("ROOFLINE_MODE_CPU"),
1083 "Configure the roofline collection mode for CPU "
1084 "specifically. Options: 'op', "
1085 "'ai'",
1086 "op", strvector_t({ "--timemory-cpu-roofline-mode" }), 1, 1,
1087 strvector_t({ "op", "ai" }));
1088
1090 string_t, gpu_roofline_mode, TIMEMORY_SETTINGS_KEY("ROOFLINE_MODE_GPU"),
1091 "Configure the roofline collection mode for GPU specifically. Options: 'op' "
1092 "'ai'.",
1093 static_cast<tsettings<string_t>*>(
1094 m_data[TIMEMORY_SETTINGS_KEY("ROOFLINE_MODE")].get())
1095 ->get(),
1096 strvector_t({ "--timemory-gpu-roofline-mode" }), 1, 1,
1097 strvector_t({ "op", "ai" }));
1098
1100 string_t, cpu_roofline_events, TIMEMORY_SETTINGS_KEY("ROOFLINE_EVENTS_CPU"),
1101 "Configure custom hw counters to add to the cpu roofline", "");
1102
1104 string_t, gpu_roofline_events, TIMEMORY_SETTINGS_KEY("ROOFLINE_EVENTS_GPU"),
1105 "Configure custom hw counters to add to the gpu roofline", "");
1106
1108 TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS"),
1109 "Configure roofline labels/descriptions/output-files "
1110 "encode the list of data types",
1111 false);
1112
1114 bool, roofline_type_labels_cpu, TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS_CPU"),
1115 "Configure labels, etc. for the roofline components "
1116 "for CPU (see also: TIMEMORY_ROOFLINE_TYPE_LABELS)",
1117 static_cast<tsettings<bool>*>(
1118 m_data[TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS")].get())
1119 ->get());
1120
1122 bool, roofline_type_labels_gpu, TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS_GPU"),
1123 "Configure labels, etc. for the roofline components "
1124 "for GPU (see also: TIMEMORY_ROOFLINE_TYPE_LABELS)",
1125 static_cast<tsettings<bool>*>(
1126 m_data[TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS")].get())
1127 ->get());
1128
1130 TIMEMORY_SETTINGS_KEY("INSTRUCTION_ROOFLINE"),
1131 "Configure the roofline to include the hw counters "
1132 "required for generating an instruction roofline",
1133 false);
1134}
1135//
1136//--------------------------------------------------------------------------------------//
1137//
1139settings::initialize_miscellaneous()
1140{
1141 // PRINT_HERE("%s", "");
1143 bool, add_secondary, TIMEMORY_SETTINGS_KEY("ADD_SECONDARY"),
1144 "Enable/disable components adding secondary (child) entries when available. "
1145 "E.g. "
1146 "suppress individual CUDA kernels, etc. when using Cupti components",
1147 true, strvector_t({ "--timemory-add-secondary" }), -1, 1);
1148
1150 size_t, throttle_count, TIMEMORY_SETTINGS_KEY("THROTTLE_COUNT"),
1151 "Minimum number of laps before checking whether a key should be throttled", 10000,
1152 strvector_t({ "--timemory-throttle-count" }), 1);
1153
1155 size_t, throttle_value, TIMEMORY_SETTINGS_KEY("THROTTLE_VALUE"),
1156 "Average call time in nanoseconds when # laps > throttle_count that triggers "
1157 "throttling",
1158 10000, strvector_t({ "--timemory-throttle-value" }), 1);
1159
1161 bool, enable_signal_handler, TIMEMORY_SETTINGS_KEY("ENABLE_SIGNAL_HANDLER"),
1162 "Enable signals in timemory_init", false,
1163 strvector_t({ "--timemory-enable-signal-handler" }), -1, 1)
1164
1166 bool, allow_signal_handler, TIMEMORY_SETTINGS_KEY("ALLOW_SIGNAL_HANDLER"),
1167 "Allow signal handling to be activated", signal_settings::allow(),
1168 strvector_t({ "--timemory-allow-signal-handler" }), -1, 1);
1169
1171 bool, enable_all_signals, TIMEMORY_SETTINGS_KEY("ENABLE_ALL_SIGNALS"),
1172 "Enable catching all signals", signal_settings::enable_all());
1173
1175 bool, disable_all_signals, TIMEMORY_SETTINGS_KEY("DISABLE_ALL_SIGNALS"),
1176 "Disable catching any signals", signal_settings::disable_all());
1177
1179 bool, destructor_report, TIMEMORY_SETTINGS_KEY("DESTRUCTOR_REPORT"),
1180 "Configure default setting for auto_{list,tuple,hybrid} to write to stdout "
1181 "during"
1182 " destruction of the bundle",
1183 false, strvector_t({ "--timemory-destructor-report" }), -1, 1);
1184
1186 bool, stack_clearing, TIMEMORY_SETTINGS_KEY("STACK_CLEARING"),
1187 "Enable/disable stopping any markers still running during finalization", true,
1188 strvector_t({ "--timemory-stack-clearing" }), -1, 1);
1189
1191 bool, banner, TIMEMORY_SETTINGS_KEY("BANNER"),
1192 "Notify about tim::manager creation and destruction",
1193 (get_env<bool>(TIMEMORY_SETTINGS_KEY("LIBRARY_CTOR"), false)));
1194
1196 std::string, TIMEMORY_SETTINGS_KEY("NETWORK_INTERFACE"),
1197 "Default network interface", std::string{},
1198 strvector_t({ "--timemory-network-interface" }), -1, 1);
1199}
1200//
1201//--------------------------------------------------------------------------------------//
1202//
1204void
1205settings::initialize_ert()
1206{
1207 // PRINT_HERE("%s", "");
1209 TIMEMORY_SETTINGS_KEY("ERT_NUM_THREADS"),
1210 "Number of threads to use when running ERT", 0);
1211
1213 TIMEMORY_SETTINGS_KEY("ERT_NUM_THREADS_CPU"),
1214 "Number of threads to use when running ERT on CPU",
1215 std::thread::hardware_concurrency());
1216
1218 uint64_t, ert_num_threads_gpu, TIMEMORY_SETTINGS_KEY("ERT_NUM_THREADS_GPU"),
1219 "Number of threads which launch kernels when running ERT on the GPU", 1);
1220
1222 uint64_t, ert_num_streams, TIMEMORY_SETTINGS_KEY("ERT_NUM_STREAMS"),
1223 "Number of streams to use when launching kernels in ERT on the GPU", 1);
1224
1226 TIMEMORY_SETTINGS_KEY("ERT_GRID_SIZE"),
1227 "Configure the grid size (number of blocks) for ERT on "
1228 "GPU (0 == auto-compute)",
1229 0);
1230
1232 uint64_t, ert_block_size, TIMEMORY_SETTINGS_KEY("ERT_BLOCK_SIZE"),
1233 "Configure the block size (number of threads per block) for ERT on GPU", 1024);
1234
1236 TIMEMORY_SETTINGS_KEY("ERT_ALIGNMENT"),
1237 "Configure the alignment (in bits) when running ERT on "
1238 "CPU (0 == 8 * sizeof(T))",
1239 0);
1240
1242 uint64_t, ert_min_working_size, TIMEMORY_SETTINGS_KEY("ERT_MIN_WORKING_SIZE"),
1243 "Configure the minimum working size when running ERT (0 == device specific)", 0);
1244
1246 TIMEMORY_SETTINGS_KEY("ERT_MIN_WORKING_SIZE_CPU"),
1247 "Configure the minimum working size when running ERT "
1248 "on CPU",
1249 64);
1250
1252 TIMEMORY_SETTINGS_KEY("ERT_MIN_WORKING_SIZE_GPU"),
1253 "Configure the minimum working size when running ERT "
1254 "on GPU",
1255 10 * 1000 * 1000);
1256
1258 uint64_t, ert_max_data_size, TIMEMORY_SETTINGS_KEY("ERT_MAX_DATA_SIZE"),
1259 "Configure the max data size when running ERT on CPU", 0);
1260
1262 uint64_t, ert_max_data_size_cpu, TIMEMORY_SETTINGS_KEY("ERT_MAX_DATA_SIZE_CPU"),
1263 "Configure the max data size when running ERT on CPU", 0);
1264
1266 uint64_t, ert_max_data_size_gpu, TIMEMORY_SETTINGS_KEY("ERT_MAX_DATA_SIZE_GPU"),
1267 "Configure the max data size when running ERT on GPU", 500 * 1000 * 1000);
1268
1271 "Skip these number of ops (i.e. ERT_FLOPS) when were set at compile time", "");
1272}
1273//
1274//--------------------------------------------------------------------------------------//
1275//
1277void
1278settings::initialize_dart()
1279{
1280 // PRINT_HERE("%s", "");
1282 TIMEMORY_SETTINGS_KEY("DART_TYPE"),
1283 "Only echo this measurement type (see also: "
1284 "TIMEMORY_DART_OUTPUT)",
1285 "", strvector_t({ "--timemory-dart-type" }));
1286
1288 TIMEMORY_SETTINGS_KEY("DART_COUNT"),
1289 "Only echo this number of dart tags (see also: "
1290 "TIMEMORY_DART_OUTPUT)",
1291 1, strvector_t({ "--timemory-dart-count" }), 1);
1292
1294 bool, dart_label, TIMEMORY_SETTINGS_KEY("DART_LABEL"),
1295 "Echo the category instead of the label (see also: TIMEMORY_DART_OUTPUT)", true,
1296 strvector_t({ "--timemory-dart-label" }), -1, 1);
1297}
1298//
1299//--------------------------------------------------------------------------------------//
1300//
1302void
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}
1320//
1321//--------------------------------------------------------------------------------------//
1322//
1324bool
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}
1352//
1353//--------------------------------------------------------------------------------------//
1354//
1356bool
1357settings::read(std::istream& ifs, std::string inp)
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 {
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 {
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}
1568//
1569//--------------------------------------------------------------------------------------//
1570//
1572void
1573settings::init_config(bool _search_default)
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}
1612//
1613//--------------------------------------------------------------------------------------//
1614//
1617 TIMEMORY_SETTINGS_KEY("SUPPRESS_PARSING"))
1619 TIMEMORY_SETTINGS_KEY("SUPPRESS_CONFIG"))
1632 TIMEMORY_SETTINGS_KEY("FLAMEGRAPH_OUTPUT"))
1638 TIMEMORY_SETTINGS_KEY("COLLAPSE_THREADS"))
1640 TIMEMORY_SETTINGS_KEY("COLLAPSE_PROCESSES"))
1648 TIMEMORY_SETTINGS_KEY("TIMING_PRECISION"))
1651 TIMEMORY_SETTINGS_KEY("TIMING_UNITS"))
1653 TIMEMORY_SETTINGS_KEY("TIMING_SCIENTIFIC"))
1655 TIMEMORY_SETTINGS_KEY("MEMORY_PRECISION"))
1658 TIMEMORY_SETTINGS_KEY("MEMORY_UNITS"))
1660 TIMEMORY_SETTINGS_KEY("MEMORY_SCIENTIFIC"))
1663 TIMEMORY_SETTINGS_KEY("OUTPUT_PREFIX"))
1666 TIMEMORY_SETTINGS_KEY("INPUT_PREFIX"))
1668 TIMEMORY_SETTINGS_KEY("INPUT_EXTENSIONS"))
1673 TIMEMORY_SETTINGS_KEY("MAX_THREAD_BOOKMARKS"))
1676 TIMEMORY_SETTINGS_KEY("STACK_CLEARING"))
1679 TIMEMORY_SETTINGS_KEY("THROTTLE_COUNT"))
1681 TIMEMORY_SETTINGS_KEY("THROTTLE_VALUE"))
1683 TIMEMORY_SETTINGS_KEY("GLOBAL_COMPONENTS"))
1685 TIMEMORY_SETTINGS_KEY("TUPLE_COMPONENTS"))
1687 TIMEMORY_SETTINGS_KEY("LIST_COMPONENTS"))
1689 TIMEMORY_SETTINGS_KEY("OMPT_COMPONENTS"))
1691 TIMEMORY_SETTINGS_KEY("MPIP_COMPONENTS"))
1693 TIMEMORY_SETTINGS_KEY("NCCLP_COMPONENTS"))
1695 TIMEMORY_SETTINGS_KEY("TRACE_COMPONENTS"))
1697 TIMEMORY_SETTINGS_KEY("PROFILER_COMPONENTS"))
1699 TIMEMORY_SETTINGS_KEY("KOKKOS_COMPONENTS"))
1705 TIMEMORY_SETTINGS_KEY("MPI_THREAD_TYPE"))
1708 TIMEMORY_SETTINGS_KEY("UPCXX_FINALIZE"))
1710 TIMEMORY_SETTINGS_KEY("PAPI_THREADING"))
1712 TIMEMORY_SETTINGS_KEY("PAPI_MULTIPLEXING"))
1714 TIMEMORY_SETTINGS_KEY("PAPI_FAIL_ON_ERROR"))
1720 TIMEMORY_SETTINGS_KEY("CUDA_EVENT_BATCH_SIZE"))
1722 TIMEMORY_SETTINGS_KEY("NVTX_MARKER_DEVICE_SYNC"))
1724 TIMEMORY_SETTINGS_KEY("CUPTI_ACTIVITY_LEVEL"))
1726 TIMEMORY_SETTINGS_KEY("CUPTI_ACTIVITY_KINDS"))
1728 TIMEMORY_SETTINGS_KEY("CUPTI_EVENTS"))
1730 TIMEMORY_SETTINGS_KEY("CUPTI_METRICS"))
1733 TIMEMORY_SETTINGS_KEY("ROOFLINE_MODE"))
1735 TIMEMORY_SETTINGS_KEY("ROOFLINE_MODE_CPU"))
1737 TIMEMORY_SETTINGS_KEY("ROOFLINE_MODE_GPU"))
1739 TIMEMORY_SETTINGS_KEY("ROOFLINE_EVENTS_CPU"))
1741 TIMEMORY_SETTINGS_KEY("ROOFLINE_EVENTS_GPU"))
1743 TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS"))
1745 TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS_CPU"))
1747 TIMEMORY_SETTINGS_KEY("ROOFLINE_TYPE_LABELS_GPU"))
1749 TIMEMORY_SETTINGS_KEY("INSTRUCTION_ROOFLINE"))
1751 TIMEMORY_SETTINGS_KEY("ERT_NUM_THREADS"))
1753 TIMEMORY_SETTINGS_KEY("ERT_NUM_THREADS_CPU"))
1755 TIMEMORY_SETTINGS_KEY("ERT_NUM_THREADS_GPU"))
1757 TIMEMORY_SETTINGS_KEY("ERT_NUM_STREAMS"))
1759 TIMEMORY_SETTINGS_KEY("ERT_GRID_SIZE"))
1761 TIMEMORY_SETTINGS_KEY("ERT_BLOCK_SIZE"))
1763 TIMEMORY_SETTINGS_KEY("ERT_ALIGNMENT"))
1765 TIMEMORY_SETTINGS_KEY("ERT_MIN_WORKING_SIZE"))
1767 TIMEMORY_SETTINGS_KEY("ERT_MIN_WORKING_SIZE_CPU"))
1769 TIMEMORY_SETTINGS_KEY("ERT_MIN_WORKING_SIZE_GPU"))
1771 TIMEMORY_SETTINGS_KEY("ERT_MAX_DATA_SIZE"))
1773 TIMEMORY_SETTINGS_KEY("ERT_MAX_DATA_SIZE_CPU"))
1775 TIMEMORY_SETTINGS_KEY("ERT_MAX_DATA_SIZE_GPU"))
1777 TIMEMORY_SETTINGS_KEY("ERT_SKIP_OPS"))
1782 TIMEMORY_SETTINGS_KEY("DESTRUCTOR_REPORT"))
1784// stream
1786 TIMEMORY_SETTINGS_KEY("SEPARATOR_FREQ"))
1787// signals
1789 TIMEMORY_SETTINGS_KEY("ENABLE_SIGNAL_HANDLER"))
1791 TIMEMORY_SETTINGS_KEY("ALLOW_SIGNAL_HANDLER"))
1793 TIMEMORY_SETTINGS_KEY("ENABLE_ALL_SIGNALS"))
1795 TIMEMORY_SETTINGS_KEY("DISABLE_ALL_SIGNALS"))
1796// miscellaneous ref
1799 TIMEMORY_SETTINGS_KEY("TIMELINE_PROFILE"))
1800TIMEMORY_SETTINGS_REFERENCE_DEF(process::id_t, target_pid,
1801 TIMEMORY_SETTINGS_KEY("TARGET_PID"))
1802//
1803//--------------------------------------------------------------------------------------//
1804//
1805} // namespace tim
1806
1807#include "timemory/tpls/cereal/archives.hpp"
1808
1810
1811#endif // TIMEMORY_SETTINGS_SETTINGS_CPP_
#define TIMEMORY_DEFAULT_ENABLED
Definition: api.hpp:201
#define TIMEMORY_DEFAULT_PLOTTING
Definition: api.hpp:197
#define TIMEMORY_PYTHON_PLOTTER
Definition: api.hpp:205
static bool & enable_all()
Definition: signals.hpp:256
static bool & disable_all()
Definition: signals.hpp:264
std::string string_t
Definition: library.cpp:57
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:320
TIMEMORY_UTILITY_INLINE std::string compute_md5(const std::string &inp)
Definition: md5.cpp:404
const string_t const string_t & _dir
Definition: definition.hpp:52
input_type & get_fields()
Definition: types.hpp:408
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
TIMEMORY_SETTINGS_MEMBER_DEF(string_t, config_file, TIMEMORY_SETTINGS_KEY("CONFIG_FILE")) TIMEMORY_SETTINGS_MEMBER_DEF(bool
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
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)
gpu_roofline_events
Definition: settings.cpp:1740
ert_max_data_size
Definition: settings.cpp:1770
TIMEMORY_SETTINGS_INLINE std::string get_local_datetime(const char *dt_format, std::time_t *dt_curr)
Definition: settings.cpp:120
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
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
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
std::vector< std::string > read_command_line(pid_t _pid)
Definition: utility.cpp:114
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
char argparse::argument_parser tim::settings * _settings
Definition: config.cpp:255
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
size_t pos
Definition: config.cpp:102
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
stack_clearing
Definition: settings.cpp:1675
TIMEMORY_SETTINGS_KEY("SUPPRESS_PARSING")) TIMEMORY_SETTINGS_MEMBER_DEF(bool
int makedir(std::string _dir, int umask)
Definition: utility.cpp:67
papi_fail_on_error
Definition: settings.cpp:1713
papi_quiet
Definition: settings.cpp:1715
auto get(const auto_bundle< Tag, Types... > &_obj)
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
ContainerT delimit(const std::string &line, const std::string &delimiters="\"',;: ", PredicateT &&predicate=[](const std::string &s) -> std::string { return s;})
Definition: delimit.hpp:68
mpi_thread
Definition: settings.cpp:1703
char const std::string const std::string & _suffix
Definition: config.cpp:57
char ** environ
#define TIMEMORY_SETTINGS_MEMBER_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT)
Definition: macros.hpp:147
#define TIMEMORY_SETTINGS_HIDDEN_MEMBER_ARG_IMPL(TYPE, ENV_VAR, DESC, INIT,...)
Definition: macros.hpp:187
#define TIMEMORY_SETTINGS_INLINE
Definition: macros.hpp:51
#define TIMEMORY_SETTINGS_PREFIX
Definition: macros.hpp:56
#define TIMEMORY_SETTINGS_MEMBER_ARG_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT,...)
Definition: macros.hpp:173
#define TIMEMORY_SETTINGS_EXTERN_TEMPLATE(...)
Definition: macros.hpp:302
#define TIMEMORY_SETTINGS_REFERENCE_ARG_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT,...)
Definition: macros.hpp:213
#define TIMEMORY_SETTINGS_REFERENCE_IMPL(TYPE, FUNC, ENV_VAR, DESC, INIT)
Definition: macros.hpp:200
#define TIMEMORY_SETTINGS_REFERENCE_DEF(TYPE, FUNC, ENV_VAR)
Definition: macros.hpp:121
arg_result get(size_t _idx, Tp &_value)
Definition: argparse.hpp:674
Provides a static get() function which returns a shared pointer to an instance of the given archive f...
Definition: policy.hpp:92
bool read(const string_t &)
read a configuration file
Definition: settings.cpp:1325
static pointer_t shared_instance()
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
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
static std::time_t * get_launch_time(Tag={})
Definition: settings.hpp:456
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
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
std::unordered_map< string_view_t, value_type > data_type
Definition: settings.hpp:82
settings & operator=(const settings &)
Definition: settings.cpp:477
process::get_id()) static strvector_t get_global_environment()
strvector_t & get_environment()
Definition: settings.hpp:250
static void parse(settings *=instance< TIMEMORY_API >())
Definition: settings.cpp:410
static settings * instance()
Definition: settings.hpp:536
static std::string format(std::string _fpath, const std::string &_tag)
Definition: settings.cpp:222
void init_config(bool search_default=true)
Definition: settings.cpp:1573
std::vector< std::string > strvector_t
Definition: settings.hpp:80
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
The declaration for the types for utility without definitions.
#define TIMEMORY_CONDITIONAL_DEMANGLED_BACKTRACE(CONDITION, DEPTH)
Definition: macros.hpp:202
#define PRINT_HERE(...)
Definition: macros.hpp:152
#define TIMEMORY_EXCEPTION(...)
Definition: types.hpp:138
#define TIMEMORY_JOIN(delim,...)
Definition: macros.hpp:90