File: pcmpsc.c

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (211 lines) | stat: -rw-r--r-- 4,708 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
 * PCMPSC.C - parallel communications routines for PPC under MPSC
 *
 * Source Version: 2.0
 * Software Release #92-0043
 *
 */

#include "cpyright.h"

#include "ppc.h"
#include <mpsc/mpsc.h>

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PC_OPEN_GROUP - open a copy of the named executable on each available
 *               - node
 */

PC_open_group(argv, pn)
   char **argv;
   int *pn;
   {
#if 0
int i, n;

    mpsc_init();

/* start up the nodes, the number of nodes is determined by 
 * the resource management environment variables
 */
    load(name, -1, 0);

    n = numnodes();
    for (i = 0; i < n; i++)
        nl[i].acpu = i;    

    *pn = n;
#endif
    return(TRUE);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PC_OPEN_MEMBER - open a copy of the named executable on each available
 *                - node
 */

PROCESS *PC_open_member(argv, pnn)
   char **argv;
   int *pnn;
   {PROCESS *pp;

    mpsc_init();

    pp = FMAKE(PROCESS, "PC_OPEN_MEMBER:pp");
    pp->acpu = mynode();
    pp->rcpu = myhost();

    *pnn = numnodes();
    return(pp);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PC_OUT - write data out to the filtered list of nodes
 *        - this does a message passing system's SEND command
 *        - or a LINDA-like PUT
 */

PC_out(bf, type, ni, pp, filt)
   byte *bf;
   char *type;
   size_t ni;
   PROCESS *pp;
   int *filt;
   {int i, j, ityp, dn, did, nb, t, more, *p;
    int type_index, default_node, default_id, host_node;
    int *nl, *pnl, *pl, *ppl, nn, np;

    type_index   = 0;
    default_node = -1;
    default_id   = 0;
    host_node    = myhost();

    ityp = 0;
    nl   = NULL;
    pl   = NULL;
    if (filt != NULL)
       {p = filt;
	more = TRUE;
	while (more)
	   {switch (*p++)
	       {case PC_MATCH_TYPE :
		     ityp |= *p++;
		     ityp |= ((type_index << 16) & PC_TYPE_MASK);
		     break;

	        case PC_MATCH_TAG :
		     ityp |= (*p++ & PC_TAG_MASK);
		     break;

	        case PC_MATCH_NODE :
                     nl = p++;
                     nn = *p++;
                     p += nn;
		     break;

	        case PC_MATCH_PID :
		     pl = p;
                     np = *p++;
                     p += np;
		     break;

	        default :
		     more = FALSE;
		     break;};};};

    nb = ni*sizeof(int);

    if (nl == NULL)
       {nn = 1;
	pnl = &default_node;}
    else
       {pnl = nl;
	nn  = *pnl++;};

    for (i = 0; i < nn; i++)
        {dn = *pnl++;
	 if (dn == PC_GROUP_LEADER)
	    dn = host_node;

	 if (pl == NULL)
	    {np = 1;
	     ppl = &default_id;}
	 else
	    {ppl = pl;
	     np  = *ppl++;};

	 for (j = 0; i < np; i++)
	     {did = *ppl++;
	      csend(ityp, bf, nb, dn, did);

	      if (_PC_debug)
	         PRINT(stdout, "\t\t\tNode %d sent %d bytes to %d\n",
		       pp->acpu, nb, dn);};};

    return((int) ni);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PC_IN - read data in from the filtered list of nodes
 *       - this does a message passing system's RECV command
 *       - or a LINDA-like GET
 */

PC_in(bf, type, ni, pp, filt)
   byte *bf;
   char *type;
   size_t ni;
   PROCESS *pp;
   int *filt;
   {int i, n, ityp, dn, did, nb, t, more, *p;
    int type_index;

    ityp = 0;
    type_index = 0;
    if (filt != NULL)
       {p = filt;
	more = TRUE;
	while (more)
	   {switch (*p++)
	       {case PC_MATCH_TYPE :
		     ityp |= *p++;
		     ityp |= (type_index << 16) & PC_TYPE_MASK;
		     break;

	        case PC_MATCH_TAG :
		     ityp |= (*p++ & PC_TAG_MASK);
		     break;

	        case PC_MATCH_NODE :
	        case PC_MATCH_PID  :
		     break;

	        default :
		     more = FALSE;
		     break;};};};

    nb = ni*sizeof(int);
    crecv(ityp, bf, nb);

    if (_PC_debug)
       PRINT(stdout, "Node %d got %d bytes\n", pp->acpu, nb);

    return((int) ni);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PC_SYNC_EXECUTION - synchronize the execution of the tasks */

void PC_sync_execution()
   {gsync();

    return;}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/