RtsFlags.c 67.6 KB
Newer Older
1

2
/* -----------------------------------------------------------------------------
3 4 5
 *
 * (c) The AQUA Project, Glasgow University, 1994-1997
 * (c) The GHC Team, 1998-1999
6 7 8 9 10
 *
 * Functions for parsing the argument list.
 *
 * ---------------------------------------------------------------------------*/

11
#include "PosixSource.h"
12 13 14 15
#include "Rts.h"
#include "RtsFlags.h"
#include "RtsUtils.h"
#include "BlockAlloc.h"
sof's avatar
sof committed
16
#include "Timer.h"		/* CS_MIN_MILLISECS */
17
#include "Profiling.h"
18

19 20
#ifdef HAVE_CTYPE_H
#include <ctype.h>
21 22
#endif

23 24 25
#include <stdlib.h>
#include <string.h>

26 27
// Flag Structure
RTS_FLAGS RtsFlags;
28 29 30 31

/*
 * Split argument lists
 */
sof's avatar
sof committed
32
int     prog_argc = 0;    /* an "int" so as to match normal "argc" */
33
char  **prog_argv = NULL;
sof's avatar
sof committed
34
char   *prog_name = NULL; /* 'basename' of prog_argv[0] */
35
int     rts_argc = 0;  /* ditto */
36 37 38 39 40 41 42 43
char   *rts_argv[MAX_RTS_ARGS];

/*
 * constants, used later 
 */
#define RTS 1
#define PGM 0

44 45
#if defined(GRAN)

sof's avatar
sof committed
46
static char *gran_debug_opts_strs[] = {
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  "DEBUG (-bDe, -bD1): event_trace; printing event trace.\n",
  "DEBUG (-bDE, -bD2): event_stats; printing event statistics.\n",
  "DEBUG (-bDb, -bD4): bq; check blocking queues\n",
  "DEBUG (-bDG, -bD8): pack; routines for (un-)packing graph structures.\n",
  "DEBUG (-bDq, -bD16): checkSparkQ; check consistency of the spark queues.\n",
  "DEBUG (-bDf, -bD32): thunkStealing; print forwarding of fetches.\n",
  "DEBUG (-bDr, -bD64): randomSteal; stealing sparks/threads from random PEs.\n",
  "DEBUG (-bDF, -bD128): findWork; searching spark-pools (local & remote), thread queues for work.\n",
  "DEBUG (-bDu, -bD256): unused; currently unused flag.\n",
  "DEBUG (-bDS, -bD512): pri; priority sparking or scheduling.\n",
  "DEBUG (-bD:, -bD1024): checkLight; check GranSim-Light setup.\n",
  "DEBUG (-bDo, -bD2048): sortedQ; check whether spark/thread queues are sorted.\n",
  "DEBUG (-bDz, -bD4096): blockOnFetch; check for blocked on fetch.\n",
  "DEBUG (-bDP, -bD8192): packBuffer; routines handling pack buffer (GranSim internal!).\n",
  "DEBUG (-bDt, -bD16384): blockOnFetch_sanity; check for TSO asleep on fetch.\n",
};

/* one character codes for the available debug options */
sof's avatar
sof committed
65
static char gran_debug_opts_flags[] = {
66 67 68 69 70
  'e', 'E', 'b', 'G', 'q', 'f', 'r', 'F', 'u', 'S', ':', 'o', 'z', 'P', 't'
};

#elif defined(PAR)

sof's avatar
sof committed
71
static char *par_debug_opts_strs[] = {
72
  "DEBUG (-qDv, -qD1): verbose; be generally verbose with parallel related stuff.\n",
73
  "DEBUG (-qDq, -qD2): bq; print blocking queues.\n",
74 75 76
  "DEBUG (-qDs, -qD4): schedule; scheduling of parallel threads.\n",
  "DEBUG (-qDe, -qD8): free; free messages.\n",
  "DEBUG (-qDr, -qD16): resume; resume messages.\n",
77
  "DEBUG (-qDw, -qD32): weight; print weights and distrib GC stuff.\n",
78
  "DEBUG (-qDF, -qD64): fetch; fetch messages.\n",
79 80 81 82 83
  // "DEBUG (-qDa, -qD128): ack; ack messages.\n",
  "DEBUG (-qDf, -qD128): fish; fish messages.\n",
  //"DEBUG (-qDo, -qD512): forward; forwarding messages to other PEs.\n",
  "DEBUG (-qDl, -qD256): tables; print internal LAGA etc tables.\n",
  "DEBUG (-qDo, -qD512): packet; packets and graph structures when packing.\n",
84 85
  "DEBUG (-qDp, -qD1024): pack; packing and unpacking graphs.\n",
  "DEBUG (-qDz, -qD2048): paranoia; ridiculously detailed output (excellent for filling a partition).\n"
86 87 88
};

/* one character codes for the available debug options */
sof's avatar
sof committed
89
static char par_debug_opts_flags[] = {
90
  'v', 'q', 's', 'e', 'r', 'w', 'F', 'f', 'l', 'o', 'p', 'z'
91 92 93 94
};

#endif /* PAR */

95 96 97 98
/* -----------------------------------------------------------------------------
   Static function decls
   -------------------------------------------------------------------------- */

99
static int		/* return NULL on error */
100 101 102 103
open_stats_file (
    I_ arg,
    int argc, char *argv[],
    int rts_argc, char *rts_argv[],
104 105
    const char *FILENAME_FMT,
    FILE **file_ret);
106 107 108 109

static I_ decode(const char *s);
static void bad_option(const char *s);

110 111 112 113 114 115 116 117 118 119 120
#if defined(GRAN)
static void enable_GranSimLight(void);
static void process_gran_option(int arg, int *rts_argc, char *rts_argv[], rtsBool *error);
static void set_GranSim_debug_options(nat n);
static void help_GranSim_debug_options(nat n);
#elif defined(PAR)
static void process_par_option(int arg, int *rts_argc, char *rts_argv[], rtsBool *error);
static void set_par_debug_options(nat n);
static void help_par_debug_options(nat n);
#endif

121 122 123 124 125 126 127 128 129
/* -----------------------------------------------------------------------------
 * Command-line option parsing routines.
 * ---------------------------------------------------------------------------*/

void initRtsFlagsDefaults(void)
{
    RtsFlags.GcFlags.statsFile		= NULL;
    RtsFlags.GcFlags.giveStats		= NO_GC_STATS;

130
    RtsFlags.GcFlags.maxStkSize		= (8 * 1024 * 1024) / sizeof(W_);
131 132
    RtsFlags.GcFlags.initialStkSize	= 1024 / sizeof(W_);

133
    RtsFlags.GcFlags.minAllocAreaSize   = (512 * 1024)        / BLOCK_SIZE;
134
    RtsFlags.GcFlags.minOldGenSize      = (1024 * 1024)       / BLOCK_SIZE;
135
    RtsFlags.GcFlags.maxHeapSize	= 0;    /* off by default */
136
    RtsFlags.GcFlags.heapSizeSuggestion	= 0;    /* none */
137
    RtsFlags.GcFlags.pcFreeHeap		= 3;	/* 3% */
138
    RtsFlags.GcFlags.oldGenFactor       = 2;
139 140 141 142 143 144
#if defined(PAR)
    /* A hack currently needed for GUM -- HWL */
    RtsFlags.GcFlags.generations        = 1;
    RtsFlags.GcFlags.steps              = 2;
    RtsFlags.GcFlags.squeezeUpdFrames	= rtsFalse;
#else
145
    RtsFlags.GcFlags.generations        = 2;
146
    RtsFlags.GcFlags.steps              = 2;
147
    RtsFlags.GcFlags.squeezeUpdFrames	= rtsTrue;
148
#endif
149
    RtsFlags.GcFlags.compact            = rtsFalse;
150
    RtsFlags.GcFlags.compactThreshold   = 30.0;
151 152 153
#ifdef RTS_GTK_FRONTPANEL
    RtsFlags.GcFlags.frontpanel         = rtsFalse;
#endif
154
    RtsFlags.GcFlags.idleGCDelayTicks   = 300 / TICK_MILLISECS; /* ticks */
155

156 157
#ifdef DEBUG
    RtsFlags.DebugFlags.scheduler	= rtsFalse;
158
    RtsFlags.DebugFlags.interpreter	= rtsFalse;
159 160 161 162 163 164
    RtsFlags.DebugFlags.weak		= rtsFalse;
    RtsFlags.DebugFlags.gccafs		= rtsFalse;
    RtsFlags.DebugFlags.gc		= rtsFalse;
    RtsFlags.DebugFlags.block_alloc	= rtsFalse;
    RtsFlags.DebugFlags.sanity		= rtsFalse;
    RtsFlags.DebugFlags.stable		= rtsFalse;
165
    RtsFlags.DebugFlags.stm             = rtsFalse;
166 167 168 169
    RtsFlags.DebugFlags.prof		= rtsFalse;
    RtsFlags.DebugFlags.gran		= rtsFalse;
    RtsFlags.DebugFlags.par		= rtsFalse;
    RtsFlags.DebugFlags.linker		= rtsFalse;
170
    RtsFlags.DebugFlags.squeeze		= rtsFalse;
171 172
#endif

173 174 175 176 177
#if defined(PROFILING) || defined(PAR)
    RtsFlags.CcFlags.doCostCentres	= 0;
#endif /* PROFILING or PAR */

#ifdef PROFILING
178
    RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
179
    RtsFlags.ProfFlags.profileInterval    = 100;
180
    RtsFlags.ProfFlags.includeTSOs        = rtsFalse;
181
    RtsFlags.ProfFlags.showCCSOnException = rtsFalse;
182
    RtsFlags.ProfFlags.maxRetainerSetSize = 8;
183 184 185 186
    RtsFlags.ProfFlags.modSelector        = NULL;
    RtsFlags.ProfFlags.descrSelector      = NULL;
    RtsFlags.ProfFlags.typeSelector       = NULL;
    RtsFlags.ProfFlags.ccSelector         = NULL;
187
    RtsFlags.ProfFlags.ccsSelector        = NULL;
188 189
    RtsFlags.ProfFlags.retainerSelector   = NULL;
    RtsFlags.ProfFlags.bioSelector        = NULL;
190

191
#elif defined(DEBUG)
192
    RtsFlags.ProfFlags.doHeapProfile      = rtsFalse;
193 194 195
#endif

    RtsFlags.ConcFlags.ctxtSwitchTime	= CS_MIN_MILLISECS;  /* In milliseconds */
196

197
#ifdef THREADED_RTS
198
    RtsFlags.ParFlags.nNodes	        = 1;
199 200
    RtsFlags.ParFlags.migrate           = rtsTrue;
    RtsFlags.ParFlags.wakeupMigrate     = rtsFalse;
201
#endif
202

203
#ifdef PAR
204
    RtsFlags.ParFlags.ParStats.Full   	  = rtsFalse;
205
    RtsFlags.ParFlags.ParStats.Suppressed = rtsFalse;
206 207 208 209 210 211
    RtsFlags.ParFlags.ParStats.Binary 	  = rtsFalse;
    RtsFlags.ParFlags.ParStats.Sparks 	  = rtsFalse;
    RtsFlags.ParFlags.ParStats.Heap   	  = rtsFalse;
    RtsFlags.ParFlags.ParStats.NewLogfile = rtsFalse;
    RtsFlags.ParFlags.ParStats.Global     = rtsFalse;

212
    RtsFlags.ParFlags.outputDisabled	= rtsFalse;
213 214 215 216 217
#ifdef DIST
    RtsFlags.ParFlags.doFairScheduling  = rtsTrue;  /* fair sched by def */
#else
    RtsFlags.ParFlags.doFairScheduling  = rtsFalse;  /* unfair sched by def */
#endif
218
    RtsFlags.ParFlags.packBufferSize	= 1024;
219 220
    RtsFlags.ParFlags.thunksToPack      = 1; /* 0 ... infinity; */
    RtsFlags.ParFlags.globalising       = 1; /* 0 ... everything */
221 222 223
    RtsFlags.ParFlags.maxThreads        = 1024;
    RtsFlags.ParFlags.maxFishes        = MAX_FISHES;
    RtsFlags.ParFlags.fishDelay         = FISH_DELAY;
224 225
#endif

226
#if defined(PAR) || defined(THREADED_RTS)
227
    RtsFlags.ParFlags.maxLocalSparks	= 4096;
228
#endif /* PAR || THREADED_RTS */
229 230 231

#if defined(GRAN)
    /* ToDo: check defaults for GranSim and GUM */
232
    RtsFlags.GcFlags.maxStkSize		= (8 * 1024 * 1024) / sizeof(W_);
233 234
    RtsFlags.GcFlags.initialStkSize	= 1024 / sizeof(W_);

235
    RtsFlags.GranFlags.maxThreads	= 65536; // refers to mandatory threads
236 237 238 239 240 241 242
    RtsFlags.GranFlags.GranSimStats.Full	= rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Suppressed	= rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Binary      = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Sparks      = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Heap        = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.NewLogfile  = rtsFalse;
    RtsFlags.GranFlags.GranSimStats.Global      = rtsFalse;
243 244 245 246

    RtsFlags.GranFlags.packBufferSize	= 1024;
    RtsFlags.GranFlags.packBufferSize_internal = GRANSIM_DEFAULT_PACK_BUFFER_SIZE;

247 248 249 250 251 252 253 254 255 256 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
    RtsFlags.GranFlags.proc         = MAX_PROC;
    RtsFlags.GranFlags.Fishing      = rtsFalse;
    RtsFlags.GranFlags.maxFishes   = MAX_FISHES;
    RtsFlags.GranFlags.time_slice   = GRAN_TIME_SLICE;
    RtsFlags.GranFlags.Light        = rtsFalse;

    RtsFlags.GranFlags.Costs.latency =             LATENCY;          
    RtsFlags.GranFlags.Costs.additional_latency =  ADDITIONAL_LATENCY; 
    RtsFlags.GranFlags.Costs.fetchtime =           FETCHTIME; 
    RtsFlags.GranFlags.Costs.lunblocktime =        LOCALUNBLOCKTIME; 
    RtsFlags.GranFlags.Costs.gunblocktime =        GLOBALUNBLOCKTIME;
    RtsFlags.GranFlags.Costs.mpacktime =           MSGPACKTIME;      
    RtsFlags.GranFlags.Costs.munpacktime =         MSGUNPACKTIME;
    RtsFlags.GranFlags.Costs.mtidytime =           MSGTIDYTIME;

    RtsFlags.GranFlags.Costs.threadcreatetime =         THREADCREATETIME;
    RtsFlags.GranFlags.Costs.threadqueuetime =          THREADQUEUETIME;
    RtsFlags.GranFlags.Costs.threaddescheduletime =     THREADDESCHEDULETIME;
    RtsFlags.GranFlags.Costs.threadscheduletime =       THREADSCHEDULETIME;
    RtsFlags.GranFlags.Costs.threadcontextswitchtime =  THREADCONTEXTSWITCHTIME;

    RtsFlags.GranFlags.Costs.arith_cost =         ARITH_COST;       
    RtsFlags.GranFlags.Costs.branch_cost =        BRANCH_COST; 
    RtsFlags.GranFlags.Costs.load_cost =          LOAD_COST;        
    RtsFlags.GranFlags.Costs.store_cost =         STORE_COST; 
    RtsFlags.GranFlags.Costs.float_cost =         FLOAT_COST;       

    RtsFlags.GranFlags.Costs.heapalloc_cost =     HEAPALLOC_COST;

    RtsFlags.GranFlags.Costs.pri_spark_overhead = PRI_SPARK_OVERHEAD;        
    RtsFlags.GranFlags.Costs.pri_sched_overhead = PRI_SCHED_OVERHEAD;        

    RtsFlags.GranFlags.DoFairSchedule           = rtsFalse;             
    RtsFlags.GranFlags.DoAsyncFetch             = rtsFalse;        
    RtsFlags.GranFlags.DoStealThreadsFirst      = rtsFalse;        
    RtsFlags.GranFlags.DoAlwaysCreateThreads    = rtsFalse;      
    RtsFlags.GranFlags.DoBulkFetching           = rtsFalse;             
    RtsFlags.GranFlags.DoThreadMigration        = rtsFalse;          
    RtsFlags.GranFlags.FetchStrategy            = 2;                     
286
    RtsFlags.GranFlags.PreferSparksOfLocalNodes = rtsFalse;   
287 288 289 290 291 292 293 294 295
    RtsFlags.GranFlags.DoPrioritySparking       = rtsFalse;         
    RtsFlags.GranFlags.DoPriorityScheduling     = rtsFalse;       
    RtsFlags.GranFlags.SparkPriority            = 0;
    RtsFlags.GranFlags.SparkPriority2           = 0; 
    RtsFlags.GranFlags.RandomPriorities         = rtsFalse;           
    RtsFlags.GranFlags.InversePriorities        = rtsFalse;          
    RtsFlags.GranFlags.IgnorePriorities         = rtsFalse;           
    RtsFlags.GranFlags.ThunksToPack             = 0;                      
    RtsFlags.GranFlags.RandomSteal              = rtsTrue;
296 297 298
#endif

#ifdef TICKY_TICKY
299 300
    RtsFlags.TickyFlags.showTickyStats	 = rtsFalse;
    RtsFlags.TickyFlags.tickyFile	 = NULL;
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
#endif
}

static const char *
usage_text[] = {
"",
"Usage: <prog> <args> [+RTS <rtsopts> | -RTS <args>] ... --RTS <args>",
"",
"   +RTS    Indicates run time system options follow",
"   -RTS    Indicates program arguments follow",
"  --RTS    Indicates that ALL subsequent arguments will be given to the",
"           program (including any of these RTS flags)",
"",
"The following run time system options are available:",
"",
316
"  -?       Prints this message and exits; the program is not executed",
317
"",
318
"  -K<size> Sets the maximum stack size (default 8M)  Egs: -K32k   -K512k",
sof's avatar
sof committed
319
"  -k<size> Sets the initial thread stack size (default 1k)  Egs: -k4k   -k2m",
320 321
"",
"  -A<size> Sets the minimum allocation area size (default 256k) Egs: -A1m -A10k",
322
"  -M<size> Sets the maximum heap size (default unlimited)  Egs: -M256k -M1G",
323
"  -H<size> Sets the minimum heap size (default 0M)   Egs: -H24m  -H1G",
324
"  -m<n>    Minimum % of heap which must be available (default 3%)",
325
"  -G<n>    Number of generations (default: 2)",
326
"  -T<n>    Number of steps in younger generations (default: 2)",
327 328
"  -c<n>    Auto-enable compaction of the oldest generation when live data is",
"           at least <n>% of the maximum heap size set with -M (default: 30%)",
329
"  -c       Enable compaction for all major collections",
330
#if defined(THREADED_RTS)
331 332
"  -I<sec>  Perform full GC after <sec> idle time (default: 0.3, 0 == off)",
#endif
333 334 335 336
"",
"  -t<file> One-line GC statistics  (default file: <program>.stat)",
"  -s<file> Summary  GC statistics  (with -Sstderr going to stderr)",
"  -S<file> Detailed GC statistics",
337 338 339
#ifdef RTS_GTK_FRONTPANEL
"  -f       Display front panel (requires X11 & GTK+)",
#endif
340 341 342 343 344 345
"",
"",
"  -Z       Don't squeeze out update frames on stack overflow",
"  -B       Sound the bell at the start of each garbage collection",
#if defined(PROFILING) || defined(PAR)
"",
346
"  -px      Time/allocation profile (XML)  (output file <program>.prof)",
andy's avatar
andy committed
347 348 349
"  -p       Time/allocation profile        (output file <program>.prof)",
"  -P       More detailed Time/Allocation profile",
"  -Pa      Give information about *all* cost centres",
350

351 352
# if defined(PROFILING)
"",
353 354 355 356 357 358 359 360
"  -hx            Heap residency profile (XML)   (output file <program>.prof)",
"  -h<break-down> Heap residency profile (hp2ps) (output file <program>.hp)",
"     break-down: c = cost centre stack (default)",
"                 m = module",
"                 d = closure description",
"                 y = type description",
"                 r = retainer",
"                 b = biography (LAG,DRAG,VOID,USE)",
361
"  A subset of closures may be selected thusly:",
362 363
"    -hc<cc>,...  specific cost centre(s) (top of stack only)",
"    -hC<cc>,...  specific cost centre(s) (anywhere in stack)",
364 365 366 367 368
"    -hm<mod>...  all cost centres from the specified modules(s)",
"    -hd<des>,... closures with specified closure descriptions",
"    -hy<typ>...  closures with specified type descriptions",
"    -hr<cc>...   closures with specified retainers",
"    -hb<bio>...  closures with specified biographies (lag,drag,void,use)",
369 370
"",
"  -R<size>       Set the maximum retainer set size (default: 8)",
371
"",
372
"  -i<sec>        Time between heap samples (seconds, default: 0.1)",
andy's avatar
andy committed
373
"",
374 375
"  -xt            Include threads (TSOs) in a heap profile",
"",
376
"  -xc      Show current cost centre stack on raising an exception",
377 378 379 380 381 382 383 384 385 386 387 388 389 390
# endif
#endif /* PROFILING or PAR */
#if !defined(PROFILING) && defined(DEBUG)
"",
"  -h<break-down> Debugging Heap residency profile",
"                 (output file <program>.hp)",
"     break-down: L = closure label (default)",
"                 T = closure type (constructor, thunk etc.)",
#endif
"",
#if defined(TICKY_TICKY)
"  -r<file>  Produce reduction profiling statistics (with -rstderr for stderr)",
"",
#endif
391
#if defined(PAR)
392 393
"  -N<n>     Use <n> PVMish processors in parallel (default: 2)",
/* NB: the -N<n> is implemented by the driver!! */
394
#endif
395 396
"  -C<secs>  Context-switch interval in seconds",
"                (0 or no argument means switch as often as possible)",
397
"                the default is .02 sec; resolution is .02 sec",
398 399 400
"",
#if defined(DEBUG)
"  -Ds  DEBUG: scheduler",
401
"  -Di  DEBUG: interpreter",
402 403 404 405 406 407 408 409 410 411
"  -Dw  DEBUG: weak",
"  -DG  DEBUG: gccafs",
"  -Dg  DEBUG: gc",
"  -Db  DEBUG: block",
"  -DS  DEBUG: sanity",
"  -Dt  DEBUG: stable",
"  -Dp  DEBUG: prof",
"  -Dr  DEBUG: gran",
"  -DP  DEBUG: par",
"  -Dl  DEBUG: linker",
412
"  -Dm  DEBUG: stm",
413
"  -Dz  DEBUG: stack squezing",
414
"",
415
#endif /* DEBUG */
416
#if defined(THREADED_RTS)
417
"  -N<n>     Use <n> OS threads (default: 1)",
418 419
"  -qm       Don't automatically migrate threads between CPUs",
"  -qw       Migrate a thread to the current CPU when it is woken up",
420
#endif
421
#if defined(THREADED_RTS) || defined(PAR)
422 423 424
"  -e<size>  Size of spark pools (default 100)",
#endif
#if defined(PAR)
425 426 427 428 429
"  -t<num>   Set maximum number of advisory threads per PE (default 32)",
"  -qP       Enable activity profile (output files in ~/<program>*.gr)",
"  -qQ<size> Set pack-buffer size (default: 1024)",
"  -qd       Turn on PVM-ish debugging",
"  -qO       Disable output for performance measurement",
430
#endif
431
#if defined(THREADED_RTS) || defined(PAR)
432 433
"  -e<n>     Maximum number of outstanding local sparks (default: 4096)",
#endif
434
#if defined(PAR)
435 436
"  -d        Turn on PVM-ish debugging",
"  -O        Disable output for performance measurement",
437 438
#endif /* PAR */
#if defined(GRAN)  /* ToDo: fill in decent Docu here */
439
"  -b...     All GranSim options start with -b; see GranSim User's Guide for details",
440
#endif
441
"",
442 443
"RTS options may also be specified using the GHCRTS environment variable.",
"",
444 445 446 447 448 449
"Other RTS options may be available for programs compiled a different way.",
"The GHC User's Guide has full details.",
"",
0
};

sof's avatar
sof committed
450
STATIC_INLINE rtsBool
451 452 453 454 455
strequal(const char *a, const char * b)
{
    return(strcmp(a, b) == 0);
}

456 457 458 459 460 461 462 463 464 465 466 467 468 469
static void
splitRtsFlags(char *s, int *rts_argc, char *rts_argv[])
{
    char *c1, *c2;

    c1 = s;
    do {
	while (isspace(*c1)) { c1++; };
	c2 = c1;
	while (!isspace(*c2) && *c2 != '\0') { c2++; };
	
	if (c1 == c2) { break; }
	
	if (*rts_argc < MAX_RTS_ARGS-1) {
sof's avatar
sof committed
470
	    s = stgMallocBytes(c2-c1+1, "RtsFlags.c:splitRtsFlags()");
471 472 473 474 475 476 477 478 479 480 481
	    strncpy(s, c1, c2-c1);
	    s[c2-c1] = '\0';
	    rts_argv[(*rts_argc)++] = s;
	} else {
	    barf("too many RTS arguments (max %d)", MAX_RTS_ARGS-1);
	}
	
	c1 = c2;
    } while (*c1 != '\0');
}
    
482 483 484 485 486 487 488
void
setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[])
{
    rtsBool error = rtsFalse;
    I_ mode;
    I_ arg, total_arg;

489
    setProgName (argv);
490 491 492 493 494 495
    total_arg = *argc;
    arg = 1;

    *argc = 1;
    *rts_argc = 0;

496 497 498 499 500 501 502 503 504
    // process arguments from the ghc_rts_opts global variable first.
    // (arguments from the GHCRTS environment variable and the command
    // line override these).
    {
	if (ghc_rts_opts != NULL) {
	    splitRtsFlags(ghc_rts_opts, rts_argc, rts_argv);
	}
    }

505
    // process arguments from the GHCRTS environment variable next
506
    // (arguments from the command line override these).
507 508 509 510
    {
	char *ghc_rts = getenv("GHCRTS");

	if (ghc_rts != NULL) {
511
	    splitRtsFlags(ghc_rts, rts_argc, rts_argv);
512 513
	}
    }
514

515 516 517
    // Split arguments (argv) into PGM (argv) and RTS (rts_argv) parts
    //   argv[0] must be PGM argument -- leave in argv

518 519 520 521 522 523 524 525 526 527 528 529
    for (mode = PGM; arg < total_arg; arg++) {
	// The '--RTS' argument disables all future +RTS ... -RTS processing.
	if (strequal("--RTS", argv[arg])) {
	    arg++;
	    break;
	}
	// The '--' argument is passed through to the program, but
	// disables all further +RTS ... -RTS processing.
	else if (strequal("--", argv[arg])) {
	    break;
	}
	else if (strequal("+RTS", argv[arg])) {
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
	    mode = RTS;
	}
	else if (strequal("-RTS", argv[arg])) {
	    mode = PGM;
	}
	else if (mode == RTS && *rts_argc < MAX_RTS_ARGS-1) {
	    rts_argv[(*rts_argc)++] = argv[arg];
	}
	else if (mode == PGM) {
	    argv[(*argc)++] = argv[arg];
	}
	else {
	  barf("too many RTS arguments (max %d)", MAX_RTS_ARGS-1);
	}
    }
545 546 547
    // process remaining program arguments
    for (; arg < total_arg; arg++) {
	argv[(*argc)++] = argv[arg];
548 549 550 551 552
    }
    argv[*argc] = (char *) 0;
    rts_argv[*rts_argc] = (char *) 0;

    // Process RTS (rts_argv) part: mainly to determine statsfile
553 554 555
    for (arg = 0; arg < *rts_argc; arg++) {
	if (rts_argv[arg][0] != '-') {
	    fflush(stdout);
556
	    errorBelch("unexpected RTS argument: %s", rts_argv[arg]);
557 558 559 560 561 562 563 564 565 566
	    error = rtsTrue;

        } else {
	    switch(rts_argv[arg][1]) {

	      /* process: general args, then PROFILING-only ones,
		 then CONCURRENT-only, PARallel-only, GRAN-only,
		 TICKY-only (same order as defined in RtsFlags.lh);
		 within those groups, mostly in case-insensitive
		 alphabetical order.
567
                 Final group is x*, which allows for more options.
568 569 570 571 572 573
	      */

#ifdef TICKY_TICKY
# define TICKY_BUILD_ONLY(x) x
#else
# define TICKY_BUILD_ONLY(x) \
574
errorBelch("not built for: ticky-ticky stats"); \
575 576 577 578 579 580 581
error = rtsTrue;
#endif

#if defined(PROFILING) 
# define COST_CENTRE_USING_BUILD_ONLY(x) x
#else
# define COST_CENTRE_USING_BUILD_ONLY(x) \
582
errorBelch("not built for: -prof or -parallel"); \
583 584 585 586 587 588 589
error = rtsTrue;
#endif

#ifdef PROFILING
# define PROFILING_BUILD_ONLY(x)   x
#else
# define PROFILING_BUILD_ONLY(x) \
590
errorBelch("not built for: -prof"); \
591 592 593
error = rtsTrue;
#endif

594 595 596 597
#ifdef PAR
# define PAR_BUILD_ONLY(x)      x
#else
# define PAR_BUILD_ONLY(x) \
598
errorBelch("not built for: -parallel"); \
599 600 601
error = rtsTrue;
#endif

602 603 604 605 606 607 608 609 610 611
#ifdef THREADED_RTS
# define THREADED_BUILD_ONLY(x)      x
#else
# define THREADED_BUILD_ONLY(x) \
errorBelch("not built for: -smp"); \
error = rtsTrue;
#endif

#if defined(THREADED_RTS) || defined(PAR)
# define PAR_OR_THREADED_BUILD_ONLY(x)      x
612
#else
613
# define PAR_OR_THREADED_BUILD_ONLY(x) \
614
errorBelch("not built for: -parallel or -smp"); \
615 616 617 618 619 620 621
error = rtsTrue;
#endif

#ifdef GRAN
# define GRAN_BUILD_ONLY(x)     x
#else
# define GRAN_BUILD_ONLY(x) \
622
errorBelch("not built for: -gransim"); \
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
error = rtsTrue;
#endif

	      /* =========== GENERAL ========================== */
	      case '?':
		error = rtsTrue;
		break;

	      case 'A':
		RtsFlags.GcFlags.minAllocAreaSize
		  = decode(rts_argv[arg]+2) / BLOCK_SIZE;
		if (RtsFlags.GcFlags.minAllocAreaSize <= 0) {
		  bad_option(rts_argv[arg]);
		}
		break;

	      case 'B':
		RtsFlags.GcFlags.ringBell = rtsTrue;
		break;

643
	      case 'c':
644 645 646 647
		  if (rts_argv[arg][2] != '\0') {
		      RtsFlags.GcFlags.compactThreshold =
			  atof(rts_argv[arg]+2);
		  } else {
648
		      RtsFlags.GcFlags.compact = rtsTrue;
649 650
		  }
		  break;
651

652 653 654 655 656 657 658
	      case 'F':
	        RtsFlags.GcFlags.oldGenFactor = atof(rts_argv[arg]+2);
	      
		if (RtsFlags.GcFlags.oldGenFactor < 0)
		  bad_option( rts_argv[arg] );
		break;
	      
659 660
#ifdef DEBUG
	      case 'D':
661 662 663 664 665 666 667 668
	      { 
		  char *c;

		  for (c  = rts_argv[arg] + 2; *c != '\0'; c++) {
		      switch (*c) {
		      case 's':
			  RtsFlags.DebugFlags.scheduler = rtsTrue;
			  break;
669 670
		      case 'i':
			  RtsFlags.DebugFlags.interpreter = rtsTrue;
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
			  break;
		      case 'w':
			  RtsFlags.DebugFlags.weak = rtsTrue;
			  break;
		      case 'G':
			  RtsFlags.DebugFlags.gccafs = rtsTrue;
			  break;
		      case 'g':
			  RtsFlags.DebugFlags.gc = rtsTrue;
			  break;
		      case 'b':
			  RtsFlags.DebugFlags.block_alloc = rtsTrue;
			  break;
		      case 'S':
			  RtsFlags.DebugFlags.sanity = rtsTrue;
			  break;
		      case 't':
			  RtsFlags.DebugFlags.stable = rtsTrue;
			  break;
		      case 'p':
			  RtsFlags.DebugFlags.prof = rtsTrue;
			  break;
		      case 'r':
			  RtsFlags.DebugFlags.gran = rtsTrue;
			  break;
		      case 'P':
			  RtsFlags.DebugFlags.par = rtsTrue;
			  break;
		      case 'l':
			  RtsFlags.DebugFlags.linker = rtsTrue;
			  break;
702 703 704
		      case 'a':
			  RtsFlags.DebugFlags.apply = rtsTrue;
			  break;
705 706 707
		      case 'm':
			  RtsFlags.DebugFlags.stm = rtsTrue;
			  break;
708 709 710
		      case 'z':
			  RtsFlags.DebugFlags.squeeze = rtsTrue;
			  break;
711 712 713 714 715 716
		      default:
			  bad_option( rts_argv[arg] );
		      }
		  }
		  break;
	      }
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
#endif

	      case 'K':
		RtsFlags.GcFlags.maxStkSize = 
		  decode(rts_argv[arg]+2) / sizeof(W_);

		if (RtsFlags.GcFlags.maxStkSize == 0) 
		  bad_option( rts_argv[arg] );
		break;

	      case 'k':
		RtsFlags.GcFlags.initialStkSize = 
		  decode(rts_argv[arg]+2) / sizeof(W_);

		if (RtsFlags.GcFlags.initialStkSize == 0) 
		  bad_option( rts_argv[arg] );
		break;

	      case 'M':
		RtsFlags.GcFlags.maxHeapSize = 
		  decode(rts_argv[arg]+2) / BLOCK_SIZE;
		/* user give size in *bytes* but "maxHeapSize" is in *blocks* */

		if (RtsFlags.GcFlags.maxHeapSize <= 0) {
		  bad_option(rts_argv[arg]);
		}
		break;

	      case 'm':
		RtsFlags.GcFlags.pcFreeHeap = atof(rts_argv[arg]+2);

		if (RtsFlags.GcFlags.pcFreeHeap < 0 || 
		    RtsFlags.GcFlags.pcFreeHeap > 100)
		  bad_option( rts_argv[arg] );
		break;

753 754
	      case 'G':
		RtsFlags.GcFlags.generations = decode(rts_argv[arg]+2);
755
		if (RtsFlags.GcFlags.generations < 1) {
756 757 758 759
		  bad_option(rts_argv[arg]);
		}
		break;

760 761 762 763 764 765 766
	      case 'T':
		RtsFlags.GcFlags.steps = decode(rts_argv[arg]+2);
		if (RtsFlags.GcFlags.steps < 1) {
		  bad_option(rts_argv[arg]);
		}
		break;

767
	      case 'H':
768 769 770 771 772 773
		RtsFlags.GcFlags.heapSizeSuggestion = 
		  decode(rts_argv[arg]+2) / BLOCK_SIZE;

		if (RtsFlags.GcFlags.heapSizeSuggestion <= 0) {
		  bad_option(rts_argv[arg]);
		}
774 775
		break;

776 777 778 779 780 781
#ifdef RTS_GTK_FRONTPANEL
	      case 'f':
		  RtsFlags.GcFlags.frontpanel = rtsTrue;
		  break;
#endif

782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798
    	      case 'I':	/* idle GC delay */
		if (rts_argv[arg][2] == '\0') {
		  /* use default */
		} else {
		    I_ cst; /* tmp */

		    /* Convert to ticks */
		    cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
		    if (cst > 0 && cst < TICK_MILLISECS) {
			cst = TICK_MILLISECS;
		    } else {
			cst = cst / TICK_MILLISECS;
		    }
		    RtsFlags.GcFlags.idleGCDelayTicks = cst;
		}
		break;

799
	      case 'S':
800 801
		  RtsFlags.GcFlags.giveStats = VERBOSE_GC_STATS;
		  goto stats;
802

803
	      case 's':
804 805
		  RtsFlags.GcFlags.giveStats = SUMMARY_GC_STATS;
		  goto stats;
806 807

	      case 't':
808 809
		  RtsFlags.GcFlags.giveStats = ONELINE_GC_STATS;
		  goto stats;
810

811
	    stats:
812
#ifdef PAR
813 814
		/* Opening all those files would almost certainly fail... */
		// RtsFlags.ParFlags.ParStats.Full = rtsTrue;
815
		RtsFlags.GcFlags.statsFile = NULL; /* temporary; ToDo: rm */
816
#else
817 818 819 820 821 822 823
		{ 
		    int r;
		    r = open_stats_file(arg, *argc, argv,
					*rts_argc, rts_argv, STAT_FILENAME_FMT,
					&RtsFlags.GcFlags.statsFile);
		    if (r == -1) { error = rtsTrue; }
		}
824
#endif
825
		  break;
826 827 828 829 830 831 832 833 834 835 836

	      case 'Z':
		RtsFlags.GcFlags.squeezeUpdFrames = rtsFalse;
		break;

	      /* =========== PROFILING ========================== */

	      case 'P': /* detailed cost centre profiling (time/alloc) */
	      case 'p': /* cost centre profiling (time/alloc) */
		COST_CENTRE_USING_BUILD_ONLY(
		switch (rts_argv[arg][2]) {
837 838
		  case 'x':
		    RtsFlags.CcFlags.doCostCentres = COST_CENTRES_XML;
839
		    break;
andy's avatar
andy committed
840 841 842
		  case 'a':
		    RtsFlags.CcFlags.doCostCentres = COST_CENTRES_ALL;
		    break;
843
		  default:
844 845 846 847 848 849 850 851
		      if (rts_argv[arg][1] == 'P') {
			  RtsFlags.CcFlags.doCostCentres =
			      COST_CENTRES_VERBOSE;
		      } else {
			  RtsFlags.CcFlags.doCostCentres =
			      COST_CENTRES_SUMMARY;
		      }
		      break;
852 853 854
		}
		) break;

855 856 857 858 859
	      case 'R':
		  PROFILING_BUILD_ONLY(
		      RtsFlags.ProfFlags.maxRetainerSetSize = atof(rts_argv[arg]+2);
  	          ) break;

860 861 862 863 864 865 866 867 868 869 870
	      case 'h': /* serial heap profile */
#if !defined(PROFILING) && defined(DEBUG)
		switch (rts_argv[arg][2]) {
		  case '\0':
		  case 'L':
		    RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_INFOPTR;
		    break;
		  case 'T':
		    RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CLOSURE_TYPE;
		    break;
		  default:
871
		    errorBelch("invalid heap profile option: %s",rts_argv[arg]);
872 873 874 875 876
		    error = rtsTrue;
		}
#else
		PROFILING_BUILD_ONLY(
		switch (rts_argv[arg][2]) {
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893
		case '\0':
		case 'C':
		case 'c':
		case 'M':
		case 'm':
		case 'D':
		case 'd':
		case 'Y':
		case 'y':
		case 'R':
		case 'r':
		case 'B':
		case 'b':
		    if (rts_argv[arg][2] != '\0' && rts_argv[arg][3] != '\0') {
			{
			    char *left  = strchr(rts_argv[arg], '{');
			    char *right = strrchr(rts_argv[arg], '}');
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910

			    // curly braces are optional, for
			    // backwards compat.
			    if (left)
				left = left+1;
			    else
				left = rts_argv[arg] + 3;

			    if (!right)
				right = rts_argv[arg] + strlen(rts_argv[arg]);

			    *right = '\0';

			    switch (rts_argv[arg][2]) {
			    case 'c': // cost centre label select
				RtsFlags.ProfFlags.ccSelector = left;
				break;
911 912 913
			    case 'C':
				RtsFlags.ProfFlags.ccsSelector = left;
				break;
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933
			    case 'M':
			    case 'm': // cost centre module select
				RtsFlags.ProfFlags.modSelector = left;
				break;
			    case 'D':
			    case 'd': // closure descr select 
				RtsFlags.ProfFlags.descrSelector = left;
				break;
			    case 'Y':
			    case 'y': // closure type select
				RtsFlags.ProfFlags.typeSelector = left;
				break;
			    case 'R':
			    case 'r': // retainer select
				RtsFlags.ProfFlags.retainerSelector = left;
				break;
			    case 'B':
			    case 'b': // biography select
				RtsFlags.ProfFlags.bioSelector = left;
				break;
934 935 936 937
			    }
			}
			break;
		    }
938

939
		    if (RtsFlags.ProfFlags.doHeapProfile != 0) {
940
			errorBelch("multiple heap profile options");
941 942 943 944 945 946 947 948 949 950 951 952
			error = rtsTrue;
			break;
		    }

		    switch (rts_argv[arg][2]) {
		    case '\0':
		    case 'C':
		    case 'c':
			RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CCS;
			break;
		    case 'M':
		    case 'm':
953 954
			  RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_MOD;
			  break;
955 956
		    case 'D':
		    case 'd':
957 958
			  RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_DESCR;
			  break;
959 960
		    case 'Y':
		    case 'y':
961 962
			  RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_TYPE;
			  break;
963 964
		    case 'R':
		    case 'r':
965 966
			  RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_RETAINER;
			  break;
967 968
		    case 'B':
		    case 'b':
969 970
			  RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_LDV;
			  break;
971 972
		    }
		    break;
973
		      
974
		default:
975
		    errorBelch("invalid heap profile option: %s",rts_argv[arg]);
976 977 978
		    error = rtsTrue;
		}
		) 
979
#endif /* PROFILING */
andy's avatar
andy committed
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994
    	    	break;

#if defined(PROFILING) 
    	      case 'i':	/* heap sample interval */
		if (rts_argv[arg][2] == '\0') {
		  /* use default */
		} else {
		    I_ cst; /* tmp */

		    /* Convert to milliseconds */
		    cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
		    cst = (cst / CS_MIN_MILLISECS) * CS_MIN_MILLISECS;
		    if (cst != 0 && cst < CS_MIN_MILLISECS)
			cst = CS_MIN_MILLISECS;

995
		    RtsFlags.ProfFlags.profileInterval = cst;
andy's avatar
andy committed
996 997 998
		}
		break;
#endif
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009

	      /* =========== CONCURRENT ========================= */
    	      case 'C':	/* context switch interval */
		if (rts_argv[arg][2] == '\0')
    	    	    RtsFlags.ConcFlags.ctxtSwitchTime = 0;
		else {
		    I_ cst; /* tmp */

		    /* Convert to milliseconds */
		    cst = (I_) ((atof(rts_argv[arg]+2) * 1000));
		    cst = (cst / CS_MIN_MILLISECS) * CS_MIN_MILLISECS;
1010
		    if (cst != 0 && cst < CS_MIN_MILLISECS)
1011 1012 1013 1014 1015 1016
			cst = CS_MIN_MILLISECS;

		    RtsFlags.ConcFlags.ctxtSwitchTime = cst;
		}
    	    	break;

1017
#ifdef THREADED_RTS
1018
	      case 'N':
1019
		THREADED_BUILD_ONLY(
1020
		if (rts_argv[arg][2] != '\0') {
1021
		    RtsFlags.ParFlags.nNodes
1022
		      = strtol(rts_argv[arg]+2, (char **) NULL, 10);
1023
		    if (RtsFlags.ParFlags.nNodes <= 0) {
1024
		      errorBelch("bad value for -N");
1025
		      error = rtsTrue;
1026 1027
		    }
		}
1028
		) break;
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047

	    case 'q':
		    switch (rts_argv[arg][2]) {
		    case '\0':
			errorBelch("incomplete RTS option: %s",rts_argv[arg]);
			error = rtsTrue;
			break;
		    case 'm':
			RtsFlags.ParFlags.migrate = rtsFalse;
			break;
		    case 'w':
			RtsFlags.ParFlags.wakeupMigrate = rtsTrue;
			break;
		    default:
			errorBelch("unknown RTS option: %s",rts_argv[arg]);
			error = rtsTrue;
			break;
		    }
		    break;
1048
#endif
1049 1050
	      /* =========== PARALLEL =========================== */
	      case 'e':
1051
		PAR_OR_THREADED_BUILD_ONLY(
1052
		if (rts_argv[arg][2] != '\0') {
1053 1054 1055
		    RtsFlags.ParFlags.maxLocalSparks
		      = strtol(rts_argv[arg]+2, (char **) NULL, 10);
		    if (RtsFlags.ParFlags.maxLocalSparks <= 0) {
1056
		      errorBelch("bad value for -e");
1057
		      error = rtsTrue;
1058 1059 1060 1061
		    }
		}
		) break;

1062
#ifdef PAR
1063
    	      case 'q':
1064
		PAR_BUILD_ONLY(
1065
		  process_par_option(arg, rts_argc, rts_argv, &error);
1066
		) break;
1067
#endif
1068 1069 1070 1071 1072

	      /* =========== GRAN =============================== */

    	      case 'b':
		GRAN_BUILD_ONLY(
1073
		  process_gran_option(arg, rts_argc, rts_argv, &error);
1074 1075 1076 1077 1078 1079 1080 1081 1082
		) break;

	      /* =========== TICKY ============================== */

	      case 'r': /* Basic profiling stats */
		TICKY_BUILD_ONLY(

		RtsFlags.TickyFlags.showTickyStats = rtsTrue;

1083 1084 1085 1086 1087 1088 1089
		{ 
		    int r;
		    r = open_stats_file(arg, *argc, argv,
					*rts_argc, rts_argv, TICKY_FILENAME_FMT,
					&RtsFlags.TickyFlags.tickyFile);
		    if (r == -1) { error = rtsTrue; }
		}
1090 1091
	        ) break;

1092 1093 1094 1095 1096
	      /* =========== EXTENDED OPTIONS =================== */

              case 'x': /* Extend the argument space */
                switch(rts_argv[arg][2]) {
                  case '\0':
1097
		    errorBelch("incomplete RTS option: %s",rts_argv[arg]);
1098 1099 1100 1101 1102
		    error = rtsTrue;
		    break;

                  case 'c': /* Debugging tool: show current cost centre on an exception */
                    PROFILING_BUILD_ONLY(
1103 1104 1105 1106 1107 1108 1109 1110 1111
			RtsFlags.ProfFlags.showCCSOnException = rtsTrue;
			);
		    break;

		case 't':  /* Include memory used by TSOs in a heap profile */
		    PROFILING_BUILD_ONLY(
			RtsFlags.ProfFlags.includeTSOs = rtsTrue;
			);
		    break;
1112 1113 1114 1115

                  /* The option prefix '-xx' is reserved for future extension.  KSW 1999-11. */

	          default:
1116
		    errorBelch("unknown RTS option: %s",rts_argv[arg]);
1117 1118 1119 1120 1121
		    error = rtsTrue;
		    break;
                }
                break;  /* defensive programming */

1122 1123
	      /* =========== OH DEAR ============================ */
	      default:
1124
		errorBelch("unknown RTS option: %s",rts_argv[arg]);
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134
		error = rtsTrue;
		break;
	    }
	}
    }
    if (error) {
	const char **p;

        fflush(stdout);
	for (p = usage_text; *p; p++)
1135
	    errorBelch("%s", *p);
1136 1137 1138 1139
	stg_exit(EXIT_FAILURE);
    }
}

1140 1141 1142 1143 1144
#if defined(GRAN)

static void
enable_GranSimLight(void) {

1145
    debugBelch("GrAnSim Light enabled (infinite number of processors;  0 communication costs)\n");
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181