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.
library.h
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/** \file timemory/library.h
26 * \headerfile timemory/library.h "timemory/library.h"
27 * This provides declaration for the library interface
28 *
29 */
30
31#pragma once
32
33#if !defined(TIMEMORY_SOURCE)
34# if !defined(TIMEMORY_USE_EXTERN) && !defined(_WIN32) && !defined(_WIN64)
35# define TIMEMORY_USE_EXTERN
36# endif
37#endif
38
40
41//--------------------------------------------------------------------------------------//
42//
43#if defined(__cplusplus)
44
46
47//--------------------------------------------------------------------------------------//
48
49struct timemory_scoped_record
50{
51 timemory_scoped_record(const char* name)
52 : m_nid(timemory_get_begin_record(name))
53 {}
54
55 timemory_scoped_record(const char* name, const char* components)
57 {}
58
59 template <typename... Idx>
60 timemory_scoped_record(const char* name, int _id, Idx... _ids)
62 {}
63
64 ~timemory_scoped_record() { timemory_end_record(m_nid); }
65
66private:
67 uint64_t m_nid = std::numeric_limits<uint64_t>::max();
68};
69
70//--------------------------------------------------------------------------------------//
71
72template <typename Tp>
73inline Tp&
74timemory_tl_static(const Tp& _initial = {})
75{
76 static thread_local Tp _instance = _initial;
77 return _instance;
78}
79
80//--------------------------------------------------------------------------------------//
81
82#endif // if defined(__cplusplus)
83//
84//--------------------------------------------------------------------------------------//
void timemory_end_record(uint64_t id)
Definition: library.cpp:557
uint64_t timemory_get_begin_record_types(const char *name, const char *ctypes)
Variant to timemory_begin_record_types which returns a unique integer.
Definition: library.cpp:503
uint64_t timemory_get_begin_record_enum(const char *name,...)
Variant to timemory_begin_record_enum which returns a unique integer.
Definition: library.cpp:524
uint64_t timemory_get_begin_record(const char *name)
Variant to timemory_begin_record which returns a unique integer.
Definition: library.cpp:482
#define TIMEMORY_COMPONENTS_END
Definition: enum.h:155
::tim::statistics< Tp > max(::tim::statistics< Tp > lhs, const Tp &rhs)
Definition: statistics.hpp:320
components
Definition: settings.cpp:1700