/*
- Time-stamp: <Fri Dec 10 1999 17:15:01 Stardate: [-30]4028.38 software>
-
- Definitions for parallel machines.
+ Definitions for GUM i.e. running on a parallel machine.
This section contains definitions applicable only to programs compiled
to run on a parallel machine, i.e. on GUM. Some of these definitions
are also used when simulating parallel execution, i.e. on GranSim.
*/
-/*
- ToDo: Check the PAR specfic part of this file
- Move stuff into Closures.h and ClosureMacros.h
- Clean-up GRAN specific code
- -- HWL
-*/
-
#ifndef PARALLEL_H
#define PARALLEL_H
#if defined(PAR) || defined(GRAN) /* whole file */
-//@node Parallel definitions, End of File
-//@section Parallel definitions
-
-//@menu
-//* Basic definitions::
-//* GUM::
-//* GranSim::
-//@end menu
-
-//@node Basic definitions, GUM, Parallel definitions, Parallel definitions
-//@subsection Basic definitions
+/*
+ * @node Parallel definitions, End of File
+ * @section Parallel definitions
+ *
+ * @menu
+ * * Basic definitions::
+ * * GUM::
+ * * GranSim::
+ * @end menu
+ *
+ * @node Basic definitions, GUM, Parallel definitions, Parallel definitions
+ * @subsection Basic definitions
+ */
+
+/* This clashes with TICKY, but currently TICKY and PAR hate each other anyway */
+#define _HS sizeofW(StgHeader)
/* SET_PAR_HDR and SET_STATIC_PAR_HDR now live in ClosureMacros.h */
# define NODE_STR_LEN 20
# define TIME_STR_LEN 120
# define TIME rtsTime
-# define CURRENT_TIME msTime()
-# define TIME_ON_PROC(p) msTime()
+# define CURRENT_TIME (msTime() - startTime)
+# define TIME_ON_PROC(p) (msTime() - startTime)
# define CURRENT_PROC thisPE
# define BINARY_STATS RtsFlags.ParFlags.ParStats.Binary
#elif defined(GRAN)
# define ADVISORY_POOL 1 /* idx of pool of advisory sparks (parallelism) */
#endif
-//@menu
-//* GUM::
-//* GranSim::
-//@end menu
-//*/
-
-//@node GUM, GranSim, Basic definitions, Parallel definitions
-//@subsection GUM
+/*
+ * @menu
+ * * GUM::
+ * * GranSim::
+ * @end menu
+ *
+ * @node GUM, GranSim, Basic definitions, Parallel definitions
+ * @subsection GUM
+ */
#if defined(PAR)
/*
-Symbolic constants for the packing code.
-
-This constant defines how many words of data we can pack into a single
-packet in the parallel (GUM) system.
+ Symbolic constants for the packing code.
+
+ This constant defines how many words of data we can pack into a single
+ packet in the parallel (GUM) system.
*/
-//@menu
-//* Types::
-//* Externs::
-//* Prototypes::
-//* Macros::
-//@end menu
-//*/
-
-//@node Types, Externs, GUM, GUM
-//@subsubsection Types
+/*
+ * @menu
+ * * Types::
+ * * Externs::
+ * * Prototypes::
+ * * Macros::
+ * @end menu
+ *
+ * @node Types, Externs, GUM, GUM
+ * @subsubsection Types
+ */
/* Sparks and spark queues */
typedef StgClosure *rtsSpark;
#define PACK_BUFFER_HDR_SIZE 4
-//@node Externs, Prototypes, Types, GUM
-//@subsubsection Externs
+/*
+ * @node Externs, Prototypes, Types, GUM
+ * @subsubsection Externs
+ */
-// extern rtsBool do_sp_profile;
+/* extern rtsBool do_sp_profile; */
extern globalAddr theGlobalFromGA, theGlobalToGA;
extern StgBlockedFetch *PendingFetches;
extern GlobalTaskId *allPEs;
extern rtsBool IAmMainThread, GlobalStopPending;
-//extern rtsBool fishing;
+/*extern rtsBool fishing; */
extern rtsTime last_fish_arrived_at;
extern nat outstandingFishes;
extern GlobalTaskId SysManTask;
extern rtsBool InGlobalGC; /* Are we in the midst of performing global GC */
-static ullong startTime; /* start of comp; in RtsStartup.c */
+extern ullong startTime; /* start of comp; in RtsStartup.c */
/* the spark pools proper */
extern rtsSpark *pending_sparks_hd[]; /* ptr to start of a spark pool */
extern nat spark_limit[];
extern rtsPackBuffer *PackBuffer; /* size: can be set via option */
-extern rtsPackBuffer *buffer; /* HWL_ */
-extern rtsPackBuffer *freeBuffer; /* HWL_ */
-extern rtsPackBuffer *packBuffer; /* HWL_ */
+extern rtsPackBuffer *buffer;
+extern rtsPackBuffer *freeBuffer;
+extern rtsPackBuffer *packBuffer;
extern rtsPackBuffer *gumPackBuffer;
-extern int thisPE;
+extern nat thisPE;
-/* From Global.c */
+/* From Global.c
extern GALA *freeGALAList;
extern GALA *freeIndirections;
extern GALA *liveIndirections;
extern GALA *liveRemoteGAs;
-
-/*
-extern HashTable *taskIDtoPEtable;
-extern HashTable *LAtoGALAtable;
-extern HashTable *pGAtoGALAtable;
*/
-//@node Prototypes, Macros, Externs, GUM
-//@subsubsection Prototypes
+/*
+ * @node Prototypes, Macros, Externs, GUM
+ * @subsubsection Prototypes
+ */
/* From ParInit.c */
void initParallelSystem(void);
void registerTask (GlobalTaskId gtid);
globalAddr *LAGAlookup (StgClosure *addr);
StgClosure *GALAlookup (globalAddr *ga);
-//static GALA *allocIndirection (StgPtr addr);
+/*static GALA *allocIndirection (StgPtr addr); */
globalAddr *makeGlobal (StgClosure *addr, rtsBool preferred);
globalAddr *setRemoteGA (StgClosure *addr, globalAddr *ga, rtsBool preferred);
void splitWeight (globalAddr *to, globalAddr *from);
void RebuildLAGAtable (void);
StgWord PackGA (StgWord pe, int slot);
-//@node Macros, , Prototypes, GUM
-//@subsubsection Macros
+# if defined(DEBUG)
+/* from Global.c */
+/* highest_slot breaks the abstraction of the slot counter for GAs; it is
+ only used for sanity checking and should used nowhere else */
+StgInt highest_slot (void);
+# endif
+
+/*
+ * @node Macros, , Prototypes, GUM
+ * @subsubsection Macros
+ */
/* delay (in us) between dying fish returning and sending out a new fish */
#define FISH_DELAY 1000
/* max no. of outstanding spark steals */
#define MAX_FISHES 1
-// ToDo: check which of these is actually needed!
+/* ToDo: check which of these is actually needed! */
-# define PACK_HEAP_REQUIRED ((RtsFlags.ParFlags.packBufferSize - PACK_HDR_SIZE) / (PACK_GA_SIZE + _FHS) * (MIN_UPD_SIZE + 2))
+# define PACK_HEAP_REQUIRED ((RtsFlags.ParFlags.packBufferSize - PACK_HDR_SIZE) / (PACK_GA_SIZE + _HS) * (MIN_UPD_SIZE + 2))
# 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)
+# define PACK_FETCHME_SIZE (PACK_GA_SIZE + _HS)
# define PACK_HDR_SIZE 1 /* Words of header in a packet */
/* At the moment, there is no activity profiling for GUM. This may change. */
# define SET_TASK_ACTIVITY(act) /* nothing */
+/*
+ The following macros are only needed for sanity checking (see Sanity.c).
+*/
+
+/* NB: this is PVM specific and should be updated for MPI etc
+ in PVM a task id (tid) is split into 2 parts: the id for the
+ physical processor it is running on and an index of tasks running
+ on a processor; PVM_PE_MASK indicates which part of a tid holds the
+ id of the physical processor (the other part of the word holds the
+ index on that processor)
+ MAX_PVM_PES and MAX_PVM_TIDS are maximal values for these 2 components
+ in GUM we have an upper bound for the total number of PVM PEs allowed:
+ it's MAX_PE defined in Parallel.h
+ to check the slot field of a GA we call a fct highest_slot which just
+ returns the internal counter
+*/
+#define PVM_PE_MASK 0xfffc0000
+#define MAX_PVM_PES MAX_PES
+#define MAX_PVM_TIDS MAX_PES
+
+#if 0
+#define LOOKS_LIKE_TID(tid) (((tid & PVM_PE_MASK) != 0) && \
+ (((tid & PVM_PE_MASK) + (tid & ~PVM_PE_MASK)) < MAX_PVM_TIDS))
+#define LOOKS_LIKE_SLOT(slot) (slot<=highest_slot())
+
+#define LOOKS_LIKE_GA(ga) (LOOKS_LIKE_TID((ga)->payload.gc.gtid) && \
+ LOOKS_LIKE_SLOT((ga)->payload.gc.slot))
+#else
+rtsBool looks_like_tid(StgInt tid);
+rtsBool looks_like_slot(StgInt slot);
+rtsBool looks_like_ga(globalAddr *ga);
+#define LOOKS_LIKE_TID(tid) looks_like_tid(tid)
+#define LOOKS_LIKE_GA(ga) looks_like_ga(ga)
+#endif /* 0 */
+
#endif /* PAR */
-//@node GranSim, , GUM, Parallel definitions
-//@subsection GranSim
+/*
+ * @node GranSim, , GUM, Parallel definitions
+ * @subsection GranSim
+ */
#if defined(GRAN)
/* ToDo: Check which of the PAR routines are needed in GranSim -- HWL */
-//@menu
-//* Types::
-//* Prototypes::
-//* Macros::
-//@end menu
-//*/
-
-//@node Types, Prototypes, GranSim, GranSim
-//@subsubsection Types
-
+/*
+ * @menu
+ * * Types::
+ * * Prototypes::
+ * * Macros::
+ * @end menu
+ *
+ * @node Types, Prototypes, GranSim, GranSim
+ * @subsubsection Types
+ */
+
+typedef StgWord *StgBuffer;
typedef struct rtsPackBuffer_ {
StgInt /* nat */ id;
StgInt /* nat */ size;
StgInt /* nat */ unpacked_size;
StgTSO *tso;
- StgClosure **buffer;
+ StgWord *buffer;
} rtsPackBuffer;
-//@node Prototypes, Macros, Types, GranSim
-//@subsubsection Prototypes
-
-
-/* main packing functions */
/*
-rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso, nat *packbuffersize);
-rtsPackBuffer *PackOneNode(StgClosure* closure, StgTSO* tso, nat *packbuffersize);
-void PrintPacket(rtsPackBuffer *buffer);
-StgClosure *UnpackGraph(rtsPackBuffer* buffer);
-*/
-/* important auxiliary functions */
-
-/*
-OLD CODE -- HWL
-void InitPackBuffer(void);
-P_ AllocateHeap (W_ size);
-P_ PackNearbyGraph (P_ closure, P_ tso, W_ *packbuffersize);
-P_ PackOneNode (P_ closure, P_ tso, W_ *packbuffersize);
-P_ UnpackGraph (P_ buffer);
-
-void InitClosureQueue (void);
-P_ DeQueueClosure(void);
-void QueueClosure (P_ closure);
-// rtsBool QueueEmpty();
-void PrintPacket (P_ buffer);
-*/
-
-// StgInfoTable *get_closure_info(StgClosure* node, unsigned int /* nat */ *size, unsigned int /* nat */ *ptrs, unsigned int /* nat */ *nonptrs, unsigned int /* nat */ *vhs, char *info_hdr_ty);
-// int /* rtsBool */ IS_BLACK_HOLE(StgClosure* node) ;
-
-//@node Macros, , Prototypes, GranSim
-//@subsubsection Macros
+ * @node Macros, , Prototypes, GranSim
+ * @subsubsection Macros
+ */
/* max no. of outstanding spark steals */
#define MAX_FISHES 1
# 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_FETCHME_SIZE (PACK_GA_SIZE + _HS)
# define PACK_HDR_SIZE 4 /* Words of header in a packet */
# define PACK_HEAP_REQUIRED \
#endif /* GRAN */
-//@node End of File, , Parallel definitions
-//@section End of File
+/*
+ * @node End of File, , Parallel definitions
+ * @section End of File
+ */
#endif /* defined(PAR) || defined(GRAN) whole file */