2 Time-stamp: <Fri Dec 10 1999 17:15:01 Stardate: [-30]4028.38 software>
4 Definitions for parallel machines.
6 This section contains definitions applicable only to programs compiled
7 to run on a parallel machine, i.e. on GUM. Some of these definitions
8 are also used when simulating parallel execution, i.e. on GranSim.
12 ToDo: Check the PAR specfic part of this file
13 Move stuff into Closures.h and ClosureMacros.h
14 Clean-up GRAN specific code
21 #if defined(PAR) || defined(GRAN) /* whole file */
23 //@node Parallel definitions, End of File
24 //@section Parallel definitions
27 //* Basic definitions::
32 //@node Basic definitions, GUM, Parallel definitions, Parallel definitions
33 //@subsection Basic definitions
35 /* SET_PAR_HDR and SET_STATIC_PAR_HDR now live in ClosureMacros.h */
37 /* Needed for dumping routines */
39 # define NODE_STR_LEN 20
40 # define TIME_STR_LEN 120
42 # define CURRENT_TIME msTime()
43 # define TIME_ON_PROC(p) msTime()
44 # define CURRENT_PROC thisPE
45 # define BINARY_STATS RtsFlags.ParFlags.ParStats.Binary
47 # define NODE_STR_LEN 20
48 # define TIME_STR_LEN 120
50 # define CURRENT_TIME CurrentTime[CurrentProc]
51 # define TIME_ON_PROC(p) CurrentTime[p]
52 # define CURRENT_PROC CurrentProc
53 # define BINARY_STATS RtsFlags.GranFlags.GranSimStats.Binary
57 # define MAX_PES 256 /* Maximum number of processors */
58 /* MAX_PES is enforced by SysMan, which does not
59 allow more than this many "processors".
60 This is important because PackGA [GlobAddr.lc]
61 **assumes** that a PE# can fit in 8+ bits.
64 # define SPARK_POOLS 2 /* no. of spark pools */
65 # define REQUIRED_POOL 0 /* idx of pool of mandatory sparks (concurrency) */
66 # define ADVISORY_POOL 1 /* idx of pool of advisory sparks (parallelism) */
75 //@node GUM, GranSim, Basic definitions, Parallel definitions
80 Symbolic constants for the packing code.
82 This constant defines how many words of data we can pack into a single
83 packet in the parallel (GUM) system.
94 //@node Types, Externs, GUM, GUM
95 //@subsubsection Types
97 /* Sparks and spark queues */
98 typedef StgClosure *rtsSpark;
99 typedef rtsSpark *rtsSparkQ;
101 typedef struct rtsPackBuffer_ {
103 StgInt /* nat */ size;
104 StgInt /* nat */ unpacked_size;
109 #define PACK_BUFFER_HDR_SIZE 4
111 //@node Externs, Prototypes, Types, GUM
112 //@subsubsection Externs
114 // extern rtsBool do_sp_profile;
116 extern globalAddr theGlobalFromGA, theGlobalToGA;
117 extern StgBlockedFetch *PendingFetches;
118 extern GlobalTaskId *allPEs;
120 extern rtsBool IAmMainThread, GlobalStopPending;
121 //extern rtsBool fishing;
122 extern rtsTime last_fish_arrived_at;
123 extern nat outstandingFishes;
124 extern GlobalTaskId SysManTask;
125 extern int seed; /* pseudo-random-number generator seed: */
126 /* Initialised in ParInit */
127 extern StgInt threadId; /* Number of Threads that have existed on a PE */
128 extern GlobalTaskId mytid;
130 extern GlobalTaskId *allPEs;
132 extern nat sparksIgnored, sparksCreated, threadsIgnored, threadsCreated;
133 extern nat advisory_thread_count;
135 extern rtsBool InGlobalGC; /* Are we in the midst of performing global GC */
137 static ullong startTime; /* start of comp; in RtsStartup.c */
139 /* the spark pools proper */
140 extern rtsSpark *pending_sparks_hd[]; /* ptr to start of a spark pool */
141 extern rtsSpark *pending_sparks_tl[]; /* ptr to end of a spark pool */
142 extern rtsSpark *pending_sparks_lim[];
143 extern rtsSpark *pending_sparks_base[];
144 extern nat spark_limit[];
146 extern rtsPackBuffer *PackBuffer; /* size: can be set via option */
147 extern rtsPackBuffer *buffer; /* HWL_ */
148 extern rtsPackBuffer *freeBuffer; /* HWL_ */
149 extern rtsPackBuffer *packBuffer; /* HWL_ */
150 extern rtsPackBuffer *gumPackBuffer;
155 extern GALA *freeGALAList;
156 extern GALA *freeIndirections;
157 extern GALA *liveIndirections;
158 extern GALA *liveRemoteGAs;
161 extern HashTable *taskIDtoPEtable;
162 extern HashTable *LAtoGALAtable;
163 extern HashTable *pGAtoGALAtable;
166 //@node Prototypes, Macros, Externs, GUM
167 //@subsubsection Prototypes
170 void initParallelSystem(void);
171 void SynchroniseSystem(void);
172 void par_exit(StgInt n);
174 PEs taskIDtoPE (GlobalTaskId gtid);
175 void registerTask (GlobalTaskId gtid);
176 globalAddr *LAGAlookup (StgClosure *addr);
177 StgClosure *GALAlookup (globalAddr *ga);
178 //static GALA *allocIndirection (StgPtr addr);
179 globalAddr *makeGlobal (StgClosure *addr, rtsBool preferred);
180 globalAddr *setRemoteGA (StgClosure *addr, globalAddr *ga, rtsBool preferred);
181 void splitWeight (globalAddr *to, globalAddr *from);
182 globalAddr *addWeight (globalAddr *ga);
183 void initGAtables (void);
184 void RebuildLAGAtable (void);
185 StgWord PackGA (StgWord pe, int slot);
187 //@node Macros, , Prototypes, GUM
188 //@subsubsection Macros
190 /* delay (in us) between dying fish returning and sending out a new fish */
191 #define FISH_DELAY 1000
192 /* max no. of outstanding spark steals */
195 // ToDo: check which of these is actually needed!
197 # define PACK_HEAP_REQUIRED ((RtsFlags.ParFlags.packBufferSize - PACK_HDR_SIZE) / (PACK_GA_SIZE + _FHS) * (MIN_UPD_SIZE + 2))
199 # define MAX_GAS (RtsFlags.ParFlags.packBufferSize / PACK_GA_SIZE)
202 # define PACK_GA_SIZE 3 /* Size of a packed GA in words */
203 /* Size of a packed fetch-me in words */
204 # define PACK_FETCHME_SIZE (PACK_GA_SIZE + FIXED_HS)
206 # define PACK_HDR_SIZE 1 /* Words of header in a packet */
208 # define PACK_PLC_SIZE 2 /* Size of a packed PLC in words */
211 Definitions relating to the entire parallel-only fixed-header field.
213 On GUM, the global addresses for each local closure are stored in a
214 separate hash table, rather then with the closure in the heap. We call
215 @getGA@ to look up the global address associated with a local closure (0
216 is returned for local closures that have no global address), and @setGA@
217 to store a new global address for a local closure which did not
218 previously have one. */
220 # define GA_HDR_SIZE 0
222 # define GA(closure) getGA(closure)
224 # define SET_GA(closure, ga) setGA(closure,ga)
225 # define SET_STATIC_GA(closure)
226 # define SET_GRAN_HDR(closure,pe)
227 # define SET_STATIC_PROCS(closure)
229 # define MAX_GA_WEIGHT 0 /* Treat as 2^n */
231 /* At the moment, there is no activity profiling for GUM. This may change. */
232 # define SET_TASK_ACTIVITY(act) /* nothing */
236 //@node GranSim, , GUM, Parallel definitions
237 //@subsection GranSim
240 /* ToDo: Check which of the PAR routines are needed in GranSim -- HWL */
249 //@node Types, Prototypes, GranSim, GranSim
250 //@subsubsection Types
252 typedef struct rtsPackBuffer_ {
254 StgInt /* nat */ size;
255 StgInt /* nat */ unpacked_size;
260 //@node Prototypes, Macros, Types, GranSim
261 //@subsubsection Prototypes
264 /* main packing functions */
266 rtsPackBuffer *PackNearbyGraph(StgClosure* closure, StgTSO* tso, nat *packbuffersize);
267 rtsPackBuffer *PackOneNode(StgClosure* closure, StgTSO* tso, nat *packbuffersize);
268 void PrintPacket(rtsPackBuffer *buffer);
269 StgClosure *UnpackGraph(rtsPackBuffer* buffer);
271 /* important auxiliary functions */
275 void InitPackBuffer(void);
276 P_ AllocateHeap (W_ size);
277 P_ PackNearbyGraph (P_ closure, P_ tso, W_ *packbuffersize);
278 P_ PackOneNode (P_ closure, P_ tso, W_ *packbuffersize);
279 P_ UnpackGraph (P_ buffer);
281 void InitClosureQueue (void);
282 P_ DeQueueClosure(void);
283 void QueueClosure (P_ closure);
284 // rtsBool QueueEmpty();
285 void PrintPacket (P_ buffer);
288 // 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);
289 // int /* rtsBool */ IS_BLACK_HOLE(StgClosure* node) ;
291 //@node Macros, , Prototypes, GranSim
292 //@subsubsection Macros
294 /* max no. of outstanding spark steals */
297 /* These are needed in the packing code to get the size of the packet
298 right. The closures itself are never built in GrAnSim. */
299 # define FETCHME_VHS IND_VHS
300 # define FETCHME_HS IND_HS
302 # define FETCHME_GA_LOCN FETCHME_HS
304 # define FETCHME_CLOSURE_SIZE(closure) IND_CLOSURE_SIZE(closure)
305 # define FETCHME_CLOSURE_NoPTRS(closure) 0L
306 # define FETCHME_CLOSURE_NoNONPTRS(closure) (IND_CLOSURE_SIZE(closure)-IND_VHS)
308 # define MAX_GAS (RtsFlags.GranFlags.packBufferSize / PACK_GA_SIZE)
309 # define PACK_GA_SIZE 3 /* Size of a packed GA in words */
310 /* Size of a packed fetch-me in words */
311 # define PACK_FETCHME_SIZE (PACK_GA_SIZE + FIXED_HS)
312 # define PACK_HDR_SIZE 4 /* Words of header in a packet */
314 # define PACK_HEAP_REQUIRED \
315 (RtsFlags.GranFlags.packBufferSize * sizeofW(StgClosure*) + \
316 2 * sizeofW(StgInt) + sizeofW(StgTSO*))
318 # define PACK_FLAG_LOCN 0
319 # define PACK_TSO_LOCN 1
320 # define PACK_UNPACKED_SIZE_LOCN 2
321 # define PACK_SIZE_LOCN 3
322 # define MAGIC_PACK_FLAG 0xfabc
324 # define GA_HDR_SIZE 1
326 # define PROCS_HDR_POSN PAR_HDR_POSN
327 # define PROCS_HDR_SIZE 1
329 /* Accessing components of the field */
330 # define PROCS(closure) ((closure)->header.gran.procs)
331 /* SET_PROCS is now SET_GRAN_HEADER in ClosureMacros.h. */
335 //@node End of File, , Parallel definitions
336 //@section End of File
338 #endif /* defined(PAR) || defined(GRAN) whole file */
340 #endif /* Parallel_H */