Flags.h 9.66 KB
Newer Older
Simon Marlow's avatar
Simon Marlow committed
1 2
/* -----------------------------------------------------------------------------
 *
3
 * (c) The GHC Team, 1998-2009
Simon Marlow's avatar
Simon Marlow committed
4 5 6
 *
 * Datatypes that holds the command-line flag settings.
 *
7 8 9
 * Do not #include this file directly: #include "Rts.h" instead.
 *
 * To understand the structure of the RTS headers, see the wiki:
10
 *   http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11
 *
Simon Marlow's avatar
Simon Marlow committed
12 13 14 15 16 17 18 19 20
 * ---------------------------------------------------------------------------*/

#ifndef RTS_FLAGS_H
#define RTS_FLAGS_H

#include <stdio.h>

/* For defaults, see the @initRtsFlagsDefaults@ routine. */

21 22 23 24 25 26 27 28
/* Note [Synchronization of flags and base APIs]
 *
 * We provide accessors to RTS flags in base. (GHC.RTS module)
 * The API should be updated whenever RTS flags are modified.
 */

/* See Note [Synchronization of flags and base APIs] */
typedef struct _GC_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
29 30 31 32 33 34 35 36 37 38
    FILE   *statsFile;
    nat	    giveStats;
#define NO_GC_STATS	 0
#define COLLECT_GC_STATS 1
#define ONELINE_GC_STATS 2
#define SUMMARY_GC_STATS 3
#define VERBOSE_GC_STATS 4

    nat     maxStkSize;         /* in *words* */
    nat     initialStkSize;     /* in *words* */
39 40
    nat     stkChunkSize;       /* in *words* */
    nat     stkChunkBufferSize; /* in *words* */
Simon Marlow's avatar
Simon Marlow committed
41 42 43 44 45

    nat	    maxHeapSize;        /* in *blocks* */
    nat     minAllocAreaSize;   /* in *blocks* */
    nat     minOldGenSize;      /* in *blocks* */
    nat     heapSizeSuggestion; /* in *blocks* */
46
    rtsBool heapSizeSuggestionAuto;
Simon Marlow's avatar
Simon Marlow committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    double  oldGenFactor;
    double  pcFreeHeap;

    nat     generations;
    nat     steps;
    rtsBool squeezeUpdFrames;

    rtsBool compact;		/* True <=> "compact all the time" */
    double  compactThreshold;

    rtsBool sweep;		/* use "mostly mark-sweep" instead of copying
                                 * for the oldest generation */
    rtsBool ringBell;
    rtsBool frontpanel;

Simon Marlow's avatar
Simon Marlow committed
62
    Time    idleGCDelayTime;    /* units: TIME_RESOLUTION */
63
    rtsBool doIdleGC;
Simon Marlow's avatar
Simon Marlow committed
64 65

    StgWord heapBase;           /* address to ask the OS for memory */
66 67 68 69 70 71 72 73

    StgWord allocLimitGrace;    /* units: *blocks*
                                 * After an AllocationLimitExceeded
                                 * exception has been raised, how much
                                 * extra space is given to the thread
                                 * to handle the exception before we
                                 * raise it again.
                                 */
74
} GC_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
75

76 77
/* See Note [Synchronization of flags and base APIs] */
typedef struct _DEBUG_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    /* flags to control debugging output & extra checking in various subsystems */
    rtsBool scheduler;      /* 's' */
    rtsBool interpreter;    /* 'i' */
    rtsBool weak;           /* 'w' */
    rtsBool gccafs;         /* 'G' */
    rtsBool gc;             /* 'g' */
    rtsBool block_alloc;    /* 'b' */
    rtsBool sanity;         /* 'S'   warning: might be expensive! */
    rtsBool stable;         /* 't' */
    rtsBool prof;           /* 'p' */
    rtsBool linker;         /* 'l'   the object linker */
    rtsBool apply;          /* 'a' */
    rtsBool stm;            /* 'm' */
    rtsBool squeeze;        /* 'z'  stack squeezing & lazy blackholing */
    rtsBool hpc; 	    /* 'c' coverage */
93
    rtsBool sparks; 	    /* 'r' */
94
} DEBUG_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
95

96 97
/* See Note [Synchronization of flags and base APIs] */
typedef struct _COST_CENTRE_FLAGS {
Gabor Greif's avatar
Gabor Greif committed
98
    nat	    doCostCentres;
99
# define COST_CENTRES_NONE      0
Simon Marlow's avatar
Simon Marlow committed
100 101 102 103 104 105 106
# define COST_CENTRES_SUMMARY	1
# define COST_CENTRES_VERBOSE	2 /* incl. serial time profile */
# define COST_CENTRES_ALL	3
# define COST_CENTRES_XML       4

    int	    profilerTicks;   /* derived */
    int	    msecsPerTick;    /* derived */
107
} COST_CENTRE_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
108

109 110
/* See Note [Synchronization of flags and base APIs] */
typedef struct _PROFILING_FLAGS {
Gabor Greif's avatar
Gabor Greif committed
111
    nat	doHeapProfile;
Simon Marlow's avatar
Simon Marlow committed
112 113 114 115 116 117 118 119 120 121
# define NO_HEAP_PROFILING	0	/* N.B. Used as indexes into arrays */
# define HEAP_BY_CCS		1
# define HEAP_BY_MOD		2
# define HEAP_BY_DESCR		4
# define HEAP_BY_TYPE		5
# define HEAP_BY_RETAINER       6
# define HEAP_BY_LDV            7

# define HEAP_BY_CLOSURE_TYPE   8

Simon Marlow's avatar
Simon Marlow committed
122 123
    Time                heapProfileInterval; /* time between samples */
    nat                 heapProfileIntervalTicks; /* ticks between samples (derived) */
Simon Marlow's avatar
Simon Marlow committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    rtsBool             includeTSOs;


    rtsBool		showCCSOnException;

    nat                 maxRetainerSetSize;

    nat                 ccsLength;

    char*               modSelector;
    char*               descrSelector;
    char*               typeSelector;
    char*               ccSelector;
    char*               ccsSelector;
    char*               retainerSelector;
    char*               bioSelector;

141
} PROFILING_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
142

143 144 145 146
#define TRACE_NONE      0
#define TRACE_EVENTLOG  1
#define TRACE_STDERR    2

147 148
/* See Note [Synchronization of flags and base APIs] */
typedef struct _TRACE_FLAGS {
149
    int tracing;
150 151
    rtsBool timestamp;      /* show timestamp in stderr output */
    rtsBool scheduler;      /* trace scheduler events */
152
    rtsBool gc;             /* trace GC events */
153 154
    rtsBool sparks_sampled; /* trace spark events by a sampled method */
    rtsBool sparks_full;    /* trace spark events 100% accurately */
155
    rtsBool user;           /* trace user events (emitted from Haskell code) */
156
} TRACE_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
157

158 159
/* See Note [Synchronization of flags and base APIs] */
typedef struct _CONCURRENT_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
160 161
    Time ctxtSwitchTime;         /* units: TIME_RESOLUTION */
    int ctxtSwitchTicks;         /* derived */
162
} CONCURRENT_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
163

Simon Marlow's avatar
Simon Marlow committed
164 165 166 167 168 169 170 171 172
/*
 * The tickInterval is the time interval between "ticks", ie.
 * timer signals (see Timer.{c,h}).  It is the frequency at
 * which we sample CCCS for profiling.
 *
 * It is changed by the +RTS -V<secs> flag.
 */
#define DEFAULT_TICK_INTERVAL USToTime(10000)

173 174
/* See Note [Synchronization of flags and base APIs] */
typedef struct _MISC_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
175
    Time    tickInterval;        /* units: TIME_RESOLUTION */
Simon Marlow's avatar
Simon Marlow committed
176 177 178 179
    rtsBool install_signal_handlers;
    rtsBool machineReadable;
    StgWord linkerMemBase;       /* address to ask the OS for memory
                                  * for the linker, NULL ==> off */
180
} MISC_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
181 182

#ifdef THREADED_RTS
183 184
/* See Note [Synchronization of flags and base APIs] */
typedef struct _PAR_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
185 186
  nat            nNodes;         /* number of threads to run simultaneously */
  rtsBool        migrate;        /* migrate threads between capabilities */
Gabor Greif's avatar
Gabor Greif committed
187
  nat            maxLocalSparks;
Simon Marlow's avatar
Simon Marlow committed
188
  rtsBool        parGcEnabled;   /* enable parallel GC */
Gabor Greif's avatar
Gabor Greif committed
189
  nat            parGcGen;       /* do parallel GC in this generation
Simon Marlow's avatar
Simon Marlow committed
190
                                  * and higher only */
191 192 193
  rtsBool        parGcLoadBalancingEnabled; 
                                 /* enable load-balancing in the
                                  * parallel GC */
Gabor Greif's avatar
Gabor Greif committed
194
  nat            parGcLoadBalancingGen;
195 196
                                 /* do load-balancing in this
                                  * generation and higher only */
197

Gabor Greif's avatar
Gabor Greif committed
198
  nat            parGcNoSyncWithIdle;
199 200 201 202 203 204
                                 /* if a Capability has been idle for
                                  * this many GCs, do not try to wake
                                  * it up when doing a
                                  * non-load-balancing parallel GC.
                                  * (zero disables) */

Simon Marlow's avatar
Simon Marlow committed
205
  rtsBool        setAffinity;    /* force thread affinity with CPUs */
206
} PAR_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
207 208
#endif /* THREADED_RTS */

209 210
/* See Note [Synchronization of flags and base APIs] */
typedef struct _TICKY_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
211 212
    rtsBool showTickyStats;
    FILE   *tickyFile;
213
} TICKY_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
214 215 216 217

#ifdef USE_PAPI
#define MAX_PAPI_USER_EVENTS 8

218 219
/* See Note [Synchronization of flags and base APIs] */
typedef struct _PAPI_FLAGS {
Simon Marlow's avatar
Simon Marlow committed
220 221 222
    nat     eventType;          /* The type of events to count */
    nat     numUserEvents;
    char *  userEvents[MAX_PAPI_USER_EVENTS];
223 224
    /* Allow user to enter either PAPI preset or native events */
    nat     userEventsKind[MAX_PAPI_USER_EVENTS];
225
} PAPI_FLAGS;
Simon Marlow's avatar
Simon Marlow committed
226 227 228 229 230 231 232

#define PAPI_FLAG_CACHE_L1 1
#define PAPI_FLAG_CACHE_L2 2
#define PAPI_FLAG_BRANCH 3
#define PAPI_FLAG_STALLS 4
#define PAPI_FLAG_CB_EVENTS 5
#define PAPI_USER_EVENTS 6
233 234
#define PAPI_PRESET_EVENT_KIND 0
#define PAPI_NATIVE_EVENT_KIND 1
Simon Marlow's avatar
Simon Marlow committed
235 236 237 238 239

#endif

/* Put them together: */

240
/* See Note [Synchronization of flags and base APIs] */
Simon Marlow's avatar
Simon Marlow committed
241 242
typedef struct _RTS_FLAGS {
    /* The first portion of RTS_FLAGS is invariant. */
243 244 245 246 247 248 249 250
    GC_FLAGS	      GcFlags;
    CONCURRENT_FLAGS  ConcFlags;
    MISC_FLAGS        MiscFlags;
    DEBUG_FLAGS	      DebugFlags;
    COST_CENTRE_FLAGS CcFlags;
    PROFILING_FLAGS   ProfFlags;
    TRACE_FLAGS       TraceFlags;
    TICKY_FLAGS	      TickyFlags;
Simon Marlow's avatar
Simon Marlow committed
251 252

#if defined(THREADED_RTS)
253
    PAR_FLAGS	      ParFlags;
Simon Marlow's avatar
Simon Marlow committed
254 255
#endif
#ifdef USE_PAPI
256
    PAPI_FLAGS        PapiFlags;
Simon Marlow's avatar
Simon Marlow committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
#endif
} RTS_FLAGS;

#ifdef COMPILING_RTS_MAIN
extern DLLIMPORT RTS_FLAGS RtsFlags;
#elif IN_STG_CODE
/* Hack because the C code generator can't generate '&label'. */
extern RTS_FLAGS RtsFlags[];
#else
extern RTS_FLAGS RtsFlags;
#endif

/*
 * The printf formats are here, so we are less likely to make
 * overly-long filenames (with disastrous results).  No more than 128
 * chars, please!  
 */

#define STATS_FILENAME_MAXLEN	128

#define GR_FILENAME_FMT		"%0.124s.gr"
#define GR_FILENAME_FMT_GUM	"%0.120s.%03d.%s"
#define HP_FILENAME_FMT		"%0.124s.hp"
#define LIFE_FILENAME_FMT	"%0.122s.life"
#define PROF_FILENAME_FMT	"%0.122s.prof"
#define PROF_FILENAME_FMT_GUM	"%0.118s.%03d.prof"
#define QP_FILENAME_FMT		"%0.124s.qp"
#define STAT_FILENAME_FMT	"%0.122s.stat"
#define TICKY_FILENAME_FMT	"%0.121s.ticky"
#define TIME_FILENAME_FMT	"%0.122s.time"
#define TIME_FILENAME_FMT_GUM	"%0.118s.%03d.time"

/* an "int" so as to match normal "argc" */
/* Now defined in Stg.h (lib/std/cbits need these too.)
extern int     prog_argc;
extern char  **prog_argv;
*/
294 295
extern int      rts_argc;  /* ditto */
extern char   **rts_argv;
Simon Marlow's avatar
Simon Marlow committed
296 297

#endif	/* RTS_FLAGS_H */