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