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