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 ************************************************************************/
15 #ifdef HAVE_SYS_TIME_H
23 #include "PEOpCodes.h"
24 #define safemalloc malloc
27 #define ANY_TASK (-1) /* receive messages from any task */
28 #define ANY_GLOBAL_TASK ANY_TASK
29 #define ANY_OPCODE (-1) /* receive any opcode */
30 #define ALL_GROUP (-1) /* wait for barrier from every group member */
34 #define MGRGROUP "MGR"
35 #define PECTLGROUP "PECTL"
40 #define sync(gp,op) do { broadcast(gp,op); pvm_barrier(gp,ALL_GROUP); } while(0)
41 #define broadcast(gp,op) do { pvm_initsend(PvmDataDefault); pvm_bcast(gp,op); } while(0)
42 #define checkComms(c,s) do {if((c)<0) { pvm_perror(s); EXIT(EXIT_FAILURE); }} while(0)
44 #define _my_gtid pvm_mytid()
45 #define GetPacket() pvm_recv(ANY_TASK,ANY_OPCODE)
46 #define PacketsWaiting() (pvm_probe(ANY_TASK,ANY_OPCODE) != 0)
48 #define HandleException(p) (*ExceptionHandler)(p)
49 #define _SetMyExceptionHandler(f) ExceptionHandler = f
51 #define SPARK_THREAD_DESCRIPTOR 1
52 #define GLOBAL_THREAD_DESCRIPTOR 2
54 #define _extract_jump_field(v) (v)
56 #define MAX_DATA_WORDS_IN_PACKET 1024
58 #define PutArg1(a) pvm_pklong(&(a),1,1)
59 #define PutArg2(a) pvm_pklong(&(a),1,1)
60 #define PutArgN(n,a) pvm_pklong(&(a),1,1)
61 #define PutArgs(b,n) pvm_pklong(b,n,1)
63 #define PutLit(l) { int a = l; PutArgN(?,a); }
65 #define GetArg1(a) pvm_upklong(&(a),1,1)
66 #define GetArg2(a) pvm_upklong(&(a),1,1)
67 #define GetArgN(n,a) pvm_upklong(&(a),1,1)
68 #define GetArgs(b,n) pvm_upklong(b,n,1)
70 void SendOp PROTO((OPCODE,GLOBAL_TASK_ID)),
71 SendOp1 PROTO((OPCODE,GLOBAL_TASK_ID,StgWord)),
72 SendOp2 PROTO((OPCODE,GLOBAL_TASK_ID,StgWord,StgWord)),
73 SendOpV PROTO((OPCODE,GLOBAL_TASK_ID,int,...)),
74 SendOpN PROTO((OPCODE,GLOBAL_TASK_ID,int,StgWord *)),
75 SendOpNV PROTO((OPCODE,GLOBAL_TASK_ID,int,StgWord*,int,...));
77 char *GetOpName PROTO((unsigned op));
78 void NullException(STG_NO_ARGS);
80 PACKET WaitForPEOp PROTO((OPCODE op, GLOBAL_TASK_ID who));
81 OPCODE Opcode PROTO((PACKET p));
82 GLOBAL_TASK_ID Sender_Task PROTO((PACKET p));
83 void get_opcode_and_sender PROTO((PACKET p, OPCODE *popcode, GLOBAL_TASK_ID *psender_id));
84 GLOBAL_TASK_ID *PEStartUp PROTO((unsigned nPEs));
85 void PEShutDown(STG_NO_ARGS);
87 extern void (*ExceptionHandler) PROTO((PACKET));
90 #endif /*defined __LLC_H */