/* --------------------------------------------------------------------------
- Time-stamp: <Wed Jan 12 2000 16:22:43 Stardate: [-30]4194.45 hwloidl>
- $Id: ParallelRts.h,v 1.2 2000/01/13 14:34:09 hwloidl Exp $
+ Time-stamp: <Tue Mar 06 2001 00:25:50 Stardate: [-30]6285.08 hwloidl>
+ $Id: ParallelRts.h,v 1.4 2001/03/22 03:51:12 hwloidl Exp $
Variables and functions specific to the parallel RTS (i.e. GUM or GranSim)
----------------------------------------------------------------------- */
#ifndef PARALLEL_RTS_H
#define PARALLEL_RTS_H
-#if defined(GRAN) || defined(PAR)
+#include "ParTicky.h"
-//@menu
-//* Packing routines::
-//* Spark handling routines::
-//* GC routines::
-//* Debugging routines::
-//* Generating .gr profiles::
-//* Common macros::
-//* Index::
-//@end menu
-
-#ifndef GRAN
-// Dummy def for NO_PRI if not in GranSim
-#define NO_PRI 0
+/* HWL HACK: compile time sanity checks; shouldn't be necessary at all */
+#if defined(PAR) && defined(GRAN)
+# error "Both PAR and GRAN defined"
#endif
-//@node Packing routines, Spark handling routines
-//@subsection Packing routines
+#if defined(DEBUG)
+/* Paranoia debugging: we add an end-of-buffer marker to every pack buffer
+ (only when sanity checking RTS is enabled, of course) */
+#define DEBUG_HEADROOM 1
+#define END_OF_BUFFER_MARKER 0x1111bbbb
+#define GARBAGE_MARKER 0x1111eeee
+#else
+#define DEBUG_HEADROOM 0
+#endif /* DEBUG */
+
+#if defined(GRAN) || defined(PAR)
#if defined(GRAN)
+
/* Statistics info */
extern nat tot_packets, tot_packet_size, tot_cuts, tot_thunks;
-#endif
-#if defined(GRAN)
/* Pack.c */
rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso,
- nat *packBufferSize);
+ nat *packBufferSize, GlobalTaskId dest);
rtsPackBuffer *PackOneNode(StgClosure* closure, StgTSO* tso,
nat *packBufferSize);
rtsPackBuffer *PackTSO(StgTSO *tso, nat *packBufferSize);
StgClosure *convertToRBH(StgClosure *closure);
void convertFromRBH(StgClosure *closure);
-/* General closure predicates */
-/*
- {Parallel.h}Daq ngoqvam vIroQpu'
+/* HLComms.c */
+rtsFetchReturnCode blockFetch(StgTSO* tso, PEs proc, StgClosure* bh);
+void blockThread(StgTSO *tso);
-StgInfoTable *get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
-rtsBool IS_BLACK_HOLE(StgClosure* node);
-StgClosure *IS_INDIRECTION(StgClosure* node);
-rtsBool IS_THUNK(StgClosure* closure);
-*/
+#endif
+#if defined(PAR)
-#elif defined(PAR)
+/* Statistics info */
+
+/* global structure for collecting statistics */
+typedef struct GlobalParStats_ {
+ /* GALA and LAGA table info */
+ nat tot_mark_GA, tot_rebuild_GA, tot_free_GA,
+ res_mark_GA, res_rebuild_GA, res_free_GA,
+ cnt_mark_GA, cnt_rebuild_GA, cnt_free_GA,
+ res_size_GA, tot_size_GA, local_alloc_GA, tot_global, tot_local;
+
+ /* time spent managing the GAs */
+ double time_mark_GA, time_rebuild_GA;
+
+ /* spark queue stats */
+ nat res_sp, tot_sp, cnt_sp, emp_sp;
+ // nat tot_sq_len, tot_sq_probes, tot_sparks;
+ /* thread queue stats */
+ nat res_tp, tot_tp, cnt_tp, emp_tp;
+ //nat tot_add_threads, tot_tq_len, non_end_add_threads;
+
+ /* packet statistics */
+ nat tot_packets, tot_packet_size, tot_thunks,
+ res_packet_size, res_thunks,
+ rec_packets, rec_packet_size, rec_thunks,
+ rec_res_packet_size, rec_res_thunks;
+ /* time spent packing stuff */
+ double time_pack, time_unpack;
+
+ /* thread stats */
+ nat tot_threads_created;
+
+ /* spark stats */
+ //nat pruned_sparks, withered_sparks;
+ nat tot_sparks_created, tot_sparks_ignored, tot_sparks_marked,
+ res_sparks_created, res_sparks_ignored, res_sparks_marked; // , sparks_created_on_PE[MAX_PROC];
+ double time_sparks;
+
+ /* scheduling stats */
+ nat tot_yields, tot_stackover, tot_heapover;
+
+ /* message statistics */
+ nat tot_fish_mess, tot_fetch_mess, tot_resume_mess, tot_schedule_mess;
+ nat rec_fish_mess, rec_fetch_mess, rec_resume_mess, rec_schedule_mess;
+#if defined(DIST)
+ nat tot_reval_mess;
+ nat rec_reval_mess;
+#endif
+
+ /* blocking queue statistics
+ rtsTime tot_bq_processing_time;
+ nat tot_bq_len, tot_bq_len_local, tot_awbq, tot_FMBQs;
+ */
+
+ /* specialised info on arrays (for GPH/Maple mainly) */
+ nat tot_arrs, tot_arr_size;
+} GlobalParStats;
+
+extern GlobalParStats globalParStats;
+
+void globalParStat_exit(void);
/* Pack.c */
+rtsBool InitPackBuffer(void);
rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso,
- nat *packBufferSize);
-
-rtsPackBuffer *PackTSO(StgTSO *tso, nat *packBufferSize);
-rtsPackBuffer *PackStkO(StgPtr stko, nat *packBufferSize);
-void PackFetchMe(StgClosure *closure);
+ nat *packBufferSize, GlobalTaskId dest);
/* Unpack.c */
void CommonUp(StgClosure *src, StgClosure *dst);
StgClosure *convertToRBH(StgClosure *closure);
void convertToFetchMe(StgRBH *rbh, globalAddr *ga);
-/* General closure predicates */
-/*
- {Parallel.h}Daq ngoqvam vIroQpu'
+/* HLComms.c */
+void blockFetch(StgBlockedFetch *bf, StgClosure *bh);
+void blockThread(StgTSO *tso);
-StgInfoTable *get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
-rtsBool IS_BLACK_HOLE(StgClosure* node);
-StgClosure *IS_INDIRECTION(StgClosure* node);
-rtsBool IS_THUNK(StgClosure* closure);
-*/
+/* Global.c */
+void GALAdeprecate(globalAddr *ga);
+
+/* HLComms.c */
+nat pending_fetches_len(void);
+
+/* ParInit.c */
+void initParallelSystem(void);
+void shutdownParallelSystem(StgInt n);
+void synchroniseSystem(void);
+void par_exit(I_);
#endif
*/
void doGlobalGC(void);
-//@node Spark handling routines, GC routines, Packing routines
-//@subsection Spark handling routines
-
-/* now in ../Sparks.c */
-
-#if 0
-
-#if defined(PAR)
-
-rtsSpark findLocalSpark(rtsBool forexport);
-StgTSO* activateSpark (rtsSpark spark);
-void disposeSpark(rtsSpark spark);
-rtsBool add_to_spark_queue(StgClosure *closure, rtsBool required);
-rtsBool initSparkPools (void);
-
-nat spark_queue_len(nat pool);
-void markSparkQueue(void);
-void print_sparkq(void);
-
-#elif defined(GRAN)
-
-void findLocalSpark (rtsEvent *event,
- rtsBool *found_res, rtsSparkQ *spark_res);
-rtsBool activateSpark (rtsEvent *event, rtsSparkQ spark);
-rtsSpark *newSpark (StgClosure *node, StgInt name, StgInt gran_info,
- StgInt size_info, StgInt par_info, StgInt local);
-void disposeSpark(rtsSpark *spark);
-void disposeSparkQ(rtsSparkQ spark);
-void add_to_spark_queue(rtsSpark *spark);
-void print_spark(rtsSpark *spark);
-nat spark_queue_len(PEs proc);
-rtsSpark *delete_from_sparkq (rtsSpark *spark, PEs p, rtsBool dispose_too);
-void markSparkQueue(void);
-void print_sparkq(PEs proc);
-void print_sparkq_stats(void);
-
-#endif
-#endif /* 0 */
-
//@node GC routines, Debugging routines, Spark handling routines
//@subsection GC routines
/* HLComms.c */
void freeRemoteGA(int pe, globalAddr *ga);
void sendFreeMessages(void);
+void markPendingFetches(rtsBool major_gc);
/* Global.c */
void markLocalGAs(rtsBool full);
void printGA (globalAddr *ga);
void printGALA (GALA *gala);
void printLAGAtable(void);
+
+rtsBool isOnLiveIndTable(globalAddr *ga);
+rtsBool isOnRemoteGATable(globalAddr *ga);
+void checkFreeGALAList(void);
+void checkFreeIndirectionsList(void);
#endif
-//@node Generating .gr profiles, Common macros, Debugging routines
+//@node Generating .gr profiles, Index, Debugging routines
//@subsection Generating .gr profiles
#define STATS_FILENAME_MAXLEN 128
extern FILE *gr_file;
extern char gr_filename[STATS_FILENAME_MAXLEN];
+//@cindex init_gr_stats
//@cindex init_gr_simulation
//@cindex end_gr_simulation
-void init_gr_simulation(int rts_argc, char *rts_argv[],
- int prog_argc, char *prog_argv[]);
-void end_gr_simulation(void);
+void init_gr_stats (void);
+void init_gr_simulation(int rts_argc, char *rts_argv[],
+ int prog_argc, char *prog_argv[]);
+void end_gr_simulation(void);
+
+// TODO: move fcts in here (as static inline)
+StgInfoTable* get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
+rtsBool IS_BLACK_HOLE(StgClosure* node);
+StgClosure *IS_INDIRECTION(StgClosure* node) ;
+StgClosure *UNWIND_IND (StgClosure *closure);
+
+
+#endif /* defined(PAR) || defined(GRAN) */
//@node Common macros, Index, Generating .gr profiles
//@subsection Common macros
-/*
- extracting specific info out of a closure; used in packing (GranSim, GUM)
+#define LOOKS_LIKE_PTR(r) \
+ (LOOKS_LIKE_STATIC_CLOSURE(r) || \
+ ((HEAP_ALLOCED(r) && Bdescr((P_)r)->free != (void *)-1)))
+
+/* see Sanity.c for this kind of test; doing this in these basic fcts
+ is paranoid (nuke it after debugging!)
*/
-//@cindex get_closure_info
-static inline StgInfoTable*
-get_closure_info(node, size, ptrs, nonptrs, vhs, info_hdr_ty)
-StgClosure* node;
-nat *size, *ptrs, *nonptrs, *vhs;
-char *info_hdr_ty;
-{
- StgInfoTable *info;
-
- info = get_itbl(node);
- /* the switch shouldn't be necessary, really; just use default case */
- switch (info->type) {
- case RBH:
- {
- StgInfoTable *rip = REVERT_INFOPTR(info); // closure to revert to
- *size = sizeW_fromITBL(rip);
- *ptrs = (nat) (rip->layout.payload.ptrs);
- *nonptrs = (nat) (rip->layout.payload.nptrs);
- *vhs = (nat) 0; // unknown
-#if 0 /* DEBUG */
- info_hdr_type(node, info_hdr_ty);
-#else
- strcpy(info_hdr_ty, "UNKNOWN");
-#endif
- return rip; // NB: we return the reverted info ptr for a RBH!!!!!!
- }
-
- default:
- *size = sizeW_fromITBL(info);
- *ptrs = (nat) (info->layout.payload.ptrs);
- *nonptrs = (nat) (info->layout.payload.nptrs);
- *vhs = (nat) 0; // unknown
-#if 0 /* DEBUG */
- info_hdr_type(node, info_hdr_ty);
-#else
- strcpy(info_hdr_ty, "UNKNOWN");
-#endif
- return info;
- }
-}
-
-//@cindex IS_BLACK_HOLE
-static inline rtsBool
-IS_BLACK_HOLE(StgClosure* node)
-{
- StgInfoTable *info;
- switch (get_itbl(node)->type) {
- case BLACKHOLE:
- case BLACKHOLE_BQ:
- case RBH:
- case FETCH_ME:
- case FETCH_ME_BQ:
- return rtsTrue;
- default:
- return rtsFalse;
- }
-//return ((info->type == BLACKHOLE || info->type == RBH) ? rtsTrue : rtsFalse);
-}
-
-//@cindex IS_INDIRECTION
-static inline StgClosure *
-IS_INDIRECTION(StgClosure* node)
-{
- StgInfoTable *info;
- info = get_itbl(node);
- switch (info->type) {
- case IND:
- case IND_OLDGEN:
- case IND_PERM:
- case IND_OLDGEN_PERM:
- case IND_STATIC:
- /* relies on indirectee being at same place for all these closure types */
- return (((StgInd*)node) -> indirectee);
- default:
- return NULL;
- }
-}
-
-//@cindex unwindInd
-static inline StgClosure *
-UNWIND_IND (StgClosure *closure)
-{
- StgClosure *next;
-
- while ((next = IS_INDIRECTION((StgClosure *)closure)) != NULL)
- closure = next;
-
- ASSERT(next==(StgClosure *)NULL);
- return closure;
-}
-#endif /* defined(PAR) || defined(GRAN) */
+/* pathetic version of the check whether p can be a closure */
+#define LOOKS_LIKE_COOL_CLOSURE(p) 1
+
+//LOOKS_LIKE_GHC_INFO(get_itbl(p))
+
+ /* Is it a static closure (i.e. in the data segment)? */ \
+ /*
+#define LOOKS_LIKE_COOL_CLOSURE(p) \
+ ((LOOKS_LIKE_STATIC(p)) ? \
+ closure_STATIC(p) \
+ : !closure_STATIC(p) && LOOKS_LIKE_PTR(p))
+ */
#endif /* PARALLEL_RTS_H */
-//@node Index, , Common macros
+//@node Index, , Index
//@subsection Index
//@index