[project @ 1996-07-25 20:43:49 by partain]
[ghc-hetmet.git] / ghc / includes / LLC.h
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 ************************************************************************/
8
9 #ifndef __LLC_H
10 #define __LLC_H
11 #ifdef PAR
12
13 #include "rtsdefs.h"
14
15 #ifdef HAVE_SYS_TIME_H
16 #include <sys/time.h>
17 #endif
18
19 #ifdef HAVE_TIME_H
20 #include <time.h>
21 #endif
22
23 #include "PEOpCodes.h"
24 #define safemalloc malloc
25 #include "pvm3.h"
26
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 */
31
32 #define PEGROUP         "PE"
33
34 #define MGRGROUP        "MGR"
35 #define PECTLGROUP      "PECTL"
36
37
38 #define PETASK          "PE"
39
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)
43
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)
47
48 #define HandleException(p)      (*ExceptionHandler)(p)
49 #define _SetMyExceptionHandler(f) ExceptionHandler = f
50
51 #define SPARK_THREAD_DESCRIPTOR         1
52 #define GLOBAL_THREAD_DESCRIPTOR        2
53
54 #define _extract_jump_field(v)  (v)
55
56 #define MAX_DATA_WORDS_IN_PACKET        1024
57
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)
62
63 #define PutLit(l)               { int a = l; PutArgN(?,a); }
64
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)
69
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,...));
76
77 char *GetOpName PROTO((unsigned op));
78 void NullException(STG_NO_ARGS);
79
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);
86
87 void (*ExceptionHandler) PROTO((PACKET));
88
89 #endif /*PAR */
90 #endif /*defined __LLC_H */