1 /* --------------------------------------------------------------------------
2 Time-stamp: <Sun Mar 18 2001 21:23:50 Stardate: [-30]6349.45 hwloidl>
3 $Id: LLC.h,v 1.4 2001/03/22 03:51:11 hwloidl Exp $
5 Low Level Communications Header (LLC.h)
7 Contains the definitions used by the Low-level Communications
8 module of the GUM Haskell runtime environment.
9 Based on the Graph for PVM implementation.
11 Phil Trinder, Glasgow University, 13th Dec 1994
12 Adapted for the 4.xx RTS
13 H-W. Loidl, Heriot-Watt, November 1999
14 ----------------------------------------------------------------------- */
21 //@node Low Level Communications Header, , ,
22 //@section Low Level Communications Header
26 //* Macros and Constants::
31 //@node Includes, Macros and Constants, Low Level Communications Header, Low Level Communications Header
32 //@subsection Includes
37 #include "PEOpCodes.h"
40 //@node Macros and Constants, PVM macros, Includes, Low Level Communications Header
41 //@subsection Macros and Constants
43 #define ANY_TASK (-1) /* receive messages from any task */
44 #define ANY_GLOBAL_TASK ANY_TASK
45 #define ANY_OPCODE (-1) /* receive any opcode */
46 #define ALL_GROUP (-1) /* wait for barrier from every group member */
50 #define MGRGROUP "MGR"
51 #define SYSGROUP "SYS"
56 //@node PVM macros, Externs, Macros and Constants, Low Level Communications Header
57 //@subsection PVM macros
59 #define sync(gp,op) do { \
61 pvm_barrier(gp,ALL_GROUP); \
64 #define broadcast(gp,op) do { \
65 pvm_initsend(PvmDataDefault); \
69 #define checkComms(c,s) do { \
72 stg_exit(EXIT_FAILURE); \
75 #define _my_gtid pvm_mytid()
76 #define GetPacket() pvm_recv(ANY_TASK,ANY_OPCODE)
77 #define PacketsWaiting() (pvm_probe(ANY_TASK,ANY_OPCODE) != 0)
79 #define SPARK_THREAD_DESCRIPTOR 1
80 #define GLOBAL_THREAD_DESCRIPTOR 2
82 #define _extract_jump_field(v) (v)
84 #define MAX_DATA_WORDS_IN_PACKET 1024
86 /* basic PVM packing */
87 #define PutArg1(a) pvm_pklong((long *)&(a),1,1)
88 #define PutArg2(a) pvm_pklong((long *)&(a),1,1)
89 #define PutArgN(n,a) pvm_pklong((long *)&(a),1,1)
90 #define PutArgs(b,n) pvm_pklong((long *)b,n,1)
92 #define PutLit(l) { int a = l; PutArgN(?,a); }
94 /* basic PVM unpacking */
95 #define GetArg1(a) pvm_upklong((long *)&(a),1,1)
96 #define GetArg2(a) pvm_upklong((long *)&(a),1,1)
97 #define GetArgN(n,a) pvm_upklong((long *)&(a),1,1)
98 #define GetArgs(b,n) pvm_upklong((long *)b,n,1)
100 //@node Externs, , PVM macros, Low Level Communications Header
101 //@subsection Externs
103 /* basic message passing routines */
104 extern void sendOp (OpCode,GlobalTaskId),
105 sendOp1 (OpCode,GlobalTaskId,StgWord),
106 sendOp2 (OpCode,GlobalTaskId,StgWord,StgWord),
107 sendOpV (OpCode,GlobalTaskId,int,...),
108 sendOpN (OpCode,GlobalTaskId,int,StgPtr),
109 sendOpNV (OpCode,GlobalTaskId,int,StgPtr,int,...);
111 extern void broadcastOpN(OpCode op, char *group, int n, StgPtr args);
113 /* extracting data out of a packet */
114 OpCode getOpcode (rtsPacket p);
115 void getOpcodeAndSender (rtsPacket p, OpCode *popcode,
116 GlobalTaskId *psender_id);
117 GlobalTaskId senderTask (rtsPacket p);
118 rtsPacket waitForPEOp(OpCode op, GlobalTaskId who, void(*processUnexpected)(rtsPacket) );
120 /* Init and shutdown routines */
121 void startUpPE (void);
122 void shutDownPE(void);
123 int getExitCode(int nbytes, GlobalTaskId *sender_idp);
126 char *getOpName (unsigned op); // returns string of opcode
127 void processUnexpectedMessage (rtsPacket);
128 //void NullException(void);
131 #endif /*defined __LLC_H */