1 /* --------------------------------------------------------------------------
2 Time-stamp: <Wed Jan 12 2000 16:22:43 Stardate: [-30]4194.45 hwloidl>
3 $Id: ParallelRts.h,v 1.2 2000/01/13 14:34:09 hwloidl Exp $
5 Variables and functions specific to the parallel RTS (i.e. GUM or GranSim)
6 ----------------------------------------------------------------------- */
11 #if defined(GRAN) || defined(PAR)
14 //* Packing routines::
15 //* Spark handling routines::
17 //* Debugging routines::
18 //* Generating .gr profiles::
24 // Dummy def for NO_PRI if not in GranSim
28 //@node Packing routines, Spark handling routines
29 //@subsection Packing routines
33 extern nat tot_packets, tot_packet_size, tot_cuts, tot_thunks;
38 rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso,
40 rtsPackBuffer *PackOneNode(StgClosure* closure, StgTSO* tso,
42 rtsPackBuffer *PackTSO(StgTSO *tso, nat *packBufferSize);
43 rtsPackBuffer *PackStkO(StgPtr stko, nat *packBufferSize);
44 void PackFetchMe(StgClosure *closure);
47 StgClosure* UnpackGraph(rtsPackBuffer* buffer);
48 void InitPendingGABuffer(nat size);
51 StgClosure *convertToRBH(StgClosure *closure);
52 void convertFromRBH(StgClosure *closure);
54 /* General closure predicates */
56 {Parallel.h}Daq ngoqvam vIroQpu'
58 StgInfoTable *get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
59 rtsBool IS_BLACK_HOLE(StgClosure* node);
60 StgClosure *IS_INDIRECTION(StgClosure* node);
61 rtsBool IS_THUNK(StgClosure* closure);
67 rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso,
70 rtsPackBuffer *PackTSO(StgTSO *tso, nat *packBufferSize);
71 rtsPackBuffer *PackStkO(StgPtr stko, nat *packBufferSize);
72 void PackFetchMe(StgClosure *closure);
75 void CommonUp(StgClosure *src, StgClosure *dst);
76 StgClosure *UnpackGraph(rtsPackBuffer *buffer, globalAddr **gamap,
80 StgClosure *convertToRBH(StgClosure *closure);
81 void convertToFetchMe(StgRBH *rbh, globalAddr *ga);
83 /* General closure predicates */
85 {Parallel.h}Daq ngoqvam vIroQpu'
87 StgInfoTable *get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
88 rtsBool IS_BLACK_HOLE(StgClosure* node);
89 StgClosure *IS_INDIRECTION(StgClosure* node);
90 rtsBool IS_THUNK(StgClosure* closure);
95 /* this routine should be moved to a more general module; currently in Pack.c
96 StgInfoTable* get_closure_info(StgClosure* node,
97 nat *size, nat *ptrs, nat *nonptrs, nat *vhs,
100 void doGlobalGC(void);
102 //@node Spark handling routines, GC routines, Packing routines
103 //@subsection Spark handling routines
105 /* now in ../Sparks.c */
111 rtsSpark findLocalSpark(rtsBool forexport);
112 StgTSO* activateSpark (rtsSpark spark);
113 void disposeSpark(rtsSpark spark);
114 rtsBool add_to_spark_queue(StgClosure *closure, rtsBool required);
115 rtsBool initSparkPools (void);
117 nat spark_queue_len(nat pool);
118 void markSparkQueue(void);
119 void print_sparkq(void);
123 void findLocalSpark (rtsEvent *event,
124 rtsBool *found_res, rtsSparkQ *spark_res);
125 rtsBool activateSpark (rtsEvent *event, rtsSparkQ spark);
126 rtsSpark *newSpark (StgClosure *node, StgInt name, StgInt gran_info,
127 StgInt size_info, StgInt par_info, StgInt local);
128 void disposeSpark(rtsSpark *spark);
129 void disposeSparkQ(rtsSparkQ spark);
130 void add_to_spark_queue(rtsSpark *spark);
131 void print_spark(rtsSpark *spark);
132 nat spark_queue_len(PEs proc);
133 rtsSpark *delete_from_sparkq (rtsSpark *spark, PEs p, rtsBool dispose_too);
134 void markSparkQueue(void);
135 void print_sparkq(PEs proc);
136 void print_sparkq_stats(void);
141 //@node GC routines, Debugging routines, Spark handling routines
142 //@subsection GC routines
146 void freeRemoteGA(int pe, globalAddr *ga);
147 void sendFreeMessages(void);
150 void markLocalGAs(rtsBool full);
151 void RebuildGAtables(rtsBool full);
152 void RebuildLAGAtable(void);
155 //@node Debugging routines, Generating .gr profiles, GC routines
156 //@subsection Debugging routines
159 void printGA (globalAddr *ga);
160 void printGALA (GALA *gala);
161 void printLAGAtable(void);
164 //@node Generating .gr profiles, Common macros, Debugging routines
165 //@subsection Generating .gr profiles
167 #define STATS_FILENAME_MAXLEN 128
169 /* Where to write the log file */
171 //@cindex gr_filename
172 extern FILE *gr_file;
173 extern char gr_filename[STATS_FILENAME_MAXLEN];
175 //@cindex init_gr_simulation
176 //@cindex end_gr_simulation
177 void init_gr_simulation(int rts_argc, char *rts_argv[],
178 int prog_argc, char *prog_argv[]);
179 void end_gr_simulation(void);
181 //@node Common macros, Index, Generating .gr profiles
182 //@subsection Common macros
185 extracting specific info out of a closure; used in packing (GranSim, GUM)
187 //@cindex get_closure_info
188 static inline StgInfoTable*
189 get_closure_info(node, size, ptrs, nonptrs, vhs, info_hdr_ty)
191 nat *size, *ptrs, *nonptrs, *vhs;
196 info = get_itbl(node);
197 /* the switch shouldn't be necessary, really; just use default case */
198 switch (info->type) {
201 StgInfoTable *rip = REVERT_INFOPTR(info); // closure to revert to
202 *size = sizeW_fromITBL(rip);
203 *ptrs = (nat) (rip->layout.payload.ptrs);
204 *nonptrs = (nat) (rip->layout.payload.nptrs);
205 *vhs = (nat) 0; // unknown
207 info_hdr_type(node, info_hdr_ty);
209 strcpy(info_hdr_ty, "UNKNOWN");
211 return rip; // NB: we return the reverted info ptr for a RBH!!!!!!
215 *size = sizeW_fromITBL(info);
216 *ptrs = (nat) (info->layout.payload.ptrs);
217 *nonptrs = (nat) (info->layout.payload.nptrs);
218 *vhs = (nat) 0; // unknown
220 info_hdr_type(node, info_hdr_ty);
222 strcpy(info_hdr_ty, "UNKNOWN");
228 //@cindex IS_BLACK_HOLE
229 static inline rtsBool
230 IS_BLACK_HOLE(StgClosure* node)
233 switch (get_itbl(node)->type) {
243 //return ((info->type == BLACKHOLE || info->type == RBH) ? rtsTrue : rtsFalse);
246 //@cindex IS_INDIRECTION
247 static inline StgClosure *
248 IS_INDIRECTION(StgClosure* node)
251 info = get_itbl(node);
252 switch (info->type) {
256 case IND_OLDGEN_PERM:
258 /* relies on indirectee being at same place for all these closure types */
259 return (((StgInd*)node) -> indirectee);
266 static inline StgClosure *
267 UNWIND_IND (StgClosure *closure)
271 while ((next = IS_INDIRECTION((StgClosure *)closure)) != NULL)
274 ASSERT(next==(StgClosure *)NULL);
278 #endif /* defined(PAR) || defined(GRAN) */
280 #endif /* PARALLEL_RTS_H */
282 //@node Index, , Common macros
286 //* IS_BLACK_HOLE:: @cindex\s-+IS_BLACK_HOLE
287 //* IS_INDIRECTION:: @cindex\s-+IS_INDIRECTION
288 //* end_gr_simulation:: @cindex\s-+end_gr_simulation
289 //* get_closure_info:: @cindex\s-+get_closure_info
290 //* gr_file:: @cindex\s-+gr_file
291 //* gr_filename:: @cindex\s-+gr_filename
292 //* init_gr_simulation:: @cindex\s-+init_gr_simulation
293 //* unwindInd:: @cindex\s-+unwindInd