X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsFlags.c;h=3fac86bf4ee26658d7741928029a4b0545e21317;hb=8b18faef8aeaf40150c208272a2fc117611e8ae8;hp=4c1f739e894615e8f62948ece354397c18cd31ef;hpb=1bd1fb932375bc4b065cc8de23f0d251e8075395;p=ghc-hetmet.git diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 4c1f739..3fac86b 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -17,6 +17,14 @@ #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_WINDOWS_H +#include +#endif + #include #include @@ -147,6 +155,7 @@ void initRtsFlagsDefaults(void) #endif RtsFlags.GcFlags.compact = rtsFalse; RtsFlags.GcFlags.compactThreshold = 30.0; + RtsFlags.GcFlags.sweep = rtsFalse; #ifdef RTS_GTK_FRONTPANEL RtsFlags.GcFlags.frontpanel = rtsFalse; #endif @@ -175,11 +184,14 @@ void initRtsFlagsDefaults(void) RtsFlags.DebugFlags.stable = rtsFalse; RtsFlags.DebugFlags.stm = rtsFalse; RtsFlags.DebugFlags.prof = rtsFalse; + RtsFlags.DebugFlags.eventlog = rtsFalse; RtsFlags.DebugFlags.gran = rtsFalse; RtsFlags.DebugFlags.par = rtsFalse; + RtsFlags.DebugFlags.apply = rtsFalse; RtsFlags.DebugFlags.linker = rtsFalse; RtsFlags.DebugFlags.squeeze = rtsFalse; RtsFlags.DebugFlags.hpc = rtsFalse; + RtsFlags.DebugFlags.timestamp = rtsFalse; #endif #if defined(PROFILING) || defined(PAR) @@ -203,15 +215,24 @@ void initRtsFlagsDefaults(void) RtsFlags.ProfFlags.bioSelector = NULL; #endif +#ifdef EVENTLOG + RtsFlags.EventLogFlags.doEventLogging = rtsFalse; +#endif + RtsFlags.MiscFlags.tickInterval = 20; /* In milliseconds */ RtsFlags.ConcFlags.ctxtSwitchTime = 20; /* In milliseconds */ RtsFlags.MiscFlags.install_signal_handlers = rtsTrue; + RtsFlags.MiscFlags.machineReadable = rtsFalse; + RtsFlags.MiscFlags.linkerMemBase = 0; #ifdef THREADED_RTS RtsFlags.ParFlags.nNodes = 1; RtsFlags.ParFlags.migrate = rtsTrue; RtsFlags.ParFlags.wakeupMigrate = rtsFalse; + RtsFlags.ParFlags.parGcEnabled = 1; + RtsFlags.ParFlags.parGcGen = 1; + RtsFlags.ParFlags.parGcLoadBalancing = 1; #endif #ifdef PAR @@ -314,12 +335,10 @@ void initRtsFlagsDefaults(void) RtsFlags.TickyFlags.tickyFile = NULL; #endif - RtsFlags.TraceFlags.timestamp = rtsFalse; - RtsFlags.TraceFlags.sched = rtsFalse; - #ifdef USE_PAPI /* By default no special measurements taken */ RtsFlags.PapiFlags.eventType = 0; + RtsFlags.PapiFlags.numUserEvents = 0; #endif } @@ -336,6 +355,7 @@ usage_text[] = { "The following run time system options are available:", "", " -? Prints this message and exits; the program is not executed", +" --info Print information about the RTS used by this program", "", " -K Sets the maximum stack size (default 8M) Egs: -K32k -K512k", " -k Sets the initial thread stack size (default 1k) Egs: -k4k -k2m", @@ -349,13 +369,14 @@ usage_text[] = { " -c Auto-enable compaction of the oldest generation when live data is", " at least % of the maximum heap size set with -M (default: 30%)", " -c Enable compaction for all major collections", +" -w Use mark-region for the oldest generation (experimental)", #if defined(THREADED_RTS) " -I Perform full GC after idle time (default: 0.3, 0 == off)", #endif "", -" -t One-line GC statistics (default file: .stat)", -" -s Summary GC statistics (with -Sstderr going to stderr)", -" -S Detailed GC statistics", +" -t[] One-line GC statistics (if omitted, uses stderr)", +" -s[] Summary GC statistics (if omitted, uses stderr)", +" -S[] Detailed GC statistics (if omitted, uses stderr)", #ifdef RTS_GTK_FRONTPANEL " -f Display front panel (requires X11 & GTK+)", #endif @@ -400,6 +421,13 @@ usage_text[] = { "", # endif #endif /* PROFILING or PAR */ + +#ifdef EVENTLOG +"", +" -l Log runtime events (generates binary trace file .eventlog)", +"", +#endif + #if !defined(PROFILING) "", " -hT Heap residency profile (output file .hp)", @@ -421,8 +449,7 @@ usage_text[] = { " This sets the resolution for -C and the profile timer -i.", " Default: 0.02 sec.", "", -" -vs Trace scheduler events (see also -Ds with -debug)", -" -vt Time-stamp trace messages", +" -vt Time-stamp debug messages", "", #if defined(DEBUG) " -Ds DEBUG: scheduler", @@ -434,8 +461,10 @@ usage_text[] = { " -DS DEBUG: sanity", " -Dt DEBUG: stable", " -Dp DEBUG: prof", +" -De DEBUG: event logging", " -Dr DEBUG: gran", " -DP DEBUG: par", +" -Da DEBUG: apply", " -Dl DEBUG: linker", " -Dm DEBUG: stm", " -Dz DEBUG: stack squezing", @@ -443,7 +472,10 @@ usage_text[] = { "", #endif /* DEBUG */ #if defined(THREADED_RTS) && !defined(NOSMP) -" -N Use OS threads (default: 1)", +" -N Use processors (default: 1)", +" -N Determine the number of processors to use automatically", +" -q1 Use one OS thread for GC (turns off parallel GC)", +" -qg Use parallel GC only for generations >= (default: 1)", " -qm Don't automatically migrate threads between CPUs", " -qw Migrate a thread to the current CPU when it is woken up", #endif @@ -469,6 +501,10 @@ usage_text[] = { #if defined(GRAN) /* ToDo: fill in decent Docu here */ " -b... All GranSim options start with -b; see GranSim User's Guide for details", #endif +#if defined(x86_64_HOST_ARCH) +" -xm Base address to mmap memory in the GHCi linker", +" (hex; must be <80000000)", +#endif #if defined(USE_PAPI) " -aX CPU performance counter measurements using PAPI", " (use with the -s option). X is one of:", @@ -633,6 +669,14 @@ errorBelch("not built for: -prof"); \ error = rtsTrue; #endif +#ifdef EVENTLOG +# define EVENTLOG_BUILD_ONLY(x) x +#else +# define EVENTLOG_BUILD_ONLY(x) \ +errorBelch("not built for: -par-prof"); \ +error = rtsTrue; +#endif + #ifdef PAR # define PAR_BUILD_ONLY(x) x #else @@ -682,20 +726,13 @@ error = rtsTrue; &rts_argv[arg][2])) { RtsFlags.MiscFlags.install_signal_handlers = rtsFalse; } + else if (strequal("machine-readable", + &rts_argv[arg][2])) { + RtsFlags.MiscFlags.machineReadable = rtsTrue; + } else if (strequal("info", &rts_argv[arg][2])) { - char *s; - printf("RTS info:\n"); - printf("RTS from GHC " ProjectVersion "\n"); - printf("RTS way " RtsWay "\n"); - printf("Host platform " HostPlatform "\n"); - printf("Build platform " BuildPlatform "\n"); - printf("Target platform " TargetPlatform "\n"); - s = strcmp(GhcUnregisterised, "YES") == 0 ? "un" : ""; - printf("Compiler is %sregisterised\n", s); - s = strcmp(GhcEnableTablesNextToCode, "YES") == 0 - ? "" : "not "; - printf("Tables are %snext to code\n", s); + printRtsInfo(); exit(0); } else { @@ -729,6 +766,14 @@ error = rtsTrue; case 'e': RtsFlags.PapiFlags.eventType = PAPI_FLAG_CB_EVENTS; break; + case '+': + if (RtsFlags.PapiFlags.numUserEvents >= MAX_PAPI_USER_EVENTS) { + errorBelch("maximum number of PAPI events reached"); + stg_exit(EXIT_FAILURE); + } + RtsFlags.PapiFlags.eventType = PAPI_USER_EVENTS; + RtsFlags.PapiFlags.userEvents[RtsFlags.PapiFlags.numUserEvents++] = rts_argv[arg] + 3; + break; default: bad_option( rts_argv[arg] ); } @@ -748,6 +793,10 @@ error = rtsTrue; } break; + case 'w': + RtsFlags.GcFlags.sweep = rtsTrue; + break; + case 'F': RtsFlags.GcFlags.oldGenFactor = atof(rts_argv[arg]+2); @@ -789,6 +838,9 @@ error = rtsTrue; case 'p': RtsFlags.DebugFlags.prof = rtsTrue; break; + case 'e': + RtsFlags.DebugFlags.eventlog = rtsTrue; + break; case 'r': RtsFlags.DebugFlags.gran = rtsTrue; break; @@ -869,10 +921,6 @@ error = rtsTrue; case 'H': RtsFlags.GcFlags.heapSizeSuggestion = decode(rts_argv[arg]+2) / BLOCK_SIZE; - - if (RtsFlags.GcFlags.heapSizeSuggestion <= 0) { - bad_option(rts_argv[arg]); - } break; #ifdef RTS_GTK_FRONTPANEL @@ -914,7 +962,7 @@ error = rtsTrue; { int r; r = open_stats_file(arg, *argc, argv, - *rts_argc, rts_argv, STAT_FILENAME_FMT, + *rts_argc, rts_argv, NULL, &RtsFlags.GcFlags.statsFile); if (r == -1) { error = rtsTrue; } } @@ -927,6 +975,14 @@ error = rtsTrue; /* =========== PROFILING ========================== */ + case 'l': +#ifdef EVENTLOG + RtsFlags.EventLogFlags.doEventLogging = rtsTrue; +#else + errorBelch("not built for: -eventlog"); +#endif + break; + case 'P': /* detailed cost centre profiling (time/alloc) */ case 'p': /* cost centre profiling (time/alloc) */ COST_CENTRE_USING_BUILD_ONLY( @@ -1120,22 +1176,63 @@ error = rtsTrue; #if defined(THREADED_RTS) && !defined(NOSMP) case 'N': THREADED_BUILD_ONLY( - if (rts_argv[arg][2] != '\0') { + if (rts_argv[arg][2] == '\0') { +#if defined(PROFILING) + RtsFlags.ParFlags.nNodes = 1; +#else + RtsFlags.ParFlags.nNodes = getNumberOfProcessors(); +#endif + } else { RtsFlags.ParFlags.nNodes = strtol(rts_argv[arg]+2, (char **) NULL, 10); if (RtsFlags.ParFlags.nNodes <= 0) { errorBelch("bad value for -N"); error = rtsTrue; } +#if defined(PROFILING) + if (RtsFlags.ParFlags.nNodes > 1) { + errorBelch("bad option %s: only -N1 is supported with profiling", rts_argv[arg]); + error = rtsTrue; + } +#endif } ) break; + case 'g': + THREADED_BUILD_ONLY( + switch (rts_argv[arg][2]) { + case '1': + // backwards compat only + RtsFlags.ParFlags.parGcEnabled = rtsFalse; + break; + default: + errorBelch("unknown RTS option: %s",rts_argv[arg]); + error = rtsTrue; + break; + } + ) break; + case 'q': switch (rts_argv[arg][2]) { case '\0': errorBelch("incomplete RTS option: %s",rts_argv[arg]); error = rtsTrue; break; + case '1': + RtsFlags.ParFlags.parGcEnabled = rtsFalse; + break; + case 'g': + if (rts_argv[arg][3] != '\0') { + RtsFlags.ParFlags.parGcGen + = strtol(rts_argv[arg]+3, (char **) NULL, 10); + } else { + errorBelch("bad value for -qg"); + error = rtsTrue; + } + break; + case 'b': + RtsFlags.ParFlags.parGcLoadBalancing = rtsFalse; + break; case 'm': RtsFlags.ParFlags.migrate = rtsFalse; break; @@ -1201,10 +1298,11 @@ error = rtsTrue; error = rtsTrue; break; case 't': - RtsFlags.TraceFlags.timestamp = rtsTrue; + RtsFlags.DebugFlags.timestamp = rtsTrue; break; case 's': - RtsFlags.TraceFlags.sched = rtsTrue; + case 'g': + // ignored for backwards-compat break; default: errorBelch("unknown RTS option: %s",rts_argv[arg]); @@ -1232,7 +1330,22 @@ error = rtsTrue; } break; - case 'c': /* Debugging tool: show current cost centre on an exception */ +#if defined(x86_64_HOST_ARCH) + case 'm': /* linkerMemBase */ + if (rts_argv[arg][3] != '\0') { + RtsFlags.MiscFlags.linkerMemBase + = strtol(rts_argv[arg]+3, (char **) NULL, 16); + if (RtsFlags.MiscFlags.linkerMemBase > 0x80000000) { + errorBelch("-xm: value must be <80000000"); + error = rtsTrue; + } + } else { + RtsFlags.MiscFlags.linkerMemBase = 0; + } + break; +#endif + + case 'c': /* Debugging tool: show current cost centre on an exception */ PROFILING_BUILD_ONLY( RtsFlags.ProfFlags.showCCSOnException = rtsTrue; ); @@ -2316,16 +2429,17 @@ open_stats_file ( { FILE *f = NULL; - if (strequal(rts_argv[arg]+2, "stderr")) { /* use debugBelch */ + if (strequal(rts_argv[arg]+2, "stderr") + || (FILENAME_FMT == NULL && rts_argv[arg][2] == '\0')) { f = NULL; /* NULL means use debugBelch */ } else { - if (rts_argv[arg][2] != '\0') { /* stats file specified */ - f = fopen(rts_argv[arg]+2,"w"); - } else { - char stats_filename[STATS_FILENAME_MAXLEN]; /* default . */ - sprintf(stats_filename, FILENAME_FMT, argv[0]); - f = fopen(stats_filename,"w"); - } + if (rts_argv[arg][2] != '\0') { /* stats file specified */ + f = fopen(rts_argv[arg]+2,"w"); + } else { + char stats_filename[STATS_FILENAME_MAXLEN]; /* default . */ + sprintf(stats_filename, FILENAME_FMT, argv[0]); + f = fopen(stats_filename,"w"); + } if (f == NULL) { errorBelch("Can't open stats file %s\n", rts_argv[arg]+2); return -1;