1 /***********************************************************************
5 The following is a notice of limited availability of the code and
6 Government license and disclaimer which must be included in the
7 prologue of the code and in all source listings of the code.
10 (c) 1977 University of Chicago
12 Permission is hereby granted to use, reproduce, prepare
13 derivative works, and to redistribute to others at no charge. If
14 you distribute a copy or copies of the Software, or you modify a
15 copy or copies of the Software or any portion of it, thus forming
16 a work based on the Software and make and/or distribute copies of
17 such work, you must meet the following conditions:
19 a) If you make a copy of the Software (modified or verbatim)
20 it must include the copyright notice and Government
21 license and disclaimer.
23 b) You must cause the modified Software to carry prominent
24 notices stating that you changed specified portions of
27 This software was authored by:
29 Argonne National Laboratory
30 J. Michalakes: (630) 252-6646; email: michalak@mcs.anl.gov
31 Mathematics and Computer Science Division
32 Argonne National Laboratory, Argonne, IL 60439
34 ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES
35 OF ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT,
36 AND OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A
37 CONTRACT WITH THE DEPARTMENT OF ENERGY.
39 GOVERNMENT LICENSE AND DISCLAIMER
41 This computer code material was prepared, in part, as an account
42 of work sponsored by an agency of the United States Government.
43 The Government is granted for itself and others acting on its
44 behalf a paid-up, nonexclusive, irrevocable worldwide license in
45 this data to reproduce, prepare derivative works, distribute
46 copies to the public, perform publicly and display publicly, and
47 to permit others to do so. NEITHER THE UNITED STATES GOVERNMENT
48 NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, NOR ANY OF
49 THEIR EMPLOYEES, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
50 ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
51 COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS,
52 PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD
53 NOT INFRINGE PRIVATELY OWNED RIGHTS.
55 ***************************************************************************/
58 #ifndef __MPL_COMPAT__
59 #define __MPL_COMPAT__
65 typedef int MPL_Request
;
66 typedef int MPL_Status
;
68 #define RSLHandleInc 32
77 int type
; /* send = 1, recv = 2 */
84 struct tagsToHandles
*tags
;
87 /******************************************************
89 * do whatever initialization is necessary for the
92 * Initial coding: Leslie Hart, 22 Apr 94
93 * Adapted to MPL: J. Michalakes 7/13/94
95 *****************************************************/
97 static int argc_dummy
= 0 ;
98 static char * argv_dummy
= "" ;
111 rslMPLHandleLUT
.nHandles
= RSLHandleInc
;
112 rslMPLHandleLUT
.nUsed
= 0;
113 rslMPLHandleLUT
.tags
= (struct tagsToHandles
*)
114 malloc (sizeof (struct tagsToHandles
) * RSLHandleInc
);
116 mpc_task_query( nbuf
, 2, 2 ) ;
119 mpc_task_query( nbuf
, 4, 3 ) ;
126 fprintf(stderr
,"rslMPLInit: \n") ;
127 fprintf(stderr
,"type_low: %d\n",type_low
) ;
128 fprintf(stderr
,"type_high: %d\n",type_high
) ;
129 fprintf(stderr
,"dontcare: %d\n",dontcare
) ;
130 fprintf(stderr
,"allmsg: %d\n",allmsg
) ;
131 fprintf(stderr
,"nulltask: %d\n",nulltask
) ;
132 fprintf(stderr
,"allgrp: %d\n",allgrp
) ;
137 if (rslMPLHandleLUT
.tags
== NULL
)
139 fprintf (stderr
, "Fatal Error: malloc failure in rslMPLInit\n");
146 /******************************************************
147 * rslMPLFindWaitH (tag)
148 * Use the LUT to find an MPL wait handle from a tag
150 * Initial coding: Leslie Hart, 22 Apr 94
152 *****************************************************/
154 long rslMPLFindWaitH (tag
, waitHandle
, type
, nbytes
)
155 int tag
; /* Tag for which we lookup a wait handle */
156 MPL_Request
*waitHandle
;
162 for (i
=0; i
< rslMPLHandleLUT
.nUsed
; i
++)
164 if (rslMPLHandleLUT
.tags
[i
].tag
== tag
)
166 *waitHandle
= rslMPLHandleLUT
.tags
[i
].Handle
;
167 *type
= rslMPLHandleLUT
.tags
[i
].type
;
168 *nbytes
= rslMPLHandleLUT
.tags
[i
].nbytes
;
169 rslMPLHandleLUT
.nUsed
--; /* Keep them contiguous */
170 rslMPLHandleLUT
.tags
[i
].tag
=rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].tag
;
171 rslMPLHandleLUT
.tags
[i
].Handle
=
172 rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].Handle
;
173 rslMPLHandleLUT
.tags
[i
].type
=
174 rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].type
;
175 rslMPLHandleLUT
.tags
[i
].nbytes
=
176 rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].nbytes
;
184 /* same as above, but leaves list alone */
185 long rslMPLPeekWaitH (tag
, waitHandle
, type
, nbytes
)
186 int tag
; /* Tag for which we lookup a wait handle */
187 MPL_Request
*waitHandle
;
193 for (i
=0; i
< rslMPLHandleLUT
.nUsed
; i
++)
195 if (rslMPLHandleLUT
.tags
[i
].tag
== tag
)
197 *waitHandle
= rslMPLHandleLUT
.tags
[i
].Handle
;
198 *type
= rslMPLHandleLUT
.tags
[i
].type
;
199 *nbytes
= rslMPLHandleLUT
.tags
[i
].nbytes
;
208 /******************************************************
209 * rslMPLSaveWaitH (tag, waitHandle)
210 * Use the LUT to save an MPL wait handle referenced by a tag
212 * Initial coding: Leslie Hart, 22 Apr 94
214 *****************************************************/
216 void rslMPLSaveWaitH (tag
, waitHandle
,type
,nbytes
)
218 MPL_Request
* waitHandle
;
221 /* Make sure there is enough space, if not, try a realloc */
222 /* If the realloc fails we're in deep trouble */
223 if (rslMPLHandleLUT
.nUsed
== rslMPLHandleLUT
.nHandles
)
225 struct tagsToHandles
*tags
; /* Temp pointer */
226 tags
= (struct tagsToHandles
*)
227 realloc (rslMPLHandleLUT
.tags
,
228 sizeof (struct tagsToHandles
) * (rslMPLHandleLUT
.nHandles
+ RSLHandleInc
));
231 rslMPLHandleLUT
.tags
= tags
;
232 rslMPLHandleLUT
.nHandles
+= RSLHandleInc
;
237 fprintf (stderr
, "Fatal Error: realloc failure in rslMPLSaveWaitH\n");
243 /* Stash the handle */
244 rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].tag
= tag
;
245 rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].Handle
= *waitHandle
;
246 rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].type
= type
;
247 rslMPLHandleLUT
.tags
[rslMPLHandleLUT
.nUsed
].nbytes
= nbytes
;
248 rslMPLHandleLUT
.nUsed
++;
251 /******************************************************
252 * rslMPLISend (buff, mlen, tag, dest)
253 * Post a non blocking send an stash a wait handle
255 * Initial coding: Leslie Hart, 22 Apr 94
257 *****************************************************/
259 void rslMPLISend (buff
, mlen
, tag
, dest
)
265 MPL_Request waitHandle
;
268 if ( tag
< type_low
|| tag
> type_high
)
270 sprintf(mess
,"RSL_SENDBEGIN message type %d out of allowed range: %d..%d\n",
271 tag
,type_low
,type_high
) ;
272 RSL_TEST_ERR( 1, mess
) ;
282 fprintf(stderr
,"mpc_send: nlen %10d type %10d dest %10d handle %08x\n",
283 mlen
, tag
, dest
, waitHandle
) ;
288 sprintf(mess
,"mpc_send returns %d", rc
) ;
289 RSL_TEST_ERR( 1, mess
) ;
292 rslMPLSaveWaitH (tag
, &waitHandle
,1,mlen
);
295 /******************************************************
296 * rslMPLIRecv (buff, mlen, tag)
297 * Post a non blocking receive an stash a wait handle
299 * Initial coding: Leslie Hart, 22 Apr 94
301 *****************************************************/
303 void rslMPLIRecv (buff
, mlen
, tag
)
308 MPL_Request waitHandle
;
316 if ( tag
< type_low
|| tag
> type_high
)
318 sprintf(mess
,"RSL_RECVBEGIN message type %d out of allowed range: %d..%d\n",
319 tag
,type_low
,type_high
) ;
320 RSL_TEST_ERR( 1, mess
) ;
332 sprintf(mess
,"mpc_recv returns %d", rc
) ;
333 RSL_TEST_ERR( 1, mess
) ;
336 /* fprintf(stderr,"rslMPLIRecv tag = %d, handle = %d\n",tag,waitHandle) ; */
338 rslMPLSaveWaitH (tag
, &waitHandle
, 2, mlen
);
341 /******************************************************
343 * Wait for a pending send/recv
345 * Initial coding: Leslie Hart, 22 Apr 94
347 *****************************************************/
351 void rslMPLWait (tag
)
354 MPL_Request waitHandle
;
359 if ( rslMPLFindWaitH (tag
, &waitHandle
, &type
, &nbytes
) != 0 )
361 fprintf(stderr
,"rslMPLWait: tag %d not found by rslMPLFindWaitH\n",tag
) ;
366 fprintf(stderr
,"calling mpc_wait: tag %d, handle %08x, type %d (%s), original nbytes %d\n",
367 tag
, waitHandle
, type
, (type
==1)?"send":((type
==2)?"recv":"unknown"),
371 rc
= mpc_wait ( &waitHandle
, &status
);
374 fprintf(stderr
,"mpc_wait fails: tag %d, handle %08x, type %d (%s), original nbytes %d, status %d, rc %d, mperrno = %d\n",
375 tag
, waitHandle
, type
, (type
==1)?"send":((type
==2)?"recv":"unknown"),
376 nbytes
, status
, rc
, mperrno
) ;
381 fprintf(stderr
,"mpc_wait : tag %d, handle %08x, status %d\n",
382 tag
, waitHandle
, status
) ;
388 MPL_Request d1
, d2
, d3
, waitHandle
, d4
, d5
, d6
;
390 rslMPLProbe( tag
, retval
)
397 if ( rslMPLPeekWaitH (tag
, &waitHandle
, &type
, &nbytes
) != 0 )
399 fprintf(stderr
,"rslMPLWait: tag %d not found by rslMPLPeekWaitH\n",tag
) ;
402 rc
= mpc_status( waitHandle
) ;
414 sprintf(mess
,"No outstanding message for tag %d (handle %d) rc=%d\n",tag
,waitHandle
,rc
) ;
415 RSL_TEST_ERR(1,mess
) ;
420 #endif /* __MPL_COMPAT__ */