summaryrefslogtreecommitdiff
path: root/ghc/includes/GranSim.lh
blob: eea0b2473aae91b7c41c259bba63db9edafe2507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
%
% (c) The GRASP/AQUA Project, Glasgow University, 1995
%
%************************************************************************
%*									*
\section{Macros and global declarations for GranSim}
%*									*
%************************************************************************

\begin{code}
#ifdef GRAN

#  define IS_IDLE(proc)	((IdleProcs & PE_NUMBER((long)proc)) != 0l)
#  define ANY_IDLE	(Idlers > 0)
#  define MAKE_IDLE(proc) do { if(!IS_IDLE(proc)) { ++Idlers; IdleProcs |= PE_NUMBER(proc);  } } while(0)
#  define MAKE_BUSY(proc) do { if(IS_IDLE(proc))  { --Idlers; IdleProcs &= ~PE_NUMBER(proc); } } while(0)

/* Event Types */
#  define STARTTHREAD     0	/* Start a newly created thread */
#  define CONTINUETHREAD  1     /* Continue running the first thread in the queue */
#  define RESUMETHREAD    2     /* Resume a previously running thread */
#  define MOVESPARK       3     /* Move a spark from one PE to another */
#  define MOVETHREAD      4     /* Move a thread from one PE to another */
#  define FINDWORK        5     /* Search for work */
#  define FETCHNODE       6     /* Fetch a node */
#  define FETCHREPLY      7     /* Receive a node */

#  define EVENT_PROC(evt)	(evt->proc)
#  define EVENT_CREATOR(evt)	(evt->creator)
#  define EVENT_TIME(evt)	(evt->time)
#  define EVENT_TYPE(evt)	(evt->evttype)
#  define EVENT_TSO(evt)	(evt->tso)
#  define EVENT_NODE(evt)	(evt->node)
#  define EVENT_SPARK(evt)	(evt->spark)
#  define EVENT_NEXT(evt)	(eventq)(evt->next)

#endif /* GRAN */

#if defined(GRAN) || defined(PAR)
void DumpGranEvent PROTO((enum gran_event_types name, P_ tso));
void DumpSparkGranEvent PROTO((enum gran_event_types name, W_ id));
void DumpGranEventAndNode PROTO((enum gran_event_types name, P_ tso, P_ node, PROC proc));
void DumpRawGranEvent PROTO((PROC pe, enum gran_event_types name, W_ id));
void DumpGranInfo PROTO((PROC pe, P_ tso, rtsBool mandatory_thread));
void grterminate PROTO((TIME v));

# ifdef GRAN
I_ SaveSparkRoots PROTO((I_));
I_ SaveEventRoots PROTO((I_));

I_ RestoreSparkRoots PROTO((I_));
I_ RestoreEventRoots PROTO((I_));

IF_RTS(int init_gr_simulation PROTO((int, char **, int, char **));)
IF_RTS(void end_gr_simulation(STG_NO_ARGS);)
# endif

# ifdef PAR
ullong msTime(STG_NO_ARGS);
#  define CURRENT_TIME msTime()

#  define CURRENT_PROC thisPE

# else	/* GRAN */

#  define CURRENT_TIME CurrentTime[CurrentProc]
#  define CURRENT_PROC CurrentProc
# endif

#endif
\end{code}