[ci skip] includes: detabify/dewhitespace rts/Hpc.h
[ghc.git] / includes / rts / Flags.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2009
4 *
5 * Datatypes that holds the command-line flag settings.
6 *
7 * Do not #include this file directly: #include "Rts.h" instead.
8 *
9 * To understand the structure of the RTS headers, see the wiki:
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #ifndef RTS_FLAGS_H
15 #define RTS_FLAGS_H
16
17 #include <stdio.h>
18
19 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
20
21 struct GC_FLAGS {
22 FILE *statsFile;
23 nat giveStats;
24 #define NO_GC_STATS 0
25 #define COLLECT_GC_STATS 1
26 #define ONELINE_GC_STATS 2
27 #define SUMMARY_GC_STATS 3
28 #define VERBOSE_GC_STATS 4
29
30 nat maxStkSize; /* in *words* */
31 nat initialStkSize; /* in *words* */
32 nat stkChunkSize; /* in *words* */
33 nat stkChunkBufferSize; /* in *words* */
34
35 nat maxHeapSize; /* in *blocks* */
36 nat minAllocAreaSize; /* in *blocks* */
37 nat minOldGenSize; /* in *blocks* */
38 nat heapSizeSuggestion; /* in *blocks* */
39 rtsBool heapSizeSuggestionAuto;
40 double oldGenFactor;
41 double pcFreeHeap;
42
43 nat generations;
44 nat steps;
45 rtsBool squeezeUpdFrames;
46
47 rtsBool compact; /* True <=> "compact all the time" */
48 double compactThreshold;
49
50 rtsBool sweep; /* use "mostly mark-sweep" instead of copying
51 * for the oldest generation */
52 rtsBool ringBell;
53 rtsBool frontpanel;
54
55 Time idleGCDelayTime; /* units: TIME_RESOLUTION */
56 rtsBool doIdleGC;
57
58 StgWord heapBase; /* address to ask the OS for memory */
59 };
60
61 struct DEBUG_FLAGS {
62 /* flags to control debugging output & extra checking in various subsystems */
63 rtsBool scheduler; /* 's' */
64 rtsBool interpreter; /* 'i' */
65 rtsBool weak; /* 'w' */
66 rtsBool gccafs; /* 'G' */
67 rtsBool gc; /* 'g' */
68 rtsBool block_alloc; /* 'b' */
69 rtsBool sanity; /* 'S' warning: might be expensive! */
70 rtsBool stable; /* 't' */
71 rtsBool prof; /* 'p' */
72 rtsBool linker; /* 'l' the object linker */
73 rtsBool apply; /* 'a' */
74 rtsBool stm; /* 'm' */
75 rtsBool squeeze; /* 'z' stack squeezing & lazy blackholing */
76 rtsBool hpc; /* 'c' coverage */
77 rtsBool sparks; /* 'r' */
78 };
79
80 struct COST_CENTRE_FLAGS {
81 nat doCostCentres;
82 # define COST_CENTRES_SUMMARY 1
83 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
84 # define COST_CENTRES_ALL 3
85 # define COST_CENTRES_XML 4
86
87 int profilerTicks; /* derived */
88 int msecsPerTick; /* derived */
89 };
90
91 struct PROFILING_FLAGS {
92 nat doHeapProfile;
93 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
94 # define HEAP_BY_CCS 1
95 # define HEAP_BY_MOD 2
96 # define HEAP_BY_DESCR 4
97 # define HEAP_BY_TYPE 5
98 # define HEAP_BY_RETAINER 6
99 # define HEAP_BY_LDV 7
100
101 # define HEAP_BY_CLOSURE_TYPE 8
102
103 Time heapProfileInterval; /* time between samples */
104 nat heapProfileIntervalTicks; /* ticks between samples (derived) */
105 rtsBool includeTSOs;
106
107
108 rtsBool showCCSOnException;
109
110 nat maxRetainerSetSize;
111
112 nat ccsLength;
113
114 char* modSelector;
115 char* descrSelector;
116 char* typeSelector;
117 char* ccSelector;
118 char* ccsSelector;
119 char* retainerSelector;
120 char* bioSelector;
121
122 };
123
124 #define TRACE_NONE 0
125 #define TRACE_EVENTLOG 1
126 #define TRACE_STDERR 2
127
128 struct TRACE_FLAGS {
129 int tracing;
130 rtsBool timestamp; /* show timestamp in stderr output */
131 rtsBool scheduler; /* trace scheduler events */
132 rtsBool gc; /* trace GC events */
133 rtsBool sparks_sampled; /* trace spark events by a sampled method */
134 rtsBool sparks_full; /* trace spark events 100% accurately */
135 rtsBool user; /* trace user events (emitted from Haskell code) */
136 };
137
138 struct CONCURRENT_FLAGS {
139 Time ctxtSwitchTime; /* units: TIME_RESOLUTION */
140 int ctxtSwitchTicks; /* derived */
141 };
142
143 /*
144 * The tickInterval is the time interval between "ticks", ie.
145 * timer signals (see Timer.{c,h}). It is the frequency at
146 * which we sample CCCS for profiling.
147 *
148 * It is changed by the +RTS -V<secs> flag.
149 */
150 #define DEFAULT_TICK_INTERVAL USToTime(10000)
151
152 struct MISC_FLAGS {
153 Time tickInterval; /* units: TIME_RESOLUTION */
154 rtsBool install_signal_handlers;
155 rtsBool machineReadable;
156 StgWord linkerMemBase; /* address to ask the OS for memory
157 * for the linker, NULL ==> off */
158 };
159
160 #ifdef THREADED_RTS
161 struct PAR_FLAGS {
162 nat nNodes; /* number of threads to run simultaneously */
163 rtsBool migrate; /* migrate threads between capabilities */
164 nat maxLocalSparks;
165 rtsBool parGcEnabled; /* enable parallel GC */
166 nat parGcGen; /* do parallel GC in this generation
167 * and higher only */
168 rtsBool parGcLoadBalancingEnabled;
169 /* enable load-balancing in the
170 * parallel GC */
171 nat parGcLoadBalancingGen;
172 /* do load-balancing in this
173 * generation and higher only */
174
175 nat parGcNoSyncWithIdle;
176 /* if a Capability has been idle for
177 * this many GCs, do not try to wake
178 * it up when doing a
179 * non-load-balancing parallel GC.
180 * (zero disables) */
181
182 rtsBool setAffinity; /* force thread affinity with CPUs */
183 };
184 #endif /* THREADED_RTS */
185
186 struct TICKY_FLAGS {
187 rtsBool showTickyStats;
188 FILE *tickyFile;
189 };
190
191 #ifdef USE_PAPI
192 #define MAX_PAPI_USER_EVENTS 8
193
194 struct PAPI_FLAGS {
195 nat eventType; /* The type of events to count */
196 nat numUserEvents;
197 char * userEvents[MAX_PAPI_USER_EVENTS];
198 /* Allow user to enter either PAPI preset or native events */
199 nat userEventsKind[MAX_PAPI_USER_EVENTS];
200 };
201
202 #define PAPI_FLAG_CACHE_L1 1
203 #define PAPI_FLAG_CACHE_L2 2
204 #define PAPI_FLAG_BRANCH 3
205 #define PAPI_FLAG_STALLS 4
206 #define PAPI_FLAG_CB_EVENTS 5
207 #define PAPI_USER_EVENTS 6
208 #define PAPI_PRESET_EVENT_KIND 0
209 #define PAPI_NATIVE_EVENT_KIND 1
210
211 #endif
212
213 /* Put them together: */
214
215 typedef struct _RTS_FLAGS {
216 /* The first portion of RTS_FLAGS is invariant. */
217 struct GC_FLAGS GcFlags;
218 struct CONCURRENT_FLAGS ConcFlags;
219 struct MISC_FLAGS MiscFlags;
220 struct DEBUG_FLAGS DebugFlags;
221 struct COST_CENTRE_FLAGS CcFlags;
222 struct PROFILING_FLAGS ProfFlags;
223 struct TRACE_FLAGS TraceFlags;
224 struct TICKY_FLAGS TickyFlags;
225
226 #if defined(THREADED_RTS)
227 struct PAR_FLAGS ParFlags;
228 #endif
229 #ifdef USE_PAPI
230 struct PAPI_FLAGS PapiFlags;
231 #endif
232 } RTS_FLAGS;
233
234 #ifdef COMPILING_RTS_MAIN
235 extern DLLIMPORT RTS_FLAGS RtsFlags;
236 #elif IN_STG_CODE
237 /* Hack because the C code generator can't generate '&label'. */
238 extern RTS_FLAGS RtsFlags[];
239 #else
240 extern RTS_FLAGS RtsFlags;
241 #endif
242
243 /*
244 * The printf formats are here, so we are less likely to make
245 * overly-long filenames (with disastrous results). No more than 128
246 * chars, please!
247 */
248
249 #define STATS_FILENAME_MAXLEN 128
250
251 #define GR_FILENAME_FMT "%0.124s.gr"
252 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
253 #define HP_FILENAME_FMT "%0.124s.hp"
254 #define LIFE_FILENAME_FMT "%0.122s.life"
255 #define PROF_FILENAME_FMT "%0.122s.prof"
256 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
257 #define QP_FILENAME_FMT "%0.124s.qp"
258 #define STAT_FILENAME_FMT "%0.122s.stat"
259 #define TICKY_FILENAME_FMT "%0.121s.ticky"
260 #define TIME_FILENAME_FMT "%0.122s.time"
261 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
262
263 /* an "int" so as to match normal "argc" */
264 /* Now defined in Stg.h (lib/std/cbits need these too.)
265 extern int prog_argc;
266 extern char **prog_argv;
267 */
268 extern int rts_argc; /* ditto */
269 extern char **rts_argv;
270
271 #endif /* RTS_FLAGS_H */