opm-common
Loading...
Searching...
No Matches
TimingMacros.hpp
1/*
2 Copyright 2023 SINTEF Digital
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef OPM_TIMINGMACROS_HPP
20#define OPM_TIMINGMACROS_HPP
21
22#include <cstdint>
23
24// This file defines macros
25// OPM_TIMEBLOCK - time block of main part of codes which do not effect performance
26// OPM_TIMEFUNCTION - time block of main part of codes which do not effect performance with name from function
27// OPM_TIMEBLOCK_LOCAL - detailed timing which may effect performance
28// OPM_TIMEFUNCTION_LOCAL - detailed timing which may effect performance with name from function
29
30namespace Opm::Subsystem
31{
32// If more granularity is needed, add more members to the enum below,
33// but keep in mind to possibly increase the number of bits used in
34// the representation, as well as updating AnySystem to be just 1-bits
35// for the new representation.
36enum Bitfield : std::uint8_t
37{
38 None = 0,
39 PvtProps = 1 << 0,
40 SatProps = 1 << 1,
41 Assembly = 1 << 2,
42 LinearSolver = 1 << 3,
43 Output = 1 << 4,
44 Wells = 1 << 5,
45 Other = 1 << 6, // Consider expanding with more options instead.
46 AnySystem = 0xff // Matches any system.
47};
48} // namespace Opm::SubSystem
49
50#ifndef DETAILED_PROFILING
51#define DETAILED_PROFILING 0 // Turn detailed profiling off.
52// #define DETAILED_PROFILING 1 // Turn detailed profiling on.
53// The value of DETAILED_PROFILING_SUBSYSTEMS controls which subsystems are
54// active for detailed profiling. Some examples below.
55// #define DETAILED_PROFILING_SUBSYSTEMS (Opm::Subsystem::PvtProps | Opm::Subsystem::SatProps)
56// #define DETAILED_PROFILING_SUBSYSTEMS (Opm::Subsystem::Assembly)
57#endif
58
59#if USE_TRACY
60#define TRACY_ENABLE 1
61#include <tracy/Tracy.hpp>
62#define OPM_TIMEBLOCK(blockname) ZoneNamedN(blockname, #blockname, true)
63#define OPM_TIMEFUNCTION() ZoneNamedN(myname, __func__, true)
64#if DETAILED_PROFILING
65#define OPM_TIMEBLOCK_LOCAL(blockname, subsys) ZoneNamedN(blockname, #blockname, DETAILED_PROFILING_SUBSYSTEMS & subsys)
66#define OPM_TIMEFUNCTION_LOCAL(subsys) ZoneNamedN(myname, __func__, DETAILED_PROFILING_SUBSYSTEMS & subsys)
67#endif
68#endif
69
70#ifndef OPM_TIMEBLOCK
71#define OPM_TIMEBLOCK(x)\
72 do { /* nothing */ } while (false)
73#endif
74
75// detailed timing which may effect performance
76#ifndef OPM_TIMEBLOCK_LOCAL
77#define OPM_TIMEBLOCK_LOCAL(x, subsys)\
78 do { /* nothing */ } while (false)
79#endif
80
81#ifndef OPM_TIMEFUNCTION
82#define OPM_TIMEFUNCTION()\
83 do { /* nothing */ } while (false)
84#endif
85
86#ifndef OPM_TIMEFUNCTION_LOCAL
87#define OPM_TIMEFUNCTION_LOCAL(subsys)\
88 do { /* nothing */ } while (false)
89#endif
90
91#endif // OPM_TIMINGMACROS_HPP