xref: /aosp_15_r20/external/pytorch/third_party/valgrind-headers/callgrind.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard Worker 
2*da0073e9SAndroid Build Coastguard Worker /*
3*da0073e9SAndroid Build Coastguard Worker    ----------------------------------------------------------------
4*da0073e9SAndroid Build Coastguard Worker 
5*da0073e9SAndroid Build Coastguard Worker    Notice that the following BSD-style license applies to this one
6*da0073e9SAndroid Build Coastguard Worker    file (callgrind.h) only.  The rest of Valgrind is licensed under the
7*da0073e9SAndroid Build Coastguard Worker    terms of the GNU General Public License, version 2, unless
8*da0073e9SAndroid Build Coastguard Worker    otherwise indicated.  See the COPYING file in the source
9*da0073e9SAndroid Build Coastguard Worker    distribution for details.
10*da0073e9SAndroid Build Coastguard Worker 
11*da0073e9SAndroid Build Coastguard Worker    ----------------------------------------------------------------
12*da0073e9SAndroid Build Coastguard Worker 
13*da0073e9SAndroid Build Coastguard Worker    This file is part of callgrind, a valgrind tool for cache simulation
14*da0073e9SAndroid Build Coastguard Worker    and call tree tracing.
15*da0073e9SAndroid Build Coastguard Worker 
16*da0073e9SAndroid Build Coastguard Worker    Copyright (C) 2003-2017 Josef Weidendorfer.  All rights reserved.
17*da0073e9SAndroid Build Coastguard Worker 
18*da0073e9SAndroid Build Coastguard Worker    Redistribution and use in source and binary forms, with or without
19*da0073e9SAndroid Build Coastguard Worker    modification, are permitted provided that the following conditions
20*da0073e9SAndroid Build Coastguard Worker    are met:
21*da0073e9SAndroid Build Coastguard Worker 
22*da0073e9SAndroid Build Coastguard Worker    1. Redistributions of source code must retain the above copyright
23*da0073e9SAndroid Build Coastguard Worker       notice, this list of conditions and the following disclaimer.
24*da0073e9SAndroid Build Coastguard Worker 
25*da0073e9SAndroid Build Coastguard Worker    2. The origin of this software must not be misrepresented; you must
26*da0073e9SAndroid Build Coastguard Worker       not claim that you wrote the original software.  If you use this
27*da0073e9SAndroid Build Coastguard Worker       software in a product, an acknowledgment in the product
28*da0073e9SAndroid Build Coastguard Worker       documentation would be appreciated but is not required.
29*da0073e9SAndroid Build Coastguard Worker 
30*da0073e9SAndroid Build Coastguard Worker    3. Altered source versions must be plainly marked as such, and must
31*da0073e9SAndroid Build Coastguard Worker       not be misrepresented as being the original software.
32*da0073e9SAndroid Build Coastguard Worker 
33*da0073e9SAndroid Build Coastguard Worker    4. The name of the author may not be used to endorse or promote
34*da0073e9SAndroid Build Coastguard Worker       products derived from this software without specific prior written
35*da0073e9SAndroid Build Coastguard Worker       permission.
36*da0073e9SAndroid Build Coastguard Worker 
37*da0073e9SAndroid Build Coastguard Worker    THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
38*da0073e9SAndroid Build Coastguard Worker    OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
39*da0073e9SAndroid Build Coastguard Worker    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40*da0073e9SAndroid Build Coastguard Worker    ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
41*da0073e9SAndroid Build Coastguard Worker    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42*da0073e9SAndroid Build Coastguard Worker    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
43*da0073e9SAndroid Build Coastguard Worker    GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44*da0073e9SAndroid Build Coastguard Worker    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45*da0073e9SAndroid Build Coastguard Worker    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
46*da0073e9SAndroid Build Coastguard Worker    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47*da0073e9SAndroid Build Coastguard Worker    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48*da0073e9SAndroid Build Coastguard Worker 
49*da0073e9SAndroid Build Coastguard Worker    ----------------------------------------------------------------
50*da0073e9SAndroid Build Coastguard Worker 
51*da0073e9SAndroid Build Coastguard Worker    Notice that the above BSD-style license applies to this one file
52*da0073e9SAndroid Build Coastguard Worker    (callgrind.h) only.  The entire rest of Valgrind is licensed under
53*da0073e9SAndroid Build Coastguard Worker    the terms of the GNU General Public License, version 2.  See the
54*da0073e9SAndroid Build Coastguard Worker    COPYING file in the source distribution for details.
55*da0073e9SAndroid Build Coastguard Worker 
56*da0073e9SAndroid Build Coastguard Worker    ----------------------------------------------------------------
57*da0073e9SAndroid Build Coastguard Worker */
58*da0073e9SAndroid Build Coastguard Worker 
59*da0073e9SAndroid Build Coastguard Worker #ifndef __CALLGRIND_H
60*da0073e9SAndroid Build Coastguard Worker #define __CALLGRIND_H
61*da0073e9SAndroid Build Coastguard Worker 
62*da0073e9SAndroid Build Coastguard Worker #include "valgrind.h"
63*da0073e9SAndroid Build Coastguard Worker 
64*da0073e9SAndroid Build Coastguard Worker /* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
65*da0073e9SAndroid Build Coastguard Worker    This enum comprises an ABI exported by Valgrind to programs
66*da0073e9SAndroid Build Coastguard Worker    which use client requests.  DO NOT CHANGE THE ORDER OF THESE
67*da0073e9SAndroid Build Coastguard Worker    ENTRIES, NOR DELETE ANY -- add new ones at the end.
68*da0073e9SAndroid Build Coastguard Worker 
69*da0073e9SAndroid Build Coastguard Worker    The identification ('C','T') for Callgrind has historical
70*da0073e9SAndroid Build Coastguard Worker    reasons: it was called "Calltree" before. Besides, ('C','G') would
71*da0073e9SAndroid Build Coastguard Worker    clash with cachegrind.
72*da0073e9SAndroid Build Coastguard Worker  */
73*da0073e9SAndroid Build Coastguard Worker 
74*da0073e9SAndroid Build Coastguard Worker typedef
75*da0073e9SAndroid Build Coastguard Worker    enum {
76*da0073e9SAndroid Build Coastguard Worker       VG_USERREQ__DUMP_STATS = VG_USERREQ_TOOL_BASE('C','T'),
77*da0073e9SAndroid Build Coastguard Worker       VG_USERREQ__ZERO_STATS,
78*da0073e9SAndroid Build Coastguard Worker       VG_USERREQ__TOGGLE_COLLECT,
79*da0073e9SAndroid Build Coastguard Worker       VG_USERREQ__DUMP_STATS_AT,
80*da0073e9SAndroid Build Coastguard Worker       VG_USERREQ__START_INSTRUMENTATION,
81*da0073e9SAndroid Build Coastguard Worker       VG_USERREQ__STOP_INSTRUMENTATION
82*da0073e9SAndroid Build Coastguard Worker    } Vg_CallgrindClientRequest;
83*da0073e9SAndroid Build Coastguard Worker 
84*da0073e9SAndroid Build Coastguard Worker /* Dump current state of cost centers, and zero them afterwards */
85*da0073e9SAndroid Build Coastguard Worker #define CALLGRIND_DUMP_STATS                                    \
86*da0073e9SAndroid Build Coastguard Worker   VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DUMP_STATS,       \
87*da0073e9SAndroid Build Coastguard Worker                                   0, 0, 0, 0, 0)
88*da0073e9SAndroid Build Coastguard Worker 
89*da0073e9SAndroid Build Coastguard Worker /* Dump current state of cost centers, and zero them afterwards.
90*da0073e9SAndroid Build Coastguard Worker    The argument is appended to a string stating the reason which triggered
91*da0073e9SAndroid Build Coastguard Worker    the dump. This string is written as a description field into the
92*da0073e9SAndroid Build Coastguard Worker    profile data dump. */
93*da0073e9SAndroid Build Coastguard Worker #define CALLGRIND_DUMP_STATS_AT(pos_str)                        \
94*da0073e9SAndroid Build Coastguard Worker   VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DUMP_STATS_AT,    \
95*da0073e9SAndroid Build Coastguard Worker                                   pos_str, 0, 0, 0, 0)
96*da0073e9SAndroid Build Coastguard Worker 
97*da0073e9SAndroid Build Coastguard Worker /* Zero cost centers */
98*da0073e9SAndroid Build Coastguard Worker #define CALLGRIND_ZERO_STATS                                    \
99*da0073e9SAndroid Build Coastguard Worker   VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__ZERO_STATS,       \
100*da0073e9SAndroid Build Coastguard Worker                                   0, 0, 0, 0, 0)
101*da0073e9SAndroid Build Coastguard Worker 
102*da0073e9SAndroid Build Coastguard Worker /* Toggles collection state.
103*da0073e9SAndroid Build Coastguard Worker    The collection state specifies whether the happening of events
104*da0073e9SAndroid Build Coastguard Worker    should be noted or if they are to be ignored. Events are noted
105*da0073e9SAndroid Build Coastguard Worker    by increment of counters in a cost center */
106*da0073e9SAndroid Build Coastguard Worker #define CALLGRIND_TOGGLE_COLLECT                                \
107*da0073e9SAndroid Build Coastguard Worker   VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__TOGGLE_COLLECT,   \
108*da0073e9SAndroid Build Coastguard Worker                                   0, 0, 0, 0, 0)
109*da0073e9SAndroid Build Coastguard Worker 
110*da0073e9SAndroid Build Coastguard Worker /* Start full callgrind instrumentation if not already switched on.
111*da0073e9SAndroid Build Coastguard Worker    When cache simulation is done, it will flush the simulated cache;
112*da0073e9SAndroid Build Coastguard Worker    this will lead to an artificial cache warmup phase afterwards with
113*da0073e9SAndroid Build Coastguard Worker    cache misses which would not have happened in reality. */
114*da0073e9SAndroid Build Coastguard Worker #define CALLGRIND_START_INSTRUMENTATION                              \
115*da0073e9SAndroid Build Coastguard Worker   VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__START_INSTRUMENTATION, \
116*da0073e9SAndroid Build Coastguard Worker                                   0, 0, 0, 0, 0)
117*da0073e9SAndroid Build Coastguard Worker 
118*da0073e9SAndroid Build Coastguard Worker /* Stop full callgrind instrumentation if not already switched off.
119*da0073e9SAndroid Build Coastguard Worker    This flushes Valgrinds translation cache, and does no additional
120*da0073e9SAndroid Build Coastguard Worker    instrumentation afterwards, which effectivly will run at the same
121*da0073e9SAndroid Build Coastguard Worker    speed as the "none" tool (ie. at minimal slowdown).
122*da0073e9SAndroid Build Coastguard Worker    Use this to bypass Callgrind aggregation for uninteresting code parts.
123*da0073e9SAndroid Build Coastguard Worker    To start Callgrind in this mode to ignore the setup phase, use
124*da0073e9SAndroid Build Coastguard Worker    the option "--instr-atstart=no". */
125*da0073e9SAndroid Build Coastguard Worker #define CALLGRIND_STOP_INSTRUMENTATION                               \
126*da0073e9SAndroid Build Coastguard Worker   VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__STOP_INSTRUMENTATION,  \
127*da0073e9SAndroid Build Coastguard Worker                                   0, 0, 0, 0, 0)
128*da0073e9SAndroid Build Coastguard Worker 
129*da0073e9SAndroid Build Coastguard Worker #endif /* __CALLGRIND_H */
130