summaryrefslogtreecommitdiff
path: root/ghc/includes
Commit message (Collapse)AuthorAgeFilesLines
...
* [project @ 2005-10-21 15:18:54 by simonmar]simonmar2005-10-211-12/+6
| | | | Fix Win32 DEBUG warnings
* [project @ 2005-10-21 14:38:18 by simonmar]simonmar2005-10-211-1/+1
| | | | wibble
* [project @ 2005-10-21 14:02:17 by simonmar]simonmar2005-10-2116-170/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Big re-hash of the threaded/SMP runtime This is a significant reworking of the threaded and SMP parts of the runtime. There are two overall goals here: - To push down the scheduler lock, reducing contention and allowing more parts of the system to run without locks. In particular, the scheduler does not require a lock any more in the common case. - To improve affinity, so that running Haskell threads stick to the same OS threads as much as possible. At this point we have the basic structure working, but there are some pieces missing. I believe it's reasonably stable - the important parts of the testsuite pass in all the (normal,threaded,SMP) ways. In more detail: - Each capability now has a run queue, instead of one global run queue. The Capability and Task APIs have been completely rewritten; see Capability.h and Task.h for the details. - Each capability has its own pool of worker Tasks. Hence, Haskell threads on a Capability's run queue will run on the same worker Task(s). As long as the OS is doing something reasonable, this should mean they usually stick to the same CPU. Another way to look at this is that we're assuming each Capability is associated with a fixed CPU. - What used to be StgMainThread is now part of the Task structure. Every OS thread in the runtime has an associated Task, and it can ask for its current Task at any time with myTask(). - removed RTS_SUPPORTS_THREADS symbol, use THREADED_RTS instead (it is now defined for SMP too). - The RtsAPI has had to change; we must explicitly pass a Capability around now. The previous interface assumed some global state. SchedAPI has also changed a lot. - The OSThreads API now supports thread-local storage, used to implement myTask(), although it could be done more efficiently using gcc's __thread extension when available. - I've moved some POSIX-specific stuff into the posix subdirectory, moving in the direction of separating out platform-specific implementations. - lots of lock-debugging and assertions in the runtime. In particular, when DEBUG is on, we catch multiple ACQUIRE_LOCK()s, and there is also an ASSERT_LOCK_HELD() call. What's missing so far: - I have almost certainly broken the Win32 build, will fix soon. - any kind of thread migration or load balancing. This is high up the agenda, though. - various performance tweaks to do - throwTo and forkProcess still do not work in SMP mode
* [project @ 2005-10-17 09:36:39 by simonmar]simonmar2005-10-171-0/+30
| | | | | | | | if TARGETPLATFORM differs from HOSTPLATFORM, don't attempt to build DerivedConstants,h, ghcautoconf.h and GHCConstants.h. If these aren't present, emit a message to remind the user to copy them from the target system. Hopefully this should make bootstrapping slightly less error prone.
* [project @ 2005-10-13 00:11:17 by sof]sof2005-10-131-0/+2
| | | | add protos for HeapStackCheck.cmm:stg_block_blackhole_* entry points
* [project @ 2005-10-12 12:58:38 by simonmar]simonmar2005-10-121-1/+6
| | | | DEBUG_FILL_SLOP: don't do anything on SMP, zeroing slop words isn't safe
* [project @ 2005-10-10 10:32:09 by simonmar]simonmar2005-10-101-2/+2
| | | | Fix bug in previous commit (fixes recent seg faults in nightly stage2)
* [project @ 2005-10-05 13:34:04 by simonmar]simonmar2005-10-051-24/+31
| | | | DEBUG_FILL_SLOP(): fill slop for AP_STACK closures too
* [project @ 2005-07-25 14:12:48 by simonmar]simonmar2005-07-254-29/+16
| | | | | | Remove the ForeignObj# type, and all its PrimOps. The new efficient representation of ForeignPtr doesn't use ForeignObj# underneath, and there seems no need to keep it.
* [project @ 2005-07-25 13:59:09 by simonmar]simonmar2005-07-251-2/+8
| | | | | Tweaks to the GC to improve perforrmance. Might be as much as 10% on some programs.
* [project @ 2005-07-14 10:38:03 by simonmar]simonmar2005-07-141-4/+5
| | | | Fix mulMayOflo() on 64-bit archs. This fixes the arith003 failures on x86_64.
* [project @ 2005-07-12 11:51:31 by simonmar]simonmar2005-07-121-0/+2
| | | | | Move mallocBytesRWX into RtsUtils, rename it to stgMallocBytesRWX, and export it.
* [project @ 2005-07-12 09:42:59 by simonmar]simonmar2005-07-121-0/+1
| | | | declare stg_returnToSchedNotPaused (forgot to commit this yesterday)
* [project @ 2005-07-11 20:33:45 by panne]panne2005-07-111-3/+1
| | | | | | | | | | | | | | | | | | | After some experiments, it seems like we're stealing too many registers from newer GCCs on SPARC, leading to "unable to find a register to spill in class `GENERAL_REGS'" errors. The fix is to leave l6 and l7 to GCC. Tested with a full 2-stage bootstrap (including OpenGL/GLUT packages) on SPARC Solaris 8 with GCC 3.4.4. A test case for this (which I'm too lazy/tired to commit) is: module Blah ( foo ) where import Foreign.Ptr ( FunPtr ) type Bar = Int -> Double -> Double -> Double -> IO () foreign import ccall unsafe "dynamic" foo :: FunPtr Bar -> Bar SimonM: MERGE TO STABLE (if nobody yells)
* [project @ 2005-06-13 12:29:48 by simonmar]simonmar2005-06-131-0/+2
| | | | | | | | | | | | Block allocator performance fix: instead of keeping the free list ordered, keep it doubly-linked, and introduce a new flag BF_FREE so we can tell when a block is free. We can still coalesce blocks on the free list because block descriptors are kept consecutively in memory, so we can tell based on the BF_FREE flag whether to coalesce with the next higher/lower blocks when freeing a block. This (almost) make freeChain O(n) rather than O(n^2), and has been reported to help a lot when dealing with very large heaps.
* [project @ 2005-06-06 08:49:07 by tharris]tharris2005-06-063-5/+13
| | | | Remove SMP-only fields from STM data structures from non-SMP builds
* [project @ 2005-05-27 14:47:08 by tharris]tharris2005-05-276-77/+98
| | | | Update STM implementation for SMP builds
* [project @ 2005-05-24 16:10:35 by simonmar]simonmar2005-05-242-4/+4
| | | | Move RTS_SUPPORTS_THREADS into RtsConfig.h
* [project @ 2005-05-24 15:43:32 by simonmar]simonmar2005-05-241-3/+14
| | | | implement lockClosure properly
* [project @ 2005-05-19 13:21:55 by simonmar]simonmar2005-05-191-1/+2
| | | | | | | | | | | | | | | | | - Move the call to threadPaused() from the scheduler into STG land, and put it in a new code fragment (stg_returnToSched) that we pass through every time we return from STG to the scheduler. Also, the SAVE_THREAD_STATE() is now in stg_returnToSched which might save a little code space (at the expense of an extra jump for every return to the scheduler). - SMP: when blocking on an MVar, we now wait until the thread has been made fully safe and placed on the blocked queue of the MVar before we unlock the MVar. This closes a race whereby another OS thread could begin waking us up before the current TSO had been properly tidied up. Fixes one cause of crashes when using MVars with SMP. I still have a deadlock problem to track down.
* [project @ 2005-05-18 14:19:12 by simonmar]simonmar2005-05-181-19/+30
| | | | Slop-filling fixes for SMP/DEBUG
* [project @ 2005-05-18 13:10:21 by simonmar]simonmar2005-05-181-0/+2
| | | | Fix unreg build on Windows
* [project @ 2005-05-16 14:27:07 by simonmar]simonmar2005-05-161-0/+2
| | | | | | | | | | | | | | | | | | | Allow the amount of idle time which must pass before we force a major GC to be configured at runtime with the +RTS -I<secs> option. The idle GC only happens in the threaded RTS, and it is useful because it can make finalizers run more promptly, and also detect cases of deadlock. Without the idle GC, Haskell computation must be taking place in order for finalizers to run or deadlock to be detected, and the only way some Haskell computation can take place is usually by in-calls. +RTS -I0 turns off the idle GC, the default is +RTS -I0.3. We might need to add more tuning if it turns out that the idle GC is problematic, for example we don't check how long the GC actually took, and we should probably back off if major GCs are taking too long and adversely affecting interactive responsiveness.
* [project @ 2005-05-13 14:27:56 by simonmar]simonmar2005-05-131-1/+0
| | | | gcc 4.0.0 fix: don't declare static static_objects as extern
* [project @ 2005-05-12 10:32:40 by simonmar]simonmar2005-05-121-0/+1
| | | | Declare checkNurserySanity()
* [project @ 2005-05-10 13:25:41 by simonmar]simonmar2005-05-106-56/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | Two SMP-related changes: - New storage manager interface: bdescr *allocateLocal(StgRegTable *reg, nat words) which allocates from the current thread's nursery (being careful not to clash with the heap pointer). It can do this without taking any locks; the lock only has to be taken if a block needs to be allocated. allocateLocal() is now used instead of allocate() in a few PrimOps. This removes locks from most Integer operations, cutting down the overhead for SMP a bit more. To make this work, we have to be able to grab the current thread's Capability out of thin air (i.e. when called from GMP), so the Capability subsystem needs to keep a hash from thread IDs to Capabilities. - Small MVar optimisation: instead of taking the global storage-manager lock, do our own locking of MVars with a bit of inline assembly (x86 only for now).
* [project @ 2005-05-05 11:20:12 by simonmar]simonmar2005-05-051-5/+41
| | | | Fix the offsets and macros for AP_STACK closures (was wrong for SMP only)
* [project @ 2005-04-28 21:31:45 by simonmar]simonmar2005-04-281-2/+2
| | | | | StgFunInfoExtra_slow_apply(): convert the slow_apply_offset to a W_ before arithmetic.
* [project @ 2005-04-28 15:28:05 by simonmar]simonmar2005-04-281-27/+30
| | | | | | Small code-size optimisation: I forgot to add a specialised case for functions with no argument words (which might happen if the function takes a void argument, for example).
* [project @ 2005-04-27 14:37:26 by simonmar]simonmar2005-04-271-5/+6
| | | | | | When using -H<size> in SMP mode, divide the total nursery size amongst the various nurseries. -H<size> now does something reasonable with SMP.
* [project @ 2005-04-27 14:25:17 by simonmar]simonmar2005-04-273-6/+119
| | | | | | | Hold the sm_mutex around access to the mutable list. The SMP RTS now seems quite stable, I've run my simple test program with 64 threads without crashes.
* [project @ 2005-04-22 17:00:48 by sof]sof2005-04-222-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | [mingw only] Better handling of I/O request abortions upon throwing an exception to a Haskell thread. As was, a thread blocked on an I/O request was simply unblocked, but its corresponding worker thread wasn't notified that the request had been abandoned. This manifested itself in GHCi upon Ctrl-C being hit at the prompt -- the worker thread blocked waiting for input on stdin prior to Ctrl-C would stick around even though its corresponding Haskell thread had been thrown an Interrupted exception. The upshot was that the worker would consume the next character typed in after Ctrl-C, but then just dropping it. Dealing with this turned out to be even more interesting due to Win32 aborting any console reads when Ctrl-C/Break events are delivered. The story could be improved upon (at the cost of portability) by making the Scheduler able to abort worker thread system calls; as is, requests are cooperatively abandoned. Maybe later. Also included are other minor tidyups to Ctrl-C handling under mingw. Merge to STABLE.
* [project @ 2005-04-22 12:28:00 by simonmar]simonmar2005-04-224-0/+21
| | | | | | | | | | | | - Now that labels are always prefixed with '&' in .hc code, we have to fix some sloppiness in the RTS .cmm code. Fortunately it's not too painful. - SMP: acquire/release the storage manager lock around atomicModifyMutVar#. This is a hack: atomicModifyMutVar# isn't atomic under SMP otherwise, but the SM lock is a large sledgehammer. I think I'll apply the sledgehammer to the MVar primitives too, for the time being.
* [project @ 2005-04-22 09:32:39 by simonmar]simonmar2005-04-226-23/+101
| | | | | | | SMP: the rest of the changes to support safe thunk entry & updates. I thought the compiler changes were independent, but I ended up breaking the HEAD, so I'll have to commit the rest. non-SMP compilation should not be affected.
* [project @ 2005-04-20 13:56:18 by simonmar]simonmar2005-04-201-29/+38
| | | | remove gaps in the closure type sequence, and add a big warning comment
* [project @ 2005-04-12 09:17:47 by simonmar]simonmar2005-04-121-0/+3
| | | | | | The in_haskell sanity check should be per-Capability rather than global. I just ran a Haskell program in 8 pthreads simultaneously :-)
* [project @ 2005-04-12 09:04:23 by simonmar]simonmar2005-04-124-16/+12
| | | | | | | | | Per-task nurseries for SMP. This was kind-of implemented before, but it's much cleaner now. There is now one *step* per capability, so we have somewhere to hang the block count. So for SMP, there are simply multiple instances of generation 0 step 0. The rNursery entry in the register table now points to the step rather than the head block of the nurersy.
* [project @ 2005-04-07 14:33:30 by simonmar]simonmar2005-04-071-0/+3
| | | | | | | | | Support handling signals in the threaded RTS by passing the signal number down the pipe to the IO manager. This avoids needing synchronisation in the signal handler. Signals should now work with -threaded. Since this is a bugfix, I'll merge the changes into the 6.4 branch.
* [project @ 2005-04-05 21:27:54 by simonmar]simonmar2005-04-051-1/+1
| | | | wibble
* [project @ 2005-04-05 21:26:11 by simonmar]simonmar2005-04-051-1/+1
| | | | unreg wibble
* [project @ 2005-04-05 21:24:53 by simonmar]simonmar2005-04-051-2/+4
| | | | wibble to fix the unreg way
* [project @ 2005-04-05 14:31:17 by simonmar]simonmar2005-04-051-1/+1
| | | | wibble
* [project @ 2005-04-05 14:23:35 by simonmar]simonmar2005-04-051-1/+1
| | | | Catch up with InfoTable changes
* [project @ 2005-04-05 12:19:54 by simonmar]simonmar2005-04-057-85/+13
| | | | | | | | | | | | | | | | | | | | | | Some multi-processor hackery, including - Don't hang blocked threads off BLACKHOLEs any more, instead keep them all on a separate queue which is checked periodically for threads to wake up. This is good because (a) we don't have to worry about locking the closure in SMP mode when we want to block on it, and (b) it means the standard update code doesn't need to wake up any threads or check for a BLACKHOLE_BQ, simplifying the update code. The downside is that if there are lots of threads blocked on BLACKHOLEs, we might have to do a lot of repeated list traversal. We don't expect this to be common, though. conc023 goes slower with this change, but we expect most programs to benefit from the shorter update code. - Fixing up the Capability code to handle multiple capabilities (SMP mode), and related changes to get the SMP mode at least building.
* [project @ 2005-04-05 09:38:00 by simonmar]simonmar2005-04-053-17/+63
| | | | | | | | | | | | | Main x86_64 hacking: we have a problem on this arch where binutils can't generate 64-bit relative relocations (R_X86_64_PC64), which many of our info-table fields are. So far we've been hacking around it by putting everything in the text section, but I've decided to adopt another approach: we'll use explicit 32-bit offset fields on this platform instead. This is safe in the default "small" memory model where all symbols are guaranteed to be in the lower 2Gb of the address space. NCG changes coming; mangler changes are probably required too.
* [project @ 2005-04-04 10:39:23 by simonmar]simonmar2005-04-042-2/+2
| | | | Give prototypes for getAllocations and revertCAFs.
* [project @ 2005-04-02 19:56:18 by simonmar]simonmar2005-04-021-2/+0
| | | | unconditionally define oFFSET_StgRegTable_rL1
* [project @ 2005-03-30 16:45:58 by wolfgang]wolfgang2005-03-301-1/+1
| | | | | | | Track size change of alloc_blocks and alloc_blocks_lim. (They are of type nat, which used to be the same size as W_, but now is the same size as CInt).
* [project @ 2005-03-30 11:07:48 by simonmar]simonmar2005-03-301-5/+1
| | | | | | reverse rev 1.4: nat should be unsigned int, not unsigned long. I'm doing this (a) to fix some printf type errors, and (b) to see what breaks.
* [project @ 2005-03-27 13:41:13 by panne]panne2005-03-2734-412/+486
| | | | | | | | | | * Some preprocessors don't like the C99/C++ '//' comments after a directive, so use '/* */' instead. For consistency, a lot of '//' in the include files were converted, too. * UnDOSified libraries/base/cbits/runProcess.c. * My favourite sport: Killed $Id$s.