Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb_statistics.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2019 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 
17 
18 
19 */
20 
21 #ifndef _TBB_tbb_statistics_H
22 #define _TBB_tbb_statistics_H
23 
63 #include "tbb/tbb_stddef.h"
64 
65 #ifndef __TBB_STATISTICS
66 #define __TBB_STATISTICS 0
67 #endif /* __TBB_STATISTICS */
68 
69 #if __TBB_STATISTICS
70 
71 #include <string.h> // for memset
72 
74 
75 #define __TBB_STATISTICS_STDOUT 1
76 
78 
80 #define __TBB_STATISTICS_TOTALS_ONLY 1
81 
83 
86 #define __TBB_STATISTICS_EARLY_DUMP 1
87 
88 #define GATHER_STATISTIC(x) (x)
89 
90 namespace tbb {
91 namespace internal {
92 
94 
96 enum statistics_groups {
97  sg_task_allocation = 0x01,
98  sg_task_execution = 0x02,
99  sg_stealing = 0x04,
100  sg_affinity = 0x08,
101  sg_arena = 0x10,
102  sg_market = 0x20,
103  sg_prio = 0x40,
104  sg_prio_ex = 0x80,
105  // List end marker. Insert new groups only before it.
106  sg_end
107 };
108 
110 const uintptr_t __TBB_ActiveStatisticsGroups = sg_task_execution | sg_stealing | sg_affinity | sg_arena | sg_market;
111 
113 
115 struct statistics_counters {
116  typedef long counter_type;
117 
118  // Group: sg_task_allocation
119  // Counters in this group can have negative values as the tasks migrate across
120  // threads while the associated counters are updated in the current thread only
121  // to avoid data races
122 
124  counter_type active_tasks;
126  counter_type free_list_length;
128 
129  counter_type big_tasks;
130 
131  // Group: sg_task_execution
132 
134  counter_type tasks_executed;
136  counter_type spawns_bypassed;
137 
138  // Group: sg_stealing
139 
141  counter_type steals_committed;
143  counter_type steals_failed;
145  counter_type thieves_conflicts;
147  counter_type thief_backoffs;
148 
149  // Group: sg_affinity
150 
152  counter_type mails_received;
154 
155  counter_type proxies_executed;
157  counter_type proxies_stolen;
159  counter_type proxies_bypassed;
161  counter_type affinity_ignored;
162 
163  // Group: sg_arena
164 
166  counter_type gate_switches;
168  counter_type arena_roundtrips;
169  // !Average concurrency level of this arena
170  counter_type avg_arena_concurrency;
172  counter_type avg_assigned_workers;
173 
174  // Group: sg_market
175 
177  counter_type market_roundtrips;
178 
179  // Group; sg_prio
180 
182  counter_type arena_prio_switches;
184  counter_type market_prio_switches;
186  counter_type arena_prio_resets;
188  counter_type prio_ref_fixups;
190  counter_type avg_arena_prio;
192  counter_type avg_market_prio;
193 
194  // Group; sg_prio_ex
195 
197  counter_type prio_winnowings;
199  counter_type prio_reloads;
201  counter_type prio_orphanings;
203  counter_type prio_tasks_offloaded;
205  counter_type prio_tasks_reloaded;
206 
207  // Constructor and helpers
208 
209  statistics_counters() { reset(); }
210 
211  void reset () { memset( this, 0, sizeof(statistics_counters) ); }
212 
213  counter_type& field ( size_t index ) { return reinterpret_cast<counter_type*>(this)[index]; }
214 
215  const counter_type& field ( size_t index ) const { return reinterpret_cast<const counter_type*>(this)[index]; }
216 
217  static size_t size () { return sizeof(statistics_counters) / sizeof(counter_type); }
218 
219  const statistics_counters& operator += ( const statistics_counters& rhs ) {
220  for ( size_t i = 0; i < size(); ++i )
221  field(i) += rhs.field(i);
222  return *this;
223  }
224 }; // statistics_counters
225 
226 static const size_t workers_counters_total = (size_t)-1;
227 static const size_t arena_counters_total = (size_t)-2;
228 
229 void dump_statistics ( const statistics_counters& c, size_t id );
230 
231 } // namespace internal
232 } // namespace tbb
233 
234 #else /* !__TBB_STATISTICS */
235 
236 #define GATHER_STATISTIC(x) ((void)0)
237 
238 #endif /* !__TBB_STATISTICS */
239 
240 #endif /* _TBB_tbb_statistics_H */
The graph class.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t size

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.