1 /***********************************************************************
2 * Low Level Communications Header (LLC.h) *
3 * Contains the definitions used by the Low-level Communications *
4 * module of the GUM Haskell runtime environment. *
5 * Based on the Graph for PVM implementation. *
6 * Phil Trinder, Glasgow University, 13th Dec 1994 *
7 ************************************************************************/
16 #include "PEOpCodes.h"
19 #define ANY_TASK (-1) /* receive messages from any task */
20 #define ANY_GLOBAL_TASK ANY_TASK
21 #define ANY_OPCODE (-1) /* receive any opcode */
22 #define ALL_GROUP (-1) /* wait for barrier from every group member */
26 #define MGRGROUP "MGR"
27 #define PECTLGROUP "PECTL"
32 #define sync(gp,op) do { broadcast(gp,op); pvm_barrier(gp,ALL_GROUP); } while(0)
33 #define broadcast(gp,op) do { pvm_initsend(PvmDataDefault); pvm_bcast(gp,op); } while(0)
34 #define checkComms(c,s) do {if((c)<0) { pvm_perror(s); stg_exit(EXIT_FAILURE); }} while(0)
36 #define _my_gtid pvm_mytid()
37 #define GetPacket() pvm_recv(ANY_TASK,ANY_OPCODE)
38 #define PacketsWaiting() (pvm_probe(ANY_TASK,ANY_OPCODE) != 0)
40 #define SPARK_THREAD_DESCRIPTOR 1
41 #define GLOBAL_THREAD_DESCRIPTOR 2
43 #define _extract_jump_field(v) (v)
45 #define MAX_DATA_WORDS_IN_PACKET 1024
47 #define PutArg1(a) pvm_pklong(&(a),1,1)
48 #define PutArg2(a) pvm_pklong(&(a),1,1)
49 #define PutArgN(n,a) pvm_pklong(&(a),1,1)
50 #define PutArgs(b,n) pvm_pklong(b,n,1)
52 #define PutLit(l) { int a = l; PutArgN(?,a); }
54 #define GetArg1(a) pvm_upklong(&(a),1,1)
55 #define GetArg2(a) pvm_upklong(&(a),1,1)
56 #define GetArgN(n,a) pvm_upklong(&(a),1,1)
57 #define GetArgs(b,n) pvm_upklong(b,n,1)
59 extern void SendOp (OPCODE,GLOBAL_TASK_ID),
60 SendOp1 (OPCODE,GLOBAL_TASK_ID,StgWord),
61 SendOp2 (OPCODE,GLOBAL_TASK_ID,StgWord,StgWord),
62 SendOpV (OPCODE,GLOBAL_TASK_ID,int,...),
63 SendOpN (OPCODE,GLOBAL_TASK_ID,int,StgPtr),
64 SendOpNV (OPCODE,GLOBAL_TASK_ID,int,StgPtr,int,...);
66 char *GetOpName (unsigned op);
67 void NullException(void);
69 PACKET WaitForPEOp (OPCODE op, GLOBAL_TASK_ID who);
70 OPCODE Opcode (PACKET p);
71 GLOBAL_TASK_ID Sender_Task (PACKET p);
72 void get_opcode_and_sender (PACKET p, OPCODE *popcode, GLOBAL_TASK_ID *psender_id);
73 GLOBAL_TASK_ID *PEStartUp (unsigned nPEs);
74 void PEShutDown(void);
75 void ProcessUnexpected (PACKET);
78 #endif /*defined __LLC_H */