[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / includes / GranSim.lh
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1995
3 %
4 %************************************************************************
5 %*                                                                      *
6 \section{Macros and global declarations for GranSim}
7 %*                                                                      *
8 %************************************************************************
9
10 \begin{code}
11 #ifdef GRAN
12
13 #  define IS_IDLE(proc) ((IdleProcs & PE_NUMBER((long)proc)) != 0l)
14 #  define ANY_IDLE      (Idlers > 0)
15 #  define MAKE_IDLE(proc) do { if(!IS_IDLE(proc)) { ++Idlers; IdleProcs |= PE_NUMBER(proc);  } } while(0)
16 #  define MAKE_BUSY(proc) do { if(IS_IDLE(proc))  { --Idlers; IdleProcs &= ~PE_NUMBER(proc); } } while(0)
17
18 /* Event Types */
19 #  define STARTTHREAD     0     /* Start a newly created thread */
20 #  define CONTINUETHREAD  1     /* Continue running the first thread in the queue */
21 #  define RESUMETHREAD    2     /* Resume a previously running thread */
22 #  define MOVESPARK       3     /* Move a spark from one PE to another */
23 #  define MOVETHREAD      4     /* Move a thread from one PE to another */
24 #  define FINDWORK        5     /* Search for work */
25 #  define FETCHNODE       6     /* Fetch a node */
26 #  define FETCHREPLY      7     /* Receive a node */
27
28 #  define EVENT_PROC(evt)       (evt->proc)
29 #  define EVENT_CREATOR(evt)    (evt->creator)
30 #  define EVENT_TIME(evt)       (evt->time)
31 #  define EVENT_TYPE(evt)       (evt->evttype)
32 #  define EVENT_TSO(evt)        (evt->tso)
33 #  define EVENT_NODE(evt)       (evt->node)
34 #  define EVENT_SPARK(evt)      (evt->spark)
35 #  define EVENT_NEXT(evt)       (eventq)(evt->next)
36
37 #endif /* GRAN */
38
39 #if defined(GRAN) || defined(PAR)
40 void DumpGranEvent PROTO((enum gran_event_types name, P_ tso));
41 void DumpSparkGranEvent PROTO((enum gran_event_types name, W_ id));
42 void DumpGranEventAndNode PROTO((enum gran_event_types name, P_ tso, P_ node, PROC proc));
43 void DumpRawGranEvent PROTO((PROC pe, enum gran_event_types name, W_ id));
44 void DumpGranInfo PROTO((PROC pe, P_ tso, rtsBool mandatory_thread));
45 void grterminate PROTO((TIME v));
46
47 # ifdef GRAN
48 I_ SaveSparkRoots PROTO((I_));
49 I_ SaveEventRoots PROTO((I_));
50
51 I_ RestoreSparkRoots PROTO((I_));
52 I_ RestoreEventRoots PROTO((I_));
53
54 IF_RTS(int init_gr_simulation PROTO((int, char **, int, char **));)
55 IF_RTS(void end_gr_simulation(STG_NO_ARGS);)
56 # endif
57
58 # ifdef PAR
59 ullong msTime(STG_NO_ARGS);
60 #  define CURRENT_TIME msTime()
61
62 #  define CURRENT_PROC thisPE
63
64 # else  /* GRAN */
65
66 #  define CURRENT_TIME CurrentTime[CurrentProc]
67 #  define CURRENT_PROC CurrentProc
68 # endif
69
70 #endif
71 \end{code}