docs-6.2.1/source/lib/omnitrace-user/omnitrace/causal.h Source File

docs-6.2.1/source/lib/omnitrace-user/omnitrace/causal.h Source File#

omnitrace: docs-6.2.1/source/lib/omnitrace-user/omnitrace/causal.h Source File
causal.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved.
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 /** @file causal.h */
24 
25 #ifndef OMNITRACE_CAUSAL_H_
26 #define OMNITRACE_CAUSAL_H_
27 
28 /**
29  * @defgroup OMNITRACE_CASUAL_GROUP OmniTrace Causal Profiling Defines
30  *
31  * @{
32  */
33 
34 #if !defined(OMNITRACE_CAUSAL_ENABLED)
35 /** Preprocessor switch to enable/disable instrumentation for causal profiling */
36 # define OMNITRACE_CAUSAL_ENABLED 1
37 #endif
38 
39 #if OMNITRACE_CAUSAL_ENABLED > 0
40 # include <omnitrace/user.h>
41 
42 # if !defined(OMNITRACE_CAUSAL_LABEL)
43 /** @cond OMNITRACE_HIDDEN_DEFINES */
44 # define OMNITRACE_CAUSAL_STR2(x) # x
45 # define OMNITRACE_CAUSAL_STR(x) OMNITRACE_CAUSAL_STR2(x)
46 /** @endcond */
47 /** Default label for a causal progress point */
48 # define OMNITRACE_CAUSAL_LABEL __FILE__ ":" OMNITRACE_CAUSAL_STR(__LINE__)
49 # endif
50 # if !defined(OMNITRACE_CAUSAL_PROGRESS)
51 /** Adds a throughput progress point with label `<file>:<line>` */
52 # define OMNITRACE_CAUSAL_PROGRESS omnitrace_user_progress(OMNITRACE_CAUSAL_LABEL);
53 # endif
54 # if !defined(OMNITRACE_CAUSAL_PROGRESS_NAMED)
55 /** Adds a throughput progress point with user defined label. Each instance should use a
56  * unique label. */
57 # define OMNITRACE_CAUSAL_PROGRESS_NAMED(LABEL) omnitrace_user_progress(LABEL);
58 # endif
59 # if !defined(OMNITRACE_CAUSAL_BEGIN)
60 /** Starts a latency progress point (region of interest) with user defined label. Each
61  * instance should use a unique label. */
62 # define OMNITRACE_CAUSAL_BEGIN(LABEL) omnitrace_user_push_region(LABEL);
63 # endif
64 # if !defined(OMNITRACE_CAUSAL_END)
65 /** End the latency progress point (region of interest) for the matching user defined
66  * label. */
67 # define OMNITRACE_CAUSAL_END(LABEL) omnitrace_user_pop_region(LABEL);
68 # endif
69 #else
70 # if !defined(OMNITRACE_CAUSAL_PROGRESS)
71 # define OMNITRACE_CAUSAL_PROGRESS
72 # endif
73 # if !defined(OMNITRACE_CAUSAL_PROGRESS_NAMED)
74 # define OMNITRACE_CAUSAL_PROGRESS_NAMED(LABEL)
75 # endif
76 # if !defined(OMNITRACE_CAUSAL_BEGIN)
77 # define OMNITRACE_CAUSAL_BEGIN(LABEL)
78 # endif
79 # if !defined(OMNITRACE_CAUSAL_END)
80 # define OMNITRACE_CAUSAL_END(LABEL)
81 # endif
82 #endif
83 
84 /** @} */
85 
86 #endif // OMNITRACE_CAUSAL_H_