1. 15 Feb, 2002 1 commit
  2. 13 Feb, 2002 1 commit
    • sof's avatar
      [project @ 2002-02-13 08:48:06 by sof] · e289780e
      sof authored
      Revised implementation of multi-threaded callouts (and callins):
      
      - unified synchronisation story for threaded and SMP builds,
        following up on SimonM's suggestion. The following synchro
        variables are now used inside the Scheduler:
      
          + thread_ready_cond - condition variable that is signalled
            when a H. thread has become runnable (via the THREAD_RUNNABLE()
            macro) and there are available capabilities. Waited on:
               + upon schedule() entry (iff no caps. available).
      	 + when a thread inside of the Scheduler spots that there
      	   are no runnable threads to service, but one or more
      	   external call is in progress.
      	 + in resumeThread(), waiting for a capability to become
      	   available.
      
            Prior to waiting on thread_ready_cond, a counter rts_n_waiting_tasks
            is incremented, so that we can keep track of the number of
            readily available worker threads (need this in order to make
            an informed decision on whether or not to create a new thread
            when an external call is made).
      
      
          + returning_worker_cond - condition variable that is waited
            on by an OS thread that has finished executing and external
            call & now want to feed its result back to the H thread
            that made the call. Before doing so, the counter
            rts_n_returning_workers is incremented.
      
            Upon entry to the Scheduler, this counter is checked for &
            if it is non-zero, the thread gives up its capability and
            signals returning_worker_cond before trying to re-grab a
            capability. (releaseCapability() takes care of this).
      
          + sched_mutex - protect Scheduler data structures.
          + gc_pending_cond - SMP-only condition variable for signalling
            completion of GCs.
      
      - initial implementation of call-ins, i.e., multiple OS threads
        may concurrently call into the RTS without interfering with
        each other. Implementation uses cheesy locking protocol to
        ensure that only one OS thread at a time can construct a
        function application -- stop-gap measure until the RtsAPI
        is revised (as discussed last month) *and* a designated
        block is used for allocating these applications.
      
      - In the implementation of call-ins, the OS thread blocks
        waiting for an RTS worker thread to complete the evaluation
        of the function application. Since main() also uses the
        RtsAPI, provide a separate entry point for it (rts_mainEvalIO()),
        which avoids creating a separate thread to evaluate Main.main,
        that can be done by the thread exec'ing main() directly.
        [Maybe there's a tidier way of doing this, a bit ugly the
        way it is now..]
      
      
      There are a couple of dark corners that needs to be looked at,
      such as conditions for shutting down (and how) + consider what
      ought to happen when async I/O is thrown into the mix (I know
      what will happen, but that's maybe not what we want).
      
      Other than that, things are in a generally happy state & I hope
      to declare myself done before the week is up.
      e289780e
  3. 22 Jan, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-01-22 13:54:22 by simonmar] · 33a7aa8b
      simonmar authored
      Deadlock is now an exception instead of a return status from
      rts_evalIO().
      
      The current behaviour is as follows, and can be changed if necessary:
      in the event of a deadlock, the top main thread is taken from the main
      thread queue, and if it is blocked on an MVar or an Exception (for
      throwTo), then it receives a Deadlock exception.  If it is blocked on
      a BLACKHOLE, we instead send it the NonTermination exception.  Note
      that only the main thread gets the exception: it is the responsibility
      of the main thread to unblock other threads if necessary.
      
      There's a slight difference in the SMP build: *all* the main threads
      get an exception, because clearly none of them may make progress
      (compared to the non-SMP situation, where all but the top main thread
      are usually blocked).
      33a7aa8b
  4. 23 Oct, 2001 1 commit
  5. 29 Aug, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-08-29 11:20:40 by simonmar] · 13350796
      simonmar authored
      - use SET_HDR rather than initialising header.info directly (fixes
        potential bugs with profiling).
      
      - add some masking to the Int32/Word32 cases to match the Int8-16 and
        Word8-16 cases (potential 64-bit bugs).
      13350796
  6. 14 Aug, 2001 1 commit
    • sewardj's avatar
      [project @ 2001-08-14 13:40:07 by sewardj] · bc5c8021
      sewardj authored
      Change the story about POSIX headers in C compilation.
      
      Until now, all C code in the RTS and library cbits has by default been
      compiled with settings for POSIXness enabled, that is:
         #define _POSIX_SOURCE   1
         #define _POSIX_C_SOURCE 199309L
         #define _ISOC9X_SOURCE
      If you wanted to negate this, you'd have to define NON_POSIX_SOURCE
      before including headers.
      
      This scheme has some bad effects:
      
      * It means that ccall-unfoldings exported via interfaces from a
        module compiled with -DNON_POSIX_SOURCE may not compile when
        imported into a module which does not -DNON_POSIX_SOURCE.
      
      * It overlaps with the feature tests we do with autoconf.
      
      * It seems to have caused borkage in the Solaris builds for some
        considerable period of time.
      
      The New Way is:
      
      * The default changes to not-being-in-Posix mode.
      
      * If you want to force a C file into Posix mode, #include as
        the **first** include the new file ghc/includes/PosixSource.h.
        Most of the RTS C sources have this include now.
      
      * NON_POSIX_SOURCE is almost totally expunged.  Unfortunately
        we have to retain some vestiges of it in ghc/compiler so that
        modules compiled via C on Solaris using older compilers don't
        break.
      bc5c8021
  7. 03 Aug, 2001 1 commit
  8. 22 Mar, 2001 1 commit
    • hwloidl's avatar
      [project @ 2001-03-22 03:51:08 by hwloidl] · 20fc2f0c
      hwloidl authored
      -*- outline -*-
      Time-stamp: <Thu Mar 22 2001 03:50:16 Stardate: [-30]6365.79 hwloidl>
      
      This commit covers changes in GHC to get GUM (way=mp) and GUM/GdH (way=md)
      working. It is a merge of my working version of GUM, based on GHC 4.06,
      with GHC 4.11. Almost all changes are in the RTS (see below).
      
      GUM is reasonably stable, we used the 4.06 version in large-ish programs for
      recent papers. Couple of things I want to change, but nothing urgent.
      GUM/GdH has just been merged and needs more testing. Hope to do that in the
      next weeks. It works in our working build but needs tweaking to run.
      GranSim doesn't work yet (*sigh*). Most of the code should be in, but needs
      more debugging.
      
      ToDo: I still want to make the following minor modifications before the release
      - Better wrapper skript for parallel execution [ghc/compiler/main]
      - Update parallel docu: started on it but it's minimal [ghc/docs/users_guide]
      - Clean up [nofib/parallel]: it's a real mess right now (*sigh*)
      - Update visualisation tools (minor things only IIRC) [ghc/utils/parallel]
      - Add a Klingon-English glossary
      
      * RTS:
      
      Almost all changes are restricted to ghc/rts/parallel and should not
      interfere with the rest. I only comment on changes outside the parallel
      dir:
      
      - Several changes in Schedule.c (scheduling loop; createThreads etc);
        should only affect parallel code
      - Added ghc/rts/hooks/ShutdownEachPEHook.c
      - ghc/rts/Linker.[ch]: GUM doesn't know about Stable Names (ifdefs)!!
      - StgMiscClosures.h: END_TSO_QUEUE etc now defined here (from StgMiscClosures.hc)
                           END_ECAF_LIST was missing a leading stg_
      - SchedAPI.h: taskStart now defined in here; it's only a wrapper around
                    scheduleThread now, but might use some init, shutdown later
      - RtsAPI.h: I have nuked the def of rts_evalNothing
      
      * Compiler:
      
      - ghc/compiler/main/DriverState.hs
        added PVM-ish flags to the parallel way
        added new ways for parallel ticky profiling and distributed exec
      
      - ghc/compiler/main/DriverPipeline.hs
        added a fct run_phase_MoveBinary which is called with way=mp after linking;
        it moves the bin file into a PVM dir and produces a wrapper script for
        parallel execution
        maybe cleaner to add a MoveBinary phase in DriverPhases.hs but this way
        it's less intrusive and MoveBinary makes probably only sense for mp anyway
      
      * Nofib:
      
      - nofib/spectral/Makefile, nofib/real/Makefile, ghc/tests/programs/Makefile:
        modified to skip some tests if HWL_NOFIB_HACK is set; only tmp to record
        which test prgs cause problems in my working build right now
      20fc2f0c
  9. 08 Feb, 2001 1 commit
  10. 11 Jan, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-01-11 17:25:56 by simonmar] · efa88123
      simonmar authored
      Re-organisation of ghc/lib/std and hslibs/lang
      ----------------------------------------------
      
      In brief: move deprecated features out of ghc/lib/std and into
      hslibs/lang, move new FFI libraries into ghc/lib/std and start
      using them.
      
      - foreign import may now return an unboxed type (this was
        advertised to work before, but in fact didn't).  Subsequent
        cleanups in PrelInt/PrelWord.
      
      - Ptr is now defined in ghc/lib/std/PrelPtr.lhs.  Ptr is no
        longer a newtype of Addr, it is defined directly in terms of
        Addr#.
      
      - PrelAddr has disappeared from ghc/lib/std, all uses of Addr in
        ghc/lib/std have been replaced with Ptr.  The definitions of
        Addr has been moved to hslibs/lang/Addr.lhs, as has
        lots of other Addr-related stuff.
      
      - ForeignObj has been removed from ghc/lib/std, and replaced with
        ForeignPtr.  The definition of ForeignObj has been moved to
        hslibs/lang/ForeignObj.lhs.
      
      - Most of the new FFI has been moved into ghc/lib/std in the form
        of modules PrelMarshalAlloc, PrelCString, PrelCError,
        PrelMarshalError, PrelMarshalArray, PrelMarshalUtils,
        PrelCTypes, PrelCTypesISO, and PrelStorable.  The corresponding
        modules in hslibs/lang simply re-export the contents of these
        modules.
      
      - PrelPosixTypes defines a few POSIX types (CMode == mode_t,
        etc.)
      
      - PrelCError changed to access errno using foreign label and peek
        (the POSIX book I have says that errno is guaranteed to be an
        extern int, so this should be OK until I get around to making
        errno thread-safe).
      
      - Hacked the macros that generate the code for CTypes and
        CTypesISO to generate much less code
        (ghc/lib/std/cbits/CTypes.h).
      
      - RtsAPI is now a bit more honest when it comes to building heap
        objects (it uses the correct constructors).
      
      - the Bits class and related stuff has been moved to ghc/lib/std
        (it was simpler this way).
      
      - Directory and System have been converted to use the new FFI.
      efa88123
  11. 04 Dec, 2000 1 commit
  12. 13 Nov, 2000 1 commit
  13. 07 Nov, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-11-07 17:05:47 by simonmar] · 2de8104d
      simonmar authored
      Clean ups:
      
         - reduce the namespace pollution of StgTypes.h, it doesn't define
           the shorthand versions any more (W_, I_ etc.).  These are moved into
           Stg.h.  StgTypes.h also defines StgClosure as an "opaque" struct.
      
         - RtsAPI.h is now standalone, and includes HsFFI.h and thereby
           config.h & StgTypes.h.  Now we don't need to #include "Stg.h" in
           *_stub.c.
      
         - all the rts_mkXXXX and rts_getXXXX functions are defined in terms
           of the HsXXXX types rather than random C types (this fixes some
           potential bugs in our foreign export support).
      
         - added HsWord type, to match StgWord.  The Haskell version of this
           type isn't "documented", but perhaps it should be.
      2de8104d
  14. 29 Aug, 2000 1 commit
  15. 15 Aug, 2000 1 commit
  16. 07 Aug, 2000 1 commit
    • qrczak's avatar
      [project @ 2000-08-07 23:37:19 by qrczak] · 4b172698
      qrczak authored
      Now Char, Char#, StgChar have 31 bits (physically 32).
      "foo"# is still an array of bytes.
      
      CharRep represents 32 bits (on a 64-bit arch too). There is also
      Int8Rep, used in those places where bytes were originally meant.
      readCharArray, indexCharOffAddr etc. still use bytes. Storable and
      {I,M}Array use wide Chars.
      
      In future perhaps all sized integers should be primitive types. Then
      some usages of indexing primops scattered through the code could
      be changed to then-available Int8 ones, and then Char variants of
      primops could be made wide (other usages that handle text should use
      conversion that will be provided later).
      
      I/O and _ccall_ arguments assume ISO-8859-1. UTF-8 is internally used
      for string literals (only).
      
      Z-encoding is ready for Unicode identifiers.
      
      Ranges of intlike and charlike closures are more easily configurable.
      
      I've probably broken nativeGen/MachCode.lhs:chrCode for Alpha but I
      don't know the Alpha assembler to fix it (what is zapnot?). Generally
      I'm not sure if I've done the NCG changes right.
      
      This commit breaks the binary compatibility (of course).
      
      TODO:
      * is* and to{Lower,Upper} in Char (in progress).
      * Libraries for text conversion (in design / experiments),
        to be plugged to I/O and a higher level foreign library.
      * PackedString.
      * StringBuffer and accepting source in encodings other than ISO-8859-1.
      4b172698
  17. 26 Apr, 2000 1 commit
  18. 25 Apr, 2000 1 commit
  19. 05 Apr, 2000 1 commit
  20. 04 Apr, 2000 1 commit
  21. 31 Mar, 2000 1 commit
    • hwloidl's avatar
      [project @ 2000-03-31 03:09:35 by hwloidl] · dd4c28a9
      hwloidl authored
      Numerous changes in the RTS to get GUM-4.06 working (currently works with
      parfib-ish programs). Most changes are isolated in the rts/parallel dir.
      
      rts/parallel/:
        The most important changes are a rewrite of the (un-)packing code (Pack.c)
        and changes in LAGA, GALA table operations (Global.c) expecially in
        rebuilding the tables during GC.
      
      rts/:
        Minor changes in Schedule.c, GC.c (interface to par specific root marking
        and evacuation), and lots of additions to Sanity.c (surprise ;-)
        Main.c change for startup: I use a new function rts_evalNothing to
        start non-main-PEs in a PAR || SMP setup (RtsAPI.c)
      
      includes/:
        Updated GranSim macros in PrimOps.h.
      
      lib/std:
        Few changes in PrelHandle.c etc replacing ForeignObj by Addr in a PAR
        setup (we still don't support ForeignObjs or WeakPtrs in GUM).
        Typically use
          #define FILE_OBJECT	    Addr
        when dealing with files.
      
      hslibs/lang/:
        Same as above (in Foreign(Obj).lhs, Weak.lhs, IOExts.lhs etc).
      
      -- HWL
      dd4c28a9
  22. 14 Mar, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-03-14 09:55:05 by simonmar] · 3ddfe34b
      simonmar authored
      Handle references from the RTS to the Prelude in a more consistent
      way.
      
      	- For statically-linked binaries, nothing has changed.
      
      	- For the interpreter, refs from the RTS to the Prelude
      	  are now indirected.  The indirections need to be
      	  filled in at some point during startup by calling
      	  fixupPreludeRefs (in Prelude.c).
      
      	- The CHARLIKE and INTLIKE tables are now handled in
      	  the same way for both Hugs and DLLs.
      
      Hugs will be broken for a short while until Julian sorts out the Hugs
      parts of this change.
      3ddfe34b
  23. 13 Mar, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-03-13 10:53:55 by simonmar] · 0d5d32bf
      simonmar authored
      Move Prelude.h from ghc/includes into ghc/rts.  It's essentially a
      list of the things from the Prelude that the RTS depends on, and isn't
      relevant to STG code.  Furthermore, this helps to clarify which parts
      of the RTS depend on things from the Prelude (by an explicity
      #include).
      0d5d32bf
  24. 02 Nov, 1999 1 commit
    • simonmar's avatar
      [project @ 1999-11-02 15:05:38 by simonmar] · f6692611
      simonmar authored
      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.
      f6692611
  25. 15 Oct, 1999 1 commit
    • sewardj's avatar
      [project @ 1999-10-15 11:02:06 by sewardj] · dfb12323
      sewardj authored
      Added basic support for foreign export dynamic.
      
      Many aspects of it are still broken:
      * Only supports x86-linux.
      * The range of allowable types is small: Char Int Float Double
        Addr and Word.
      * Adjustor thunks are never freed.
      * Returning Doubles or Floats doesn't work at all.
      
      I expect to fix some of these shortly.  foreign import also
      needs redoing, so it can accept any number of arguments of
      any type.
      
      Also:
      * Fixed setRtsFlags in Evaluator.c to make it endian-independent.
      * Fixed raisePrim in Evaluator.c so things like division by zero,
        array index errors, etc, throw an exception instead of
        terminating StgHugs.  raisePrim is renamed makeErrorCall.
      dfb12323
  26. 06 Jul, 1999 1 commit
    • sof's avatar
      [project @ 1999-07-06 09:42:38 by sof] · f86b9ce4
      sof authored
      Redo previous commit to cut down on the use of COMPILING_RTS where
      possible - SchedAPI.h is now an RTS internal header file which
      RtsAPI.h no longer includes.
      f86b9ce4
  27. 21 May, 1999 1 commit
    • sof's avatar
      [project @ 1999-05-21 14:46:19 by sof] · 263aaaa5
      sof authored
      Made rts_evalIO() stricter, i.e.,
      
         rts_evalIO( action );
      
      will now essentially cause `action' to be applied
      to the following (imaginary) defn of `evalIO':
      
          evalIO :: IO a -> IO a
          evalIO action = action >>= \ x -> x `seq` return x
      
      instead of just
      
          evalIO :: IO a -> IO a
          evalIO action = action >>= \ x -> return x
      
      The old, lazier behaviour is now available via rts_evalLazyIO().
      263aaaa5
  28. 04 May, 1999 1 commit
  29. 03 Mar, 1999 1 commit
  30. 05 Feb, 1999 1 commit
  31. 27 Jan, 1999 1 commit
    • simonpj's avatar
      [project @ 1999-01-27 14:51:14 by simonpj] · 18976e61
      simonpj authored
      Finally!  This commits the ongoing saga of Simon's hygiene sweep
      
      FUNCTIONALITY
      ~~~~~~~~~~~~~
      a) The 'unused variable' warnings from the renamer work.  
      b) Better error messages here and there, esp type checker
      c) Fixities for Haskell 98 (maybe I'd done that before)
      d) Lazy reporting of name clashes for Haskell 98 (ditto)
      
      HYGIENE
      ~~~~~~~
      a) type OccName has its own module.  OccNames are represented
         by a single FastString, not three as in the last round.  This
         string is held in Z-encoded form; a decoding function decodes
         for printing in user error messages.  There's a nice tight
         encoding for (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
      
      b) type Module is a proper ADT, in module OccName
      
      c) type RdrName is a proper ADT, in its own module
      
      d) type Name has a new, somwhat tidier, representation
      
      e) much grunting in the renamer to get Provenances right.
         This makes error messages look better (no spurious qualifiers)
      18976e61
  32. 02 Dec, 1998 1 commit