diff options
author | simonmar <unknown> | 1999-11-02 15:06:05 +0000 |
---|---|---|
committer | simonmar <unknown> | 1999-11-02 15:06:05 +0000 |
commit | f6692611aad945e46ffb615bde1df7def3fc742f (patch) | |
tree | 04e2e2af9c43eba1b60312b89eb3ac8f34209e2c /ghc/includes/StgMacros.h | |
parent | 947d2e363f75e9e230d535c876ecdafba45174b5 (diff) | |
download | haskell-f6692611aad945e46ffb615bde1df7def3fc742f.tar.gz |
[project @ 1999-11-02 15:05:38 by simonmar]
This commit adds in the current state of our SMP support. Notably,
this allows the new way 's' to be built, providing support for running
multiple Haskell threads simultaneously on top of any pthreads
implementation, the idea being to take advantage of commodity SMP
boxes.
Don't expect to get much of a speedup yet; due to the excessive
locking required to synchronise access to mutable heap objects, you'll
see a slowdown in most cases, even on a UP machine. The best I've
seen is a 1.6-1.7 speedup on an example that did no locking (two
optimised nfibs in parallel).
- new RTS -N flag specifies how many pthreads to start.
- new driver -smp flag, tells the driver to use way 's'.
- new compiler -fsmp option (not for user comsumption)
tells the compiler not to generate direct jumps to
thunk entry code.
- largely rewritten scheduler
- _ccall_GC is now done by handing back a "token" to the
RTS before executing the ccall; it should now be possible
to execute blocking ccalls in the current thread while
allowing the RTS to continue running Haskell threads as
normal.
- you can only call thread-safe C libraries from a way 's'
build, of course.
Pthread support is still incomplete, and weird things (including
deadlocks) are likely to happen.
Diffstat (limited to 'ghc/includes/StgMacros.h')
-rw-r--r-- | ghc/includes/StgMacros.h | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/ghc/includes/StgMacros.h b/ghc/includes/StgMacros.h index 3dec7513b0..b14ab43a82 100644 --- a/ghc/includes/StgMacros.h +++ b/ghc/includes/StgMacros.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgMacros.h,v 1.13 1999/10/13 16:39:21 simonmar Exp $ + * $Id: StgMacros.h,v 1.14 1999/11/02 15:05:52 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -416,12 +416,23 @@ EDI_(stg_gen_chk_info); #define SET_TAG(t) /* nothing */ #ifdef EAGER_BLACKHOLING -# define UPD_BH_UPDATABLE(thunk) \ - TICK_UPD_BH_UPDATABLE(); \ - SET_INFO((StgClosure *)thunk,&BLACKHOLE_info) -# define UPD_BH_SINGLE_ENTRY(thunk) \ - TICK_UPD_BH_SINGLE_ENTRY(); \ - SET_INFO((StgClosure *)thunk,&SE_BLACKHOLE_info) +# ifdef SMP +# define UPD_BH_UPDATABLE(info) \ + TICK_UPD_BH_UPDATABLE(); \ + LOCK_THUNK(info); \ + SET_INFO(R1.cl,&BLACKHOLE_info) +# define UPD_BH_SINGLE_ENTRY(info) \ + TICK_UPD_BH_SINGLE_ENTRY(); \ + LOCK_THUNK(info); \ + SET_INFO(R1.cl,&BLACKHOLE_info) +# else +# define UPD_BH_UPDATABLE(info) \ + TICK_UPD_BH_UPDATABLE(); \ + SET_INFO(R1.cl,&BLACKHOLE_info) +# define UPD_BH_SINGLE_ENTRY(info) \ + TICK_UPD_BH_SINGLE_ENTRY(); \ + SET_INFO(R1.cl,&SE_BLACKHOLE_info) +# endif #else /* !EAGER_BLACKHOLING */ # define UPD_BH_UPDATABLE(thunk) /* nothing */ # define UPD_BH_SINGLE_ENTRY(thunk) /* nothing */ @@ -642,10 +653,15 @@ extern DLL_IMPORT_DATA const StgPolyInfoTable seq_frame_info; We save all the STG registers (that is, the ones that are mapped to machine registers) in their places in the TSO. - The stack registers go into the current stack object, and the heap - registers are saved in global locations. + The stack registers go into the current stack object, and the + current nursery is updated from the heap pointer. + + These functions assume that BaseReg is loaded appropriately (if + we have one). -------------------------------------------------------------------------- */ +#ifndef NO_REGS + static __inline__ void SaveThreadState(void) { @@ -656,6 +672,12 @@ SaveThreadState(void) CurrentTSO->splim = SpLim; CloseNursery(Hp); +#ifdef REG_CurrentTSO + SAVE_CurrentTSO = CurrentTSO; +#endif +#ifdef REG_CurrentNursery + SAVE_CurrentNursery = CurrentNursery; +#endif #if defined(PROFILING) CurrentTSO->prof.CCCS = CCCS; #endif @@ -664,19 +686,30 @@ SaveThreadState(void) static __inline__ void LoadThreadState (void) { -#ifdef REG_Base - BaseReg = (StgRegTable*)&MainRegTable; -#endif - Sp = CurrentTSO->sp; Su = CurrentTSO->su; SpLim = CurrentTSO->splim; OpenNursery(Hp,HpLim); +#ifdef REG_CurrentTSO + CurrentTSO = SAVE_CurrentTSO; +#endif +#ifdef REG_CurrentNursery + CurrentNursery = SAVE_CurrentNursery; +#endif # if defined(PROFILING) CCCS = CurrentTSO->prof.CCCS; # endif } +/* + * Suspending/resuming threads for doing external C-calls (_ccall_GC). + * These functions are defined in rts/Schedule.c. + */ +StgInt suspendThread ( StgRegTable *cap ); +StgRegTable * resumeThread ( StgInt ); + +#endif /* NO_REGS */ + #endif /* STGMACROS_H */ |