X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FRtsFlags.c;h=e439afe00cb28a34e6abda7f4124c3dc46ae3aa2;hp=0f83b3356c3a23ba8bb7275f2196ef9fa4c3b1db;hb=1525a5819aa3a6eae8d8b05cfe348a2384da0c84;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1 diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 0f83b33..e439afe 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -1,32 +1,17 @@ - /* ----------------------------------------------------------------------------- * * (c) The AQUA Project, Glasgow University, 1994-1997 - * (c) The GHC Team, 1998-1999 + * (c) The GHC Team, 1998-2006 * * Functions for parsing the argument list. * * ---------------------------------------------------------------------------*/ -//@menu -//* Includes:: -//* Constants:: -//* Static function decls:: -//* Command-line option parsing routines:: -//* GranSim specific options:: -//* Aux fcts:: -//@end menu -//*/ - -//@node Includes, Constants -//@subsection Includes - #include "PosixSource.h" #include "Rts.h" #include "RtsFlags.h" #include "RtsUtils.h" #include "BlockAlloc.h" -#include "Timer.h" /* CS_MIN_MILLISECS */ #include "Profiling.h" #ifdef HAVE_CTYPE_H @@ -48,9 +33,6 @@ char *prog_name = NULL; /* 'basename' of prog_argv[0] */ int rts_argc = 0; /* ditto */ char *rts_argv[MAX_RTS_ARGS]; -//@node Constants, Static function decls, Includes -//@subsection Constants - /* * constants, used later */ @@ -108,9 +90,6 @@ static char par_debug_opts_flags[] = { #endif /* PAR */ -//@node Static function decls, Command-line option parsing routines, Constants -//@subsection Static function decls - /* ----------------------------------------------------------------------------- Static function decls -------------------------------------------------------------------------- */ @@ -137,9 +116,6 @@ static void set_par_debug_options(nat n); static void help_par_debug_options(nat n); #endif -//@node Command-line option parsing routines, GranSim specific options, Static function decls -//@subsection Command-line option parsing routines - /* ----------------------------------------------------------------------------- * Command-line option parsing routines. * ---------------------------------------------------------------------------*/ @@ -173,12 +149,11 @@ void initRtsFlagsDefaults(void) #ifdef RTS_GTK_FRONTPANEL RtsFlags.GcFlags.frontpanel = rtsFalse; #endif - RtsFlags.GcFlags.idleGCDelayTicks = 300 / TICK_MILLISECS; /* ticks */ + RtsFlags.GcFlags.idleGCDelayTime = 300; /* millisecs */ #ifdef DEBUG RtsFlags.DebugFlags.scheduler = rtsFalse; RtsFlags.DebugFlags.interpreter = rtsFalse; - RtsFlags.DebugFlags.codegen = rtsFalse; RtsFlags.DebugFlags.weak = rtsFalse; RtsFlags.DebugFlags.gccafs = rtsFalse; RtsFlags.DebugFlags.gc = rtsFalse; @@ -215,7 +190,8 @@ void initRtsFlagsDefaults(void) RtsFlags.ProfFlags.doHeapProfile = rtsFalse; #endif - RtsFlags.ConcFlags.ctxtSwitchTime = CS_MIN_MILLISECS; /* In milliseconds */ + RtsFlags.MiscFlags.tickInterval = 50; /* In milliseconds */ + RtsFlags.ConcFlags.ctxtSwitchTime = 50; /* In milliseconds */ #ifdef THREADED_RTS RtsFlags.ParFlags.nNodes = 1; @@ -322,6 +298,9 @@ void initRtsFlagsDefaults(void) RtsFlags.TickyFlags.showTickyStats = rtsFalse; RtsFlags.TickyFlags.tickyFile = NULL; #endif + + RtsFlags.TraceFlags.timestamp = rtsFalse; + RtsFlags.TraceFlags.sched = rtsFalse; } static const char * @@ -415,14 +394,19 @@ usage_text[] = { " -N Use PVMish processors in parallel (default: 2)", /* NB: the -N is implemented by the driver!! */ #endif -" -C Context-switch interval in seconds", -" (0 or no argument means switch as often as possible)", -" the default is .02 sec; resolution is .02 sec", +" -C Context-switch interval in seconds.", +" 0 or no argument means switch as often as possible.", +" Default: 0.02 sec; resolution is set by -V below.", +" -V Master tick interval in seconds.", +" 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", "", #if defined(DEBUG) " -Ds DEBUG: scheduler", " -Di DEBUG: interpreter", -" -Dc DEBUG: codegen", " -Dw DEBUG: weak", " -DG DEBUG: gccafs", " -Dg DEBUG: gc", @@ -437,7 +421,7 @@ usage_text[] = { " -Dz DEBUG: stack squezing", "", #endif /* DEBUG */ -#if defined(THREADED_RTS) +#if defined(THREADED_RTS) && !defined(NOSMP) " -N Use OS threads (default: 1)", " -qm Don't automatically migrate threads between CPUs", " -qw Migrate a thread to the current CPU when it is woken up", @@ -693,9 +677,6 @@ error = rtsTrue; case 'i': RtsFlags.DebugFlags.interpreter = rtsTrue; break; - case 'c': - RtsFlags.DebugFlags.codegen = rtsTrue; - break; case 'w': RtsFlags.DebugFlags.weak = rtsTrue; break; @@ -812,14 +793,9 @@ error = rtsTrue; } else { I_ cst; /* tmp */ - /* Convert to ticks */ + /* Convert to millisecs */ 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; + RtsFlags.GcFlags.idleGCDelayTime = cst; } break; @@ -1015,10 +991,6 @@ error = rtsTrue; /* 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; - RtsFlags.ProfFlags.profileInterval = cst; } break; @@ -1033,15 +1005,24 @@ error = rtsTrue; /* 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; - RtsFlags.ConcFlags.ctxtSwitchTime = cst; } break; -#ifdef THREADED_RTS + case 'V': /* master tick interval */ + if (rts_argv[arg][2] == '\0') { + // turns off ticks completely + RtsFlags.MiscFlags.tickInterval = 0; + } else { + I_ cst; /* tmp */ + + /* Convert to milliseconds */ + cst = (I_) ((atof(rts_argv[arg]+2) * 1000)); + RtsFlags.MiscFlags.tickInterval = cst; + } + break; + +#if defined(THREADED_RTS) && !defined(NOSMP) case 'N': THREADED_BUILD_ONLY( if (rts_argv[arg][2] != '\0') { @@ -1054,7 +1035,7 @@ error = rtsTrue; } ) break; - case 'q': + case 'q': switch (rts_argv[arg][2]) { case '\0': errorBelch("incomplete RTS option: %s",rts_argv[arg]); @@ -1116,6 +1097,27 @@ error = rtsTrue; } ) break; + /* =========== TRACING ---------=================== */ + + case 'v': + switch(rts_argv[arg][2]) { + case '\0': + errorBelch("incomplete RTS option: %s",rts_argv[arg]); + error = rtsTrue; + break; + case 't': + RtsFlags.TraceFlags.timestamp = rtsTrue; + break; + case 's': + RtsFlags.TraceFlags.sched = rtsTrue; + break; + default: + errorBelch("unknown RTS option: %s",rts_argv[arg]); + error = rtsTrue; + break; + } + break; + /* =========== EXTENDED OPTIONS =================== */ case 'x': /* Extend the argument space */ @@ -1154,6 +1156,47 @@ error = rtsTrue; } } } + + // Determine what tick interval we should use for the RTS timer + // by taking the shortest of the various intervals that we need to + // monitor. + if (RtsFlags.MiscFlags.tickInterval <= 0) { + RtsFlags.MiscFlags.tickInterval = 50; + } + + if (RtsFlags.ConcFlags.ctxtSwitchTime > 0) { + RtsFlags.MiscFlags.tickInterval = + stg_min(RtsFlags.ConcFlags.ctxtSwitchTime, + RtsFlags.MiscFlags.tickInterval); + } + + if (RtsFlags.GcFlags.idleGCDelayTime > 0) { + RtsFlags.MiscFlags.tickInterval = + stg_min(RtsFlags.GcFlags.idleGCDelayTime, + RtsFlags.MiscFlags.tickInterval); + } + +#ifdef PROFILING + if (RtsFlags.ProfFlags.profileInterval > 0) { + RtsFlags.MiscFlags.tickInterval = + stg_min(RtsFlags.ProfFlags.profileInterval, + RtsFlags.MiscFlags.tickInterval); + } +#endif + + if (RtsFlags.ConcFlags.ctxtSwitchTime > 0) { + RtsFlags.ConcFlags.ctxtSwitchTicks = + RtsFlags.ConcFlags.ctxtSwitchTime / + RtsFlags.MiscFlags.tickInterval; + } else { + RtsFlags.ConcFlags.ctxtSwitchTicks = 0; + } + +#ifdef PROFILING + RtsFlags.ProfFlags.profileIntervalTicks = + RtsFlags.ProfFlags.profileInterval / RtsFlags.MiscFlags.tickInterval; +#endif + if (error) { const char **p; @@ -1166,9 +1209,6 @@ error = rtsTrue; #if defined(GRAN) -//@node GranSim specific options, Aux fcts, Command-line option parsing routines -//@subsection GranSim specific options - static void enable_GranSimLight(void) { @@ -2140,9 +2180,6 @@ help_par_debug_options(nat n) { #endif /* PAR */ -//@node Aux fcts, , GranSim specific options -//@subsection Aux fcts - static void stats_fprintf(FILE *f, char *s, ...) {