[project @ 1996-07-25 20:43:49 by partain]
[ghc-hetmet.git] / ghc / includes / Parallel.lh
index 83f2f44..6a565db 100644 (file)
@@ -32,11 +32,14 @@ These basic definitions need to be around, one way or the other:
 
 \begin{code}
 # ifdef PAR
-#  define MAX_PES      128             /* Maximum number of processors */
+#  define MAX_PES      256             /* Maximum number of processors */
+       /* MAX_PES is enforced by SysMan, which does not
+          allow more than this many "processors".
+          This is important because PackGA [GlobAddr.lc]
+          **assumes** that a PE# can fit in 8+ bits.
+       */
 
-extern I_ do_gr_profile;
 extern I_ do_sp_profile;
-extern I_ do_gr_binary;
 
 extern P_ PendingFetches;
 extern GLOBAL_TASK_ID *PEs;
@@ -88,7 +91,6 @@ extern void myexit PROTO((I_));
 # else
 #  define EXIT exit
 # endif
-
 \end{code}
 
 %************************************************************************
@@ -112,8 +114,9 @@ Get this out of the way.  These are all null definitions.
   
 #  define SET_TASK_ACTIVITY(act)               /* nothing */
 
-# else
-# ifdef GRAN
+#endif
+
+#if defined(GRAN)
 
 #  define GA_HDR_SIZE                  1
 
@@ -127,13 +130,10 @@ Get this out of the way.  These are all null definitions.
        PROCS(closure) = (W_)(procs)    /* Set closure's location */
 #  define SET_GRAN_HDR(closure,pe)     SET_PROCS(closure,pe)
 
-#  if defined(GRAN_TNG)
 #   define SET_STATIC_PROCS(closure)   , (W_) (Everywhere)
-#  else
-#   define SET_STATIC_PROCS(closure)   , (W_) (MainPE)
-#  endif   /* GRAN_TNG */
 
 #  define SET_TASK_ACTIVITY(act)       /* nothing */
+#endif
 \end{code}
 
 %************************************************************************
@@ -151,7 +151,7 @@ for local closures that have no global address), and @setGA@ to store a new
 global address for a local closure which did not previously have one.
 
 \begin{code}
-# else /* it must be PARallel (to end of file) */
+#if defined(PAR) 
 
 #  define GA_HDR_SIZE                  0
   
@@ -164,8 +164,11 @@ global address for a local closure which did not previously have one.
   
 #  define MAX_GA_WEIGHT                        0       /* Treat as 2^n */
   
-#  define PACK_GA(pe,slot)    ((((W_)(pe)) << (BITS_IN(W_)/2)) | ((W_)(slot)))
-
+W_ PackGA PROTO((W_, int));
+   /* There was a PACK_GA macro here; but we turned it into the PackGA
+      routine [GlobAddr.lc] (because it needs to do quite a bit of
+      paranoia checking.  Phil & Will (95/08)
+   */
 \end{code}
 
 At the moment, there is no activity profiling for GUM.  This may change.
@@ -315,7 +318,7 @@ a distinguished info pointer.
 
 \begin{code}
 #  define FMBQ_VHS                     BQ_VHS
-#  define FMBQ_HS                              BQ_HS
+#  define FMBQ_HS                      BQ_HS
   
 #  define FMBQ_CLOSURE_SIZE(closure)   BQ_CLOSURE_SIZE(closure)
 #  define FMBQ_CLOSURE_NoPTRS(closure) BQ_CLOSURE_NoPTRS(closure)
@@ -439,13 +442,8 @@ Special info-table for local blocking queues.
 %************************************************************************
 
 \begin{code}
-#  ifdef GRAN
-#   define HAVE_SPARK ((PendingSparksHd[REQUIRED_POOL] != Nil_closure) ||      \
-                   (PendingSparksHd[ADVISORY_POOL] != Nil_closure))
-#  else
 #   define HAVE_SPARK ((PendingSparksHd[REQUIRED_POOL] < PendingSparksTl[REQUIRED_POOL]) \
                ||  (PendingSparksHd[ADVISORY_POOL] < PendingSparksTl[ADVISORY_POOL]))
-#  endif
 
 #  define HAVE_WORK    (RUNNING_THREAD || HAVE_SPARK)
 #  define RUNNING_THREAD  (CurrentTSO != NULL)
@@ -464,34 +462,45 @@ This constant defines how many words of data we can pack into a single
 packet in the parallel (GUM) system.
 
 \begin{code}
-#  ifdef GUM
-P_      PackNearbyGraph PROTO((P_ closure,W_ *size));
+void   InitPackBuffer(STG_NO_ARGS);
 P_      PackTSO PROTO((P_ tso, W_ *size));
 P_      PackStkO PROTO((P_ stko, W_ *size));
 P_     AllocateHeap PROTO((W_ size)); /* Doesn't belong */
 
-P_      get_closure_info PROTO((P_ closure, W_ *size, W_ *ptrs, W_ *nonptrs, W_ *vhs));
-
-rtsBool isOffset PROTO((globalAddr *ga)),
-       isFixed PROTO((globalAddr *ga));
-
 void    InitClosureQueue (STG_NO_ARGS);
 P_      DeQueueClosure(STG_NO_ARGS);
 void    QueueClosure PROTO((P_ closure));
 rtsBool QueueEmpty(STG_NO_ARGS);
 void    PrintPacket PROTO((P_ buffer));
-void    doGlobalGC(STG_NO_ARGS);
 
-P_ UnpackGraph PROTO((W_ *buffer, globalAddr **gamap, W_ *nGAs));
-#  endif
+P_      get_closure_info PROTO((P_ closure, W_ *size, W_ *ptrs, W_ *nonptrs, W_ *vhs, char *type));
 
-#  define PACK_BUFFER_SIZE     1024
-#  define PACK_HEAP_REQUIRED  \
-    ((PACK_BUFFER_SIZE - PACK_HDR_SIZE) / (PACK_GA_SIZE + _FHS) * (SPEC_HS + 2))
+rtsBool isOffset PROTO((globalAddr *ga)),
+       isFixed PROTO((globalAddr *ga));
 
+void    doGlobalGC(STG_NO_ARGS);
+
+P_      PackNearbyGraph PROTO((P_ closure,W_ *size));
+P_      UnpackGraph PROTO((W_ *buffer, globalAddr **gamap, W_ *nGAs));
 \end{code}
 
 \begin{code}
+#    define PACK_HEAP_REQUIRED  \
+      ((RTSflags.ParFlags.packBufferSize - PACK_HDR_SIZE) / (PACK_GA_SIZE + _FHS) * (SPEC_HS + 2))
+
+extern W_      *PackBuffer;      /* size: can be set via option */
+extern long *buffer;             /* HWL_ */
+extern W_ *freeBuffer;           /* HWL_ */
+extern W_ *packBuffer;           /* HWL_ */
+
+extern void    InitPackBuffer(STG_NO_ARGS);
+extern void    InitMoreBuffers(STG_NO_ARGS);
+extern void    InitPendingGABuffer(W_ size); 
+extern void    AllocClosureQueue(W_ size);
+
+#  define MAX_GAS      (RTSflags.ParFlags.packBufferSize / PACK_GA_SIZE)
+
+
 #  define PACK_GA_SIZE 3       /* Size of a packed GA in words */
                                /* Size of a packed fetch-me in words */
 #  define PACK_FETCHME_SIZE (PACK_GA_SIZE + FIXED_HS)
@@ -499,14 +508,56 @@ P_ UnpackGraph PROTO((W_ *buffer, globalAddr **gamap, W_ *nGAs));
 #  define PACK_HDR_SIZE        1       /* Words of header in a packet */
 
 #  define PACK_PLC_SIZE        2       /* Size of a packed PLC in words */
-  
-#  define MAX_GAS      (PACK_BUFFER_SIZE / PACK_GA_SIZE)
 
+#endif
 \end{code}
-End multi-slurp protection:
 \begin{code}
-# endif /* yes, it is PARallel */
-#endif /* it was GRAN or PARallel */
+
+#if defined(GRAN)
+/* ToDo: Check which of the PAR routines are needed in GranSim -- HWL */
+void  InitPackBuffer(STG_NO_ARGS);
+P_    AllocateHeap PROTO((W_ size)); /* Doesn't belong */
+P_    PackNearbyGraph PROTO((P_ closure, P_ tso, W_ *packbuffersize));
+P_    PackOneNode PROTO((P_ closure, P_ tso, W_ *packbuffersize));
+P_    UnpackGraph PROTO((P_ buffer));
+
+void    InitClosureQueue (STG_NO_ARGS);
+P_      DeQueueClosure(STG_NO_ARGS);
+void    QueueClosure PROTO((P_ closure));
+rtsBool QueueEmpty(STG_NO_ARGS);
+void    PrintPacket PROTO((P_ buffer));
+
+P_      get_closure_info PROTO((P_ closure, W_ *size, W_ *ptrs, W_ *nonptrs, W_ *vhs, char *type));
+
+/* These are needed in the packing code to get the size of the packet
+   right. The closures itself are never built in GrAnSim. */
+#  define FETCHME_VHS                          IND_VHS
+#  define FETCHME_HS                           IND_HS
+  
+#  define FETCHME_GA_LOCN                       FETCHME_HS
+  
+#  define FETCHME_CLOSURE_SIZE(closure)                IND_CLOSURE_SIZE(closure)
+#  define FETCHME_CLOSURE_NoPTRS(closure)              0L
+#  define FETCHME_CLOSURE_NoNONPTRS(closure)   (IND_CLOSURE_SIZE(closure)-IND_VHS)
+  
+#  define MAX_GAS      (RTSflags.GranFlags.packBufferSize / PACK_GA_SIZE)
+#  define PACK_GA_SIZE 3       /* Size of a packed GA in words */
+                               /* Size of a packed fetch-me in words */
+#  define PACK_FETCHME_SIZE (PACK_GA_SIZE + FIXED_HS)
+#  define PACK_HDR_SIZE        4       /* Words of header in a packet */
+
+#    define PACK_HEAP_REQUIRED  \
+      ((RTSflags.GranFlags.packBufferSize - PACK_HDR_SIZE) / (PACK_GA_SIZE \
+      + _FHS) * (SPEC_HS + 2)) 
+
+#    define PACK_FLAG_LOCN           0  
+#    define PACK_TSO_LOCN            1
+#    define PACK_UNPACKED_SIZE_LOCN  2
+#    define PACK_SIZE_LOCN           3
+#    define MAGIC_PACK_FLAG          0xfabc
+#endif  
 
 #endif /* Parallel_H */
 \end{code}
+
+