1 /* --------------------------------------------------------------------------
2 Time-stamp: <Sun Mar 18 2001 21:23:50 Stardate: [-30]6349.45 hwloidl>
4 Low Level Communications Header (LLC.h)
6 Contains the definitions used by the Low-level Communications
7 module of the GUM Haskell runtime environment.
8 Based on the Graph for PVM implementation.
10 Phil Trinder, Glasgow University, 13th Dec 1994
11 Adapted for the 4.xx RTS
12 H-W. Loidl, Heriot-Watt, November 1999
13 ----------------------------------------------------------------------- */
20 //@node Low Level Communications Header, , ,
21 //@section Low Level Communications Header
25 //* Macros and Constants::
30 //@node Includes, Macros and Constants, Low Level Communications Header, Low Level Communications Header
31 //@subsection Includes
36 #include "PEOpCodes.h"
39 //@node Macros and Constants, PVM macros, Includes, Low Level Communications Header
40 //@subsection Macros and Constants
42 #define ANY_TASK (-1) /* receive messages from any task */
43 #define ANY_GLOBAL_TASK ANY_TASK
44 #define ANY_OPCODE (-1) /* receive any opcode */
45 #define ALL_GROUP (-1) /* wait for barrier from every group member */
49 #define MGRGROUP "MGR"
50 #define SYSGROUP "SYS"
55 //@node PVM macros, Externs, Macros and Constants, Low Level Communications Header
56 //@subsection PVM macros
58 #define sync(gp,op) do { \
60 pvm_barrier(gp,ALL_GROUP); \
63 #define broadcast(gp,op) do { \
64 pvm_initsend(PvmDataDefault); \
68 #define checkComms(c,s) do { \
71 stg_exit(EXIT_FAILURE); \
74 #define _my_gtid pvm_mytid()
75 #define GetPacket() pvm_recv(ANY_TASK,ANY_OPCODE)
76 #define PacketsWaiting() (pvm_probe(ANY_TASK,ANY_OPCODE) != 0)
78 #define SPARK_THREAD_DESCRIPTOR 1
79 #define GLOBAL_THREAD_DESCRIPTOR 2
81 #define _extract_jump_field(v) (v)
83 #define MAX_DATA_WORDS_IN_PACKET 1024
85 /* basic PVM packing */
86 #define PutArg1(a) pvm_pklong((long *)&(a),1,1)
87 #define PutArg2(a) pvm_pklong((long *)&(a),1,1)
88 #define PutArgN(n,a) pvm_pklong((long *)&(a),1,1)
89 #define PutArgs(b,n) pvm_pklong((long *)b,n,1)
91 #define PutLit(l) { int a = l; PutArgN(?,a); }
93 /* basic PVM unpacking */
94 #define GetArg1(a) pvm_upklong((long *)&(a),1,1)
95 #define GetArg2(a) pvm_upklong((long *)&(a),1,1)
96 #define GetArgN(n,a) pvm_upklong((long *)&(a),1,1)
97 #define GetArgs(b,n) pvm_upklong((long *)b,n,1)
99 //@node Externs, , PVM macros, Low Level Communications Header
100 //@subsection Externs
102 /* basic message passing routines */
103 extern void sendOp (OpCode,GlobalTaskId),
104 sendOp1 (OpCode,GlobalTaskId,StgWord),
105 sendOp2 (OpCode,GlobalTaskId,StgWord,StgWord),
106 sendOpV (OpCode,GlobalTaskId,int,...),
107 sendOpN (OpCode,GlobalTaskId,int,StgPtr),
108 sendOpNV (OpCode,GlobalTaskId,int,StgPtr,int,...);
110 extern void broadcastOpN(OpCode op, char *group, int n, StgPtr args);
112 /* extracting data out of a packet */
113 OpCode getOpcode (rtsPacket p);
114 void getOpcodeAndSender (rtsPacket p, OpCode *popcode,
115 GlobalTaskId *psender_id);
116 GlobalTaskId senderTask (rtsPacket p);
117 rtsPacket waitForPEOp(OpCode op, GlobalTaskId who, void(*processUnexpected)(rtsPacket) );
119 /* Init and shutdown routines */
120 void startUpPE (void);
121 void shutDownPE(void);
122 int getExitCode(int nbytes, GlobalTaskId *sender_idp);
125 char *getOpName (unsigned op); // returns string of opcode
126 void processUnexpectedMessage (rtsPacket);
127 //void NullException(void);
130 #endif /*defined __LLC_H */