X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fruntime%2Fmain%2Fmain.lc;h=9293b3004ff255dd195e125e32108a25fd0b9259;hb=063eda14b18aadc138bc27eb460e1af93b09ca9b;hp=fd70cd623b3fde1c08ddf6a07de8deb1a15ae29f;hpb=10521d8418fd3a1cf32882718b5bd28992db36fd;p=ghc-hetmet.git diff --git a/ghc/runtime/main/main.lc b/ghc/runtime/main/main.lc index fd70cd6..9293b30 100644 --- a/ghc/runtime/main/main.lc +++ b/ghc/runtime/main/main.lc @@ -24,7 +24,7 @@ /* memory.h and strings.h conflict on some systems. */ #endif /* not STDC_HEADERS and not HAVE_STRING_H */ -#if defined(PROFILING) || defined(PAR) +#if defined(PROFILING) || defined(PAR) || defined(GRAN) /* need some "time" things */ /* ToDo: This is a mess! Improve ? */ @@ -55,7 +55,7 @@ extern void checkAStack(STG_NO_ARGS); /* a real nasty Global Variable */ /* moved to main/TopClosure(13)?.lc -- *one* of them will get linked in -P_ TopClosure = Main_mainPrimIO_closure; +P_ TopClosure = GHCmain_mainPrimIO_closure; */ /* structure to carry around info about the storage manager */ @@ -66,22 +66,16 @@ extern I_ OkToGC, buckets; extern rtsBool TraceSparks, DelaySparks, DeferGlobalUpdates; -extern void RunParallelSystem PROTO((P_)); -extern void initParallelSystem(STG_NO_ARGS); -extern void SynchroniseSystem(STG_NO_ARGS); - -extern void SetTrace PROTO((W_ address, I_ level/*?*/)); -#endif +void RunParallelSystem PROTO((P_)); +void initParallelSystem(STG_NO_ARGS); +void SynchroniseSystem(STG_NO_ARGS); -#if defined(GRAN_CHECK) && defined(GRAN) -extern W_ debug; -extern W_ event_trace ; -extern W_ event_trace_all ; +void SetTrace PROTO((W_ address, I_ level/*?*/)); #endif -extern void *stgAllocForGMP PROTO((size_t)); -extern void *stgReallocForGMP PROTO ((void *, size_t, size_t)); -extern void stgDeallocForGMP PROTO ((void *, size_t)); +void *stgAllocForGMP PROTO((size_t)); +void *stgReallocForGMP PROTO ((void *, size_t, size_t)); +void stgDeallocForGMP PROTO ((void *, size_t)); /* NeXTs can't just reach out and touch "end", to use in distinguishing things in static vs dynamic (malloc'd) memory. @@ -99,17 +93,16 @@ char *rts_argv[MAX_RTS_ARGS]; jmp_buf restart_main; /* For restarting after a signal */ #endif -#if defined(PVM) -unsigned nPEs = 0, nIMUs = 0; -#endif - #if defined(PAR) -int nPEs = 0; +int nPEs = 0; /* Number of PEs */ #endif int /* return type of "main" is defined by the C standard */ main(int argc, char *argv[]) { +#ifdef GRAN + int i; +#endif \end{code} The very first thing we do is grab the start time...just in case we're @@ -126,19 +119,23 @@ Manager's requirements. \begin{code} #ifdef PAR + if (*argv[0] == '-') { /* Look to see whether we're the Main Thread */ + IAmMainThread = rtsTrue; + argv++; argc--; /* Strip off flag argument */ +/* fprintf(stderr, "I am Main Thread\n"); */ + } /* * Grab the number of PEs out of the argument vector, and * eliminate it from further argument processing. */ nPEs = atoi(argv[1]); argv[1] = argv[0]; - argv++; - argc--; - + argv++; argc--; + initEachPEHook(); /* HWL: hook to be execed on each PE */ SynchroniseSystem(); #endif -#if defined(PROFILING) || defined(PAR) +#if defined(PROFILING) || defined(PAR) || defined(GRAN) /* setup string indicating time of run -- only used for profiling */ (void) time_str(); #endif @@ -176,10 +173,11 @@ Manager's requirements. } #endif -#if defined(CONCURRENT) && defined(GRAN) - if (!no_gr_profile) +#if defined(GRAN) + if (!RTSflags.GranFlags.granSimStats_suppressed) if (init_gr_simulation(rts_argc, rts_argv, prog_argc, prog_argv) != 0) { - fprintf(stderr, "init_gr_simulation failed!\n"); EXIT(EXIT_FAILURE); + fprintf(stderr, "init_gr_simulation failed!\n"); + EXIT(EXIT_FAILURE); } #endif @@ -229,7 +227,7 @@ Manager's requirements. /* Record initialization times */ end_init(); -#if defined(PROFILING) || defined(CONCURRENT) +#if defined(PROFILING) || defined(CONCURRENT) /* * Both the context-switcher and the cost-center profiler use * a virtual timer. @@ -265,29 +263,33 @@ Manager's requirements. #endif #ifdef CONCURRENT + AvailableStack = AvailableTSO = Prelude_Z91Z93_closure; # if defined(GRAN) /* HWL */ - /* RunnableThreadsHd etc. are init in ScheduleThreads */ - /* - * I'm not sure about this. Note that this code is for re-initializing - * things when a longjmp to restart_main occurs. --JSM - */ - -# else /* !GRAN */ - AvailableStack = AvailableTSO = Nil_closure; - RunnableThreadsHd = RunnableThreadsTl = Nil_closure; - WaitingThreadsHd = WaitingThreadsTl = Nil_closure; + /* Moved in here from ScheduleThreads, to handle a restart_main + (because of a signal) properly. */ + for (i=0; i char * @@ -401,7 +393,7 @@ getErrorHandler(STG_NO_ARGS) return (StgInt) errorHandler; } -#ifndef PAR +#if !defined(PAR) void raiseError( handler )