[project @ 2001-03-21 15:33:47 by simonmar]
[ghc-hetmet.git] / ghc / rts / parallel / ParallelRts.h
1 /* --------------------------------------------------------------------------
2    Time-stamp: <Wed Mar 29 2000 19:10:29 Stardate: [-30]4578.78 hwloidl>
3    $Id: ParallelRts.h,v 1.3 2000/03/31 03:09:37 hwloidl Exp $
4
5    Variables and functions specific to the parallel RTS (i.e. GUM or GranSim)
6    ----------------------------------------------------------------------- */
7
8 #ifndef PARALLEL_RTS_H
9 #define PARALLEL_RTS_H
10
11 #if defined(GRAN) || defined(PAR)
12
13 #if defined(GRAN)
14
15 /* Statistics info */
16 extern nat tot_packets, tot_packet_size, tot_cuts, tot_thunks;
17
18 /* Pack.c */
19 rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso, 
20                                nat *packBufferSize);
21 rtsPackBuffer *PackOneNode(StgClosure* closure, StgTSO* tso, 
22                            nat *packBufferSize);
23 rtsPackBuffer *PackTSO(StgTSO *tso, nat *packBufferSize);
24 rtsPackBuffer *PackStkO(StgPtr stko, nat *packBufferSize);
25 void           PackFetchMe(StgClosure *closure);
26
27 /* Unpack.c */
28 StgClosure*    UnpackGraph(rtsPackBuffer* buffer);
29 void           InitPendingGABuffer(nat size); 
30
31 /* RBH.c */
32 StgClosure    *convertToRBH(StgClosure *closure);
33 void           convertFromRBH(StgClosure *closure);
34
35 /* HLComms.c */
36 rtsFetchReturnCode blockFetch(StgTSO* tso, PEs proc, StgClosure* bh);
37 void           blockThread(StgTSO *tso);
38
39 /* General closure predicates */
40 /*
41     {Parallel.h}Daq ngoqvam vIroQpu'
42
43 StgInfoTable *get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
44 rtsBool      IS_BLACK_HOLE(StgClosure* node);
45 StgClosure  *IS_INDIRECTION(StgClosure* node);
46 rtsBool      IS_THUNK(StgClosure* closure);
47 */
48
49 #endif
50 #if defined(PAR)
51
52 /* Pack.c */
53 rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso, 
54                                nat *packBufferSize); 
55
56 /* Unpack.c */
57 void           CommonUp(StgClosure *src, StgClosure *dst);
58 StgClosure    *UnpackGraph(rtsPackBuffer *buffer, globalAddr **gamap, 
59                            nat *nGAs);
60
61 /* RBH.c */
62 StgClosure    *convertToRBH(StgClosure *closure);
63 void           convertToFetchMe(StgRBH *rbh, globalAddr *ga);
64
65 /* HLComms.c */
66 void           blockFetch(StgBlockedFetch *bf, StgClosure *bh);
67 void           blockThread(StgTSO *tso);
68
69 /* Global.c */
70 void           GALAdeprecate(globalAddr *ga);
71
72 /* General closure predicates */
73 /* 
74   {Parallel.h}Daq ngoqvam vIroQpu'
75
76 StgInfoTable *get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
77 rtsBool      IS_BLACK_HOLE(StgClosure* node);
78 StgClosure  *IS_INDIRECTION(StgClosure* node);
79 rtsBool      IS_THUNK(StgClosure* closure);
80 */
81
82 #endif
83
84 /* this routine should be moved to a more general module; currently in Pack.c 
85 StgInfoTable* get_closure_info(StgClosure* node, 
86                                nat *size, nat *ptrs, nat *nonptrs, nat *vhs, 
87                                char *info_hdr_ty);
88 */
89 void doGlobalGC(void); 
90
91 //@node GC routines, Debugging routines, Spark handling routines
92 //@subsection GC routines
93
94 #if defined(PAR)
95 /* HLComms.c */
96 void      freeRemoteGA(int pe, globalAddr *ga);
97 void      sendFreeMessages(void);
98
99 /* Global.c */
100 void      markLocalGAs(rtsBool full);
101 void      RebuildGAtables(rtsBool full);
102 void      RebuildLAGAtable(void);
103 #endif
104
105 //@node Debugging routines, Generating .gr profiles, GC routines
106 //@subsection Debugging routines
107
108 #if defined(PAR)
109 void      printGA (globalAddr *ga);
110 void      printGALA (GALA *gala);
111 void      printLAGAtable(void);
112
113 rtsBool   isOnLiveIndTable(globalAddr *ga);
114 rtsBool   isOnRemoteGATable(globalAddr *ga);
115 void      checkFreeGALAList(void);
116 void      checkFreeIndirectionsList(void);
117 #endif
118
119 //@node Generating .gr profiles, Index, Debugging routines
120 //@subsection Generating .gr profiles
121
122 #define STATS_FILENAME_MAXLEN   128
123
124 /* Where to write the log file */
125 //@cindex gr_file
126 //@cindex gr_filename
127 extern FILE *gr_file;
128 extern char gr_filename[STATS_FILENAME_MAXLEN];
129
130 //@cindex init_gr_stats
131 //@cindex init_gr_simulation
132 //@cindex end_gr_simulation
133 void init_gr_stats (void);
134 void init_gr_simulation(int rts_argc, char *rts_argv[], 
135                         int prog_argc, char *prog_argv[]);
136 void end_gr_simulation(void);
137
138 // TODO: move fcts in here (as static inline)
139 StgInfoTable* get_closure_info(StgClosure* node, nat *size, nat *ptrs, nat *nonptrs, nat *vhs, char *info_hdr_ty);
140 rtsBool IS_BLACK_HOLE(StgClosure* node);
141 StgClosure *IS_INDIRECTION(StgClosure* node)          ;
142 StgClosure *UNWIND_IND (StgClosure *closure);
143
144
145 #endif /* defined(PAR) || defined(GRAN) */
146
147 //@node Common macros, Index, Generating .gr profiles
148 //@subsection Common macros
149
150 #define LOOKS_LIKE_PTR(r)    \
151         (LOOKS_LIKE_STATIC_CLOSURE(r) ||  \
152          ((HEAP_ALLOCED(r) && Bdescr((P_)r)->free != (void *)-1)))
153
154 /* see Sanity.c for this kind of test; doing this in these basic fcts
155    is paranoid (nuke it after debugging!)
156 */
157
158 /* pathetic version of the check whether p can be a closure */
159 #define LOOKS_LIKE_COOL_CLOSURE(p)  1
160
161 //LOOKS_LIKE_GHC_INFO(get_itbl(p))
162
163     /* Is it a static closure (i.e. in the data segment)? */ \
164     /*
165 #define LOOKS_LIKE_COOL_CLOSURE(p)  \
166     ((LOOKS_LIKE_STATIC(p)) ?                                   \
167         closure_STATIC(p)                               \
168       : !closure_STATIC(p) && LOOKS_LIKE_PTR(p))
169     */
170
171 #endif /* PARALLEL_RTS_H */
172
173 //@node Index,  , Index
174 //@subsection Index
175
176 //@index
177 //* IS_BLACK_HOLE::  @cindex\s-+IS_BLACK_HOLE
178 //* IS_INDIRECTION::  @cindex\s-+IS_INDIRECTION
179 //* end_gr_simulation::  @cindex\s-+end_gr_simulation
180 //* get_closure_info::  @cindex\s-+get_closure_info
181 //* gr_file::  @cindex\s-+gr_file
182 //* gr_filename::  @cindex\s-+gr_filename
183 //* init_gr_simulation::  @cindex\s-+init_gr_simulation
184 //* unwindInd::  @cindex\s-+unwindInd
185 //@end index