summaryrefslogtreecommitdiff
path: root/ghc/includes/Stg.h
diff options
context:
space:
mode:
authorsimonmar <unknown>1999-11-02 15:06:05 +0000
committersimonmar <unknown>1999-11-02 15:06:05 +0000
commitf6692611aad945e46ffb615bde1df7def3fc742f (patch)
tree04e2e2af9c43eba1b60312b89eb3ac8f34209e2c /ghc/includes/Stg.h
parent947d2e363f75e9e230d535c876ecdafba45174b5 (diff)
downloadhaskell-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/Stg.h')
-rw-r--r--ghc/includes/Stg.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/ghc/includes/Stg.h b/ghc/includes/Stg.h
index 9b2ab0d5c0..756e8fb51a 100644
--- a/ghc/includes/Stg.h
+++ b/ghc/includes/Stg.h
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $Id: Stg.h,v 1.17 1999/07/06 09:42:39 sof Exp $
+ * $Id: Stg.h,v 1.18 1999/11/02 15:05:52 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
@@ -16,6 +16,17 @@
#define _POSIX_SOURCE
#endif
+/* If we include "Stg.h" directly, we're in STG code, and we therefore
+ * get all the global register variables, macros etc. that go along
+ * with that. If "Stg.h" is included via "Rts.h", we're assumed to
+ * be in vanilla C.
+ */
+#ifdef NOT_IN_STG_CODE
+#define NO_REGS /* don't define fixed registers */
+#else
+#define IN_STG_CODE
+#endif
+
/* Configuration */
#include "config.h"
#ifdef __HUGS__ /* vile hack till the GHC folks come on board */
@@ -33,13 +44,17 @@
* For now, do lazy and not eager.
*/
-#define LAZY_BLACKHOLING
-/* #define EAGER_BLACKHOLING */
-
-#ifdef TICKY_TICKY
-/* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of single-entry thunks. */
-# undef LAZY_BLACKHOLING
-# define EAGER_BLACKHOLING
+/* TICKY_TICKY needs EAGER_BLACKHOLING to verify no double-entries of
+ * single-entry thunks.
+ *
+ * SMP needs EAGER_BLACKHOLING because it has to lock thunks
+ * synchronously, in case another thread is trying to evaluate the
+ * same thunk simultaneously.
+ */
+#if defined(SMP) || defined(TICKY_TICKY)
+# define EAGER_BLACKHOLING
+#else
+# define LAZY_BLACKHOLING
#endif
/* ToDo: Set this flag properly: COMPILER and INTERPRETER should not be mutually exclusive. */
@@ -96,8 +111,10 @@ void _stgAssert (char *, unsigned int);
#include "ClosureTypes.h"
#include "InfoTables.h"
#include "TSO.h"
+#include "Block.h"
/* STG/Optimised-C related stuff */
+#include "SMP.h"
#include "MachRegs.h"
#include "Regs.h"
#include "TailCalls.h"
@@ -121,6 +138,10 @@ void _stgAssert (char *, unsigned int);
#include <unistd.h>
#endif
+#ifdef SMP
+#include <pthread.h>
+#endif
+
/* GNU mp library */
#include "gmp.h"