1 /* --------------------------------------------------------------------------
2 Time-stamp: <Tue Mar 06 2001 00:25:50 Stardate: [-30]6285.08 hwloidl>
4 Variables and functions specific to the parallel RTS (i.e. GUM or GranSim)
5 ----------------------------------------------------------------------- */
12 /* HWL HACK: compile time sanity checks; shouldn't be necessary at all */
13 #if defined(PAR) && defined(GRAN)
14 # error "Both PAR and GRAN defined"
18 /* Paranoia debugging: we add an end-of-buffer marker to every pack buffer
19 (only when sanity checking RTS is enabled, of course) */
20 #define DEBUG_HEADROOM 1
21 #define END_OF_BUFFER_MARKER 0x1111bbbb
22 #define GARBAGE_MARKER 0x1111eeee
24 #define DEBUG_HEADROOM 0
27 #if defined(GRAN) || defined(PAR)
32 extern nat tot_packets, tot_packet_size, tot_cuts, tot_thunks;
35 rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso,
36 nat *packBufferSize, GlobalTaskId dest);
37 rtsPackBuffer *PackOneNode(StgClosure* closure, StgTSO* tso,
39 rtsPackBuffer *PackTSO(StgTSO *tso, nat *packBufferSize);
40 rtsPackBuffer *PackStkO(StgPtr stko, nat *packBufferSize);
41 void PackFetchMe(StgClosure *closure);
44 StgClosure* UnpackGraph(rtsPackBuffer* buffer);
45 void InitPendingGABuffer(nat size);
48 StgClosure *convertToRBH(StgClosure *closure);
49 void convertFromRBH(StgClosure *closure);
52 rtsFetchReturnCode blockFetch(StgTSO* tso, PEs proc, StgClosure* bh);
53 void blockThread(StgTSO *tso);
60 /* global structure for collecting statistics */
61 typedef struct GlobalParStats_ {
62 /* GALA and LAGA table info */
63 nat tot_mark_GA, tot_rebuild_GA, tot_free_GA,
64 res_mark_GA, res_rebuild_GA, res_free_GA,
65 cnt_mark_GA, cnt_rebuild_GA, cnt_free_GA,
66 res_size_GA, tot_size_GA, local_alloc_GA, tot_global, tot_local;
68 /* time spent managing the GAs */
69 double time_mark_GA, time_rebuild_GA;
71 /* spark queue stats */
72 nat res_sp, tot_sp, cnt_sp, emp_sp;
73 // nat tot_sq_len, tot_sq_probes, tot_sparks;
74 /* thread queue stats */
75 nat res_tp, tot_tp, cnt_tp, emp_tp;
76 //nat tot_add_threads, tot_tq_len, non_end_add_threads;
78 /* packet statistics */
79 nat tot_packets, tot_packet_size, tot_thunks,
80 res_packet_size, res_thunks,
81 rec_packets, rec_packet_size, rec_thunks,
82 rec_res_packet_size, rec_res_thunks;
83 /* time spent packing stuff */
84 double time_pack, time_unpack;
87 nat tot_threads_created;
90 //nat pruned_sparks, withered_sparks;
91 nat tot_sparks_created, tot_sparks_ignored, tot_sparks_marked,
92 res_sparks_created, res_sparks_ignored, res_sparks_marked; // , sparks_created_on_PE[MAX_PROC];
95 /* scheduling stats */
96 nat tot_yields, tot_stackover, tot_heapover;
98 /* message statistics */
99 nat tot_fish_mess, tot_fetch_mess, tot_resume_mess, tot_schedule_mess;
100 nat rec_fish_mess, rec_fetch_mess, rec_resume_mess, rec_schedule_mess;
106 /* blocking queue statistics
107 rtsTime tot_bq_processing_time;
108 nat tot_bq_len, tot_bq_len_local, tot_awbq, tot_FMBQs;
111 /* specialised info on arrays (for GPH/Maple mainly) */
112 nat tot_arrs, tot_arr_size;
115 extern GlobalParStats globalParStats;
117 void globalParStat_exit(void);
120 rtsBool InitPackBuffer(void);
121 rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso,
122 nat *packBufferSize, GlobalTaskId dest);
125 void CommonUp(StgClosure *src, StgClosure *dst);
126 StgClosure *UnpackGraph(rtsPackBuffer *buffer, globalAddr **gamap,
130 StgClosure *convertToRBH(StgClosure *closure);
131 void convertToFetchMe(StgRBH *rbh, globalAddr *ga);
134 void blockFetch(StgBlockedFetch *bf, StgClosure *bh);
135 void blockThread(StgTSO *tso);
138 void GALAdeprecate(globalAddr *ga);
141 nat pending_fetches_len(void);
144 void initParallelSystem(void);
145 void shutdownParallelSystem(StgInt n);
146 void synchroniseSystem(void);
151 /* this routine should be moved to a more general module; currently in Pack.c
152 StgInfoTable* get_closure_info(StgClosure* node,
153 nat *size, nat *ptrs, nat *nonptrs, nat *vhs,
156 void doGlobalGC(void);
158 //@node GC routines, Debugging routines, Spark handling routines
159 //@subsection GC routines
163 void freeRemoteGA(int pe, globalAddr *ga);
164 void sendFreeMessages(void);
165 void markPendingFetches(rtsBool major_gc);
168 void markLocalGAs(rtsBool full);
169 void RebuildGAtables(rtsBool full);
170 void RebuildLAGAtable(void);
173 //@node Debugging routines, Generating .gr profiles, GC routines
174 //@subsection Debugging routines
177 void printGA (globalAddr *ga);
178 void printGALA (GALA *gala);
179 void printLAGAtable(void);
181 rtsBool isOnLiveIndTable(globalAddr *ga);
182 rtsBool isOnRemoteGATable(globalAddr *ga);
183 void checkFreeGALAList(void);
184 void checkFreeIndirectionsList(void);
187 //@node Generating .gr profiles, Index, Debugging routines
188 //@subsection Generating .gr profiles
190 #define STATS_FILENAME_MAXLEN 128
192 /* Where to write the log file */
194 //@cindex gr_filename
195 extern FILE *gr_file;
196 extern char gr_filename[STATS_FILENAME_MAXLEN];
198 //@cindex init_gr_stats
199 //@cindex init_gr_simulation
200 //@cindex end_gr_simulation
201 void init_gr_stats (void);
202 void init_gr_simulation(int rts_argc, char *rts_argv[],
203 int prog_argc, char *prog_argv[]);
204 void end_gr_simulation(void);
206 // TODO: move fcts in here (as static inline)
207 StgInfoTable* get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
208 rtsBool IS_BLACK_HOLE(StgClosure* node);
209 StgClosure *IS_INDIRECTION(StgClosure* node) ;
210 StgClosure *UNWIND_IND (StgClosure *closure);
213 #endif /* defined(PAR) || defined(GRAN) */
215 //@node Common macros, Index, Generating .gr profiles
216 //@subsection Common macros
218 #define LOOKS_LIKE_PTR(r) \
219 (LOOKS_LIKE_STATIC_CLOSURE(r) || \
220 ((HEAP_ALLOCED(r) && Bdescr((P_)r)->free != (void *)-1)))
222 /* see Sanity.c for this kind of test; doing this in these basic fcts
223 is paranoid (nuke it after debugging!)
226 /* pathetic version of the check whether p can be a closure */
227 #define LOOKS_LIKE_COOL_CLOSURE(p) 1
229 //LOOKS_LIKE_GHC_INFO(get_itbl(p))
231 /* Is it a static closure (i.e. in the data segment)? */ \
233 #define LOOKS_LIKE_COOL_CLOSURE(p) \
234 ((LOOKS_LIKE_STATIC(p)) ? \
236 : !closure_STATIC(p) && LOOKS_LIKE_PTR(p))
239 #endif /* PARALLEL_RTS_H */
241 //@node Index, , Index
245 //* IS_BLACK_HOLE:: @cindex\s-+IS_BLACK_HOLE
246 //* IS_INDIRECTION:: @cindex\s-+IS_INDIRECTION
247 //* end_gr_simulation:: @cindex\s-+end_gr_simulation
248 //* get_closure_info:: @cindex\s-+get_closure_info
249 //* gr_file:: @cindex\s-+gr_file
250 //* gr_filename:: @cindex\s-+gr_filename
251 //* init_gr_simulation:: @cindex\s-+init_gr_simulation
252 //* unwindInd:: @cindex\s-+unwindInd