add a new trace class for spark events
[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://hackage.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 int idleGCDelayTime; /* in milliseconds */
56
57 StgWord heapBase; /* address to ask the OS for memory */
58 };
59
60 struct DEBUG_FLAGS {
61 /* flags to control debugging output & extra checking in various subsystems */
62 rtsBool scheduler; /* 's' */
63 rtsBool interpreter; /* 'i' */
64 rtsBool weak; /* 'w' */
65 rtsBool gccafs; /* 'G' */
66 rtsBool gc; /* 'g' */
67 rtsBool block_alloc; /* 'b' */
68 rtsBool sanity; /* 'S' warning: might be expensive! */
69 rtsBool stable; /* 't' */
70 rtsBool prof; /* 'p' */
71 rtsBool linker; /* 'l' the object linker */
72 rtsBool apply; /* 'a' */
73 rtsBool stm; /* 'm' */
74 rtsBool squeeze; /* 'z' stack squeezing & lazy blackholing */
75 rtsBool hpc; /* 'c' coverage */
76 rtsBool sparks; /* 'r' */
77 };
78
79 struct COST_CENTRE_FLAGS {
80 unsigned int doCostCentres;
81 # define COST_CENTRES_SUMMARY 1
82 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
83 # define COST_CENTRES_ALL 3
84 # define COST_CENTRES_XML 4
85
86 int profilerTicks; /* derived */
87 int msecsPerTick; /* derived */
88 };
89
90 struct PROFILING_FLAGS {
91 unsigned int doHeapProfile;
92 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
93 # define HEAP_BY_CCS 1
94 # define HEAP_BY_MOD 2
95 # define HEAP_BY_DESCR 4
96 # define HEAP_BY_TYPE 5
97 # define HEAP_BY_RETAINER 6
98 # define HEAP_BY_LDV 7
99
100 # define HEAP_BY_CLOSURE_TYPE 8
101
102 nat profileInterval; /* delta between samples (in ms) */
103 nat profileIntervalTicks; /* delta between samples (in 'ticks') */
104 rtsBool includeTSOs;
105
106
107 rtsBool showCCSOnException;
108
109 nat maxRetainerSetSize;
110
111 nat ccsLength;
112
113 char* modSelector;
114 char* descrSelector;
115 char* typeSelector;
116 char* ccSelector;
117 char* ccsSelector;
118 char* retainerSelector;
119 char* bioSelector;
120
121 };
122
123 #define TRACE_NONE 0
124 #define TRACE_EVENTLOG 1
125 #define TRACE_STDERR 2
126
127 struct TRACE_FLAGS {
128 int tracing;
129 rtsBool timestamp; /* show timestamp in stderr output */
130 rtsBool scheduler; /* trace scheduler events */
131 rtsBool sparks; /* trace spark events */
132 };
133
134 struct CONCURRENT_FLAGS {
135 int ctxtSwitchTime; /* in milliseconds */
136 int ctxtSwitchTicks; /* derived */
137 };
138
139 struct MISC_FLAGS {
140 int tickInterval; /* in milliseconds */
141 rtsBool install_signal_handlers;
142 rtsBool machineReadable;
143 StgWord linkerMemBase; /* address to ask the OS for memory
144 * for the linker, NULL ==> off */
145 };
146
147 #ifdef THREADED_RTS
148 struct PAR_FLAGS {
149 nat nNodes; /* number of threads to run simultaneously */
150 rtsBool migrate; /* migrate threads between capabilities */
151 unsigned int maxLocalSparks;
152 rtsBool parGcEnabled; /* enable parallel GC */
153 unsigned int parGcGen; /* do parallel GC in this generation
154 * and higher only */
155 rtsBool parGcLoadBalancingEnabled;
156 /* enable load-balancing in the
157 * parallel GC */
158 unsigned int parGcLoadBalancingGen;
159 /* do load-balancing in this
160 * generation and higher only */
161 rtsBool setAffinity; /* force thread affinity with CPUs */
162 };
163 #endif /* THREADED_RTS */
164
165 struct TICKY_FLAGS {
166 rtsBool showTickyStats;
167 FILE *tickyFile;
168 };
169
170 #ifdef USE_PAPI
171 #define MAX_PAPI_USER_EVENTS 8
172
173 struct PAPI_FLAGS {
174 nat eventType; /* The type of events to count */
175 nat numUserEvents;
176 char * userEvents[MAX_PAPI_USER_EVENTS];
177 /* Allow user to enter either PAPI preset or native events */
178 nat userEventsKind[MAX_PAPI_USER_EVENTS];
179 };
180
181 #define PAPI_FLAG_CACHE_L1 1
182 #define PAPI_FLAG_CACHE_L2 2
183 #define PAPI_FLAG_BRANCH 3
184 #define PAPI_FLAG_STALLS 4
185 #define PAPI_FLAG_CB_EVENTS 5
186 #define PAPI_USER_EVENTS 6
187 #define PAPI_PRESET_EVENT_KIND 0
188 #define PAPI_NATIVE_EVENT_KIND 1
189
190 #endif
191
192 /* Put them together: */
193
194 typedef struct _RTS_FLAGS {
195 /* The first portion of RTS_FLAGS is invariant. */
196 struct GC_FLAGS GcFlags;
197 struct CONCURRENT_FLAGS ConcFlags;
198 struct MISC_FLAGS MiscFlags;
199 struct DEBUG_FLAGS DebugFlags;
200 struct COST_CENTRE_FLAGS CcFlags;
201 struct PROFILING_FLAGS ProfFlags;
202 struct TRACE_FLAGS TraceFlags;
203 struct TICKY_FLAGS TickyFlags;
204
205 #if defined(THREADED_RTS)
206 struct PAR_FLAGS ParFlags;
207 #endif
208 #ifdef USE_PAPI
209 struct PAPI_FLAGS PapiFlags;
210 #endif
211 } RTS_FLAGS;
212
213 #ifdef COMPILING_RTS_MAIN
214 extern DLLIMPORT RTS_FLAGS RtsFlags;
215 #elif IN_STG_CODE
216 /* Hack because the C code generator can't generate '&label'. */
217 extern RTS_FLAGS RtsFlags[];
218 #else
219 extern RTS_FLAGS RtsFlags;
220 #endif
221
222 /*
223 * The printf formats are here, so we are less likely to make
224 * overly-long filenames (with disastrous results). No more than 128
225 * chars, please!
226 */
227
228 #define STATS_FILENAME_MAXLEN 128
229
230 #define GR_FILENAME_FMT "%0.124s.gr"
231 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
232 #define HP_FILENAME_FMT "%0.124s.hp"
233 #define LIFE_FILENAME_FMT "%0.122s.life"
234 #define PROF_FILENAME_FMT "%0.122s.prof"
235 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
236 #define QP_FILENAME_FMT "%0.124s.qp"
237 #define STAT_FILENAME_FMT "%0.122s.stat"
238 #define TICKY_FILENAME_FMT "%0.121s.ticky"
239 #define TIME_FILENAME_FMT "%0.122s.time"
240 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
241
242 /* an "int" so as to match normal "argc" */
243 /* Now defined in Stg.h (lib/std/cbits need these too.)
244 extern int prog_argc;
245 extern char **prog_argv;
246 */
247 extern int rts_argc; /* ditto */
248 extern char **rts_argv;
249
250 #endif /* RTS_FLAGS_H */