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__
63 typedef unsigned int MPL_Request
;
64 typedef unsigned int MPL_Status
;
66 #define PICLHandleInc 128
72 int type
; /* send = 1, recv = 2 */
79 struct tagsToHandles
*tags
;
82 /******************************************************
84 * do whatever initialization is necessary for the
87 * Initial coding: Leslie Hart, 22 Apr 94
88 * Adapted to MPL: J. Michalakes 7/13/94
89 * Adapted to PICL from RSL: J. Michalakes 7/13/94
91 *****************************************************/
93 static int argc_dummy
= 0 ;
94 static char * argv_dummy
= "" ;
107 void setarc0( i1
, i2
, i3
, i4
) /* noop */
108 int *i1
, *i2
, *i3
, *i4
;
115 void check0( i1
) /* noop */
123 void open0( nprocs
, me
, dum
)
124 int *nprocs
, *me
, *dum
;
128 piclMPLHandleLUT
.nHandles
= PICLHandleInc
;
129 piclMPLHandleLUT
.nUsed
= 0;
130 piclMPLHandleLUT
.tags
= (struct tagsToHandles
*)
131 malloc (sizeof (struct tagsToHandles
) * PICLHandleInc
);
133 mpc_task_query( nbuf
, 2, 2 ) ;
136 mpc_task_query( nbuf
, 4, 3 ) ;
143 fprintf(stderr
,"piclMPLInit: \n") ;
144 fprintf(stderr
,"type_low: %d\n",type_low
) ;
145 fprintf(stderr
,"type_high: %d\n",type_high
) ;
146 fprintf(stderr
,"dontcare: %d\n",dontcare
) ;
147 fprintf(stderr
,"allmsg: %d\n",allmsg
) ;
148 fprintf(stderr
,"nulltask: %d\n",nulltask
) ;
149 fprintf(stderr
,"allgrp: %d\n",allgrp
) ;
153 if (piclMPLHandleLUT
.tags
== NULL
)
155 fprintf (stderr
, "Fatal Error: malloc failure in piclMPLInit\n");
159 who0( nprocs
, me
, dum
) ;
165 who0( nprocs
, me
, dum
)
166 int *nprocs
, *me
, *dum
;
168 mpc_environ( nprocs
, me
) ;
176 fprintf(stderr
,"Warning -- clock0 is stubbed in %s\n", __FILE__
) ;
177 return(0.0) ; /* stub for now */
184 recv0( buf
, len
, type
)
193 rsl_mp_type
= *type
;
196 if ( rsl_mp_type
< type_low
|| rsl_mp_type
> type_high
)
198 sprintf(mess
,"RSL_RECV message type %d out of allowed range: %d..%d\n",
199 rsl_mp_type
,type_low
,type_high
) ;
200 RSL_TEST_ERR( 1, mess
) ;
202 rc
= mpc_brecv(buf
,rsl_mp_n
,
206 if ( rc
) {fprintf(stderr
,"mpc_brecv returns %d\n",rc
);exit(1);}
207 if ( rsl_mp_nbytes
> (*len
) )
209 fprintf(stderr
,"Message too large: tag %d, recvd %d, allocated %d\n",
210 *type
,rsl_mp_nbytes
,(*len
));
218 send0( buf
, len
, type
, dest
)
220 int *len
, *type
, *dest
;
225 rsl_mp_type
= *type
;
226 if ( rsl_mp_type
< type_low
|| rsl_mp_type
> type_high
)
228 sprintf(mess
,"RSL_SEND message type %d out of allowed range: %d..%d\n",
229 rsl_mp_type
,type_low
,type_high
) ;
230 RSL_TEST_ERR( 1, mess
) ;
232 if (0) fprintf(stderr
,"mpc_bsend: nlen %10d type %10d dest %10d\n", \
233 B
, rsl_mp_type
, D
) ; \
234 rc
= mpc_bsend(A
,B
,D
,C
) ; \
235 if ( rc
) {fprintf(stderr
,"mpc_bsend returns %d\n",rc
);exit(1);} \
241 /******************************************************
242 * piclMPLFindWaitH (tag)
243 * Use the LUT to find an MPL wait handle from a tag
245 * Initial coding: Leslie Hart, 22 Apr 94
247 *****************************************************/
249 long piclMPLFindWaitH (tag
, waitHandle
, type
, nbytes
)
250 int tag
; /* Tag for which we lookup a wait handle */
251 MPL_Request
*waitHandle
;
257 for (i
=0; i
< piclMPLHandleLUT
.nUsed
; i
++)
259 if (piclMPLHandleLUT
.tags
[i
].tag
== tag
)
261 *waitHandle
= piclMPLHandleLUT
.tags
[i
].Handle
;
262 *type
= piclMPLHandleLUT
.tags
[i
].type
;
263 *nbytes
= piclMPLHandleLUT
.tags
[i
].nbytes
;
264 piclMPLHandleLUT
.nUsed
--; /* Keep them contiguous */
265 piclMPLHandleLUT
.tags
[i
].tag
=piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].tag
;
266 piclMPLHandleLUT
.tags
[i
].Handle
=
267 piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].Handle
;
268 piclMPLHandleLUT
.tags
[i
].type
=
269 piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].type
;
270 piclMPLHandleLUT
.tags
[i
].nbytes
=
271 piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].nbytes
;
279 /******************************************************
280 * piclMPLSaveWaitH (tag, waitHandle)
281 * Use the LUT to save an MPL wait handle referenced by a tag
283 * Initial coding: Leslie Hart, 22 Apr 94
285 *****************************************************/
287 void piclMPLSaveWaitH (tag
, waitHandle
,type
,nbytes
)
289 MPL_Request
* waitHandle
;
292 /* Make sure there is enough space, if not, try a realloc */
293 /* If the realloc fails we're in deep trouble */
294 if (piclMPLHandleLUT
.nUsed
== piclMPLHandleLUT
.nHandles
)
296 struct tagsToHandles
*tags
; /* Temp pointer */
297 tags
= (struct tagsToHandles
*)
298 realloc (piclMPLHandleLUT
.tags
,
299 sizeof (struct tagsToHandles
) * (piclMPLHandleLUT
.nHandles
+ PICLHandleInc
));
302 piclMPLHandleLUT
.tags
= tags
;
303 piclMPLHandleLUT
.nHandles
+= PICLHandleInc
;
308 fprintf (stderr
, "Fatal Error: realloc failure in piclMPLSaveWaitH\n");
314 /* Stash the handle */
315 piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].tag
= tag
;
316 piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].Handle
= *waitHandle
;
317 piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].type
= type
;
318 piclMPLHandleLUT
.tags
[piclMPLHandleLUT
.nUsed
].nbytes
= nbytes
;
319 piclMPLHandleLUT
.nUsed
++;
322 /******************************************************
323 * piclMPLISend (buff, mlen, tag, dest)
324 * Post a non blocking send an stash a wait handle
326 * Initial coding: Leslie Hart, 22 Apr 94
328 *****************************************************/
330 void piclMPLISend (buff
, mlen
, tag
, dest
)
336 MPL_Request waitHandle
;
339 if ( tag
< type_low
|| tag
> type_high
)
341 sprintf(mess
,"PICL_SENDBEGIN message type %d out of allowed range: %d..%d\n",
342 tag
,type_low
,type_high
) ;
343 PICL_TEST_ERR( 1, mess
) ;
353 fprintf(stderr
,"mpc_send: nlen %10d type %10d dest %10d handle %08x\n",
354 mlen
, tag
, dest
, waitHandle
) ;
359 sprintf(mess
,"mpc_send returns %d", rc
) ;
360 PICL_TEST_ERR( 1, mess
) ;
363 piclMPLSaveWaitH (tag
, &waitHandle
,1,mlen
);
366 /******************************************************
367 * piclMPLIRecv (buff, mlen, tag)
368 * Post a non blocking receive an stash a wait handle
370 * Initial coding: Leslie Hart, 22 Apr 94
372 *****************************************************/
374 void piclMPLIRecv (buff
, mlen
, tag
)
379 MPL_Request waitHandle
;
387 if ( tag
< type_low
|| tag
> type_high
)
389 sprintf(mess
,"PICL_RECVBEGIN message type %d out of allowed range: %d..%d\n",
390 tag
,type_low
,type_high
) ;
391 PICL_TEST_ERR( 1, mess
) ;
402 fprintf(stderr
,"mpc_recv: nlen %10d type %10d source %10d handle %08x\n",
403 mlen
, tag
, source
, waitHandle
) ;
408 sprintf(mess
,"mpc_recv returns %d", rc
) ;
409 PICL_TEST_ERR( 1, mess
) ;
412 piclMPLSaveWaitH (tag
, &waitHandle
, 2, mlen
);
415 /******************************************************
417 * Wait for a pending send/recv
419 * Initial coding: Leslie Hart, 22 Apr 94
421 *****************************************************/
425 void piclMPLWait (tag
)
428 MPL_Request waitHandle
;
433 if ( piclMPLFindWaitH (tag
, &waitHandle
, &type
, &nbytes
) != 0 )
435 fprintf(stderr
,"piclMPLWait: tag %d not found by piclMPLFindWaitH\n",tag
) ;
440 fprintf(stderr
,"calling mpc_wait: tag %d, handle %08x, type %d (%s), original nbytes %d\n",
441 tag
, waitHandle
, type
, (type
==1)?"send":((type
==2)?"recv":"unknown"),
445 rc
= mpc_wait ( &waitHandle
, &status
);
448 fprintf(stderr
,"mpc_wait fails: tag %d, handle %08x, type %d (%s), original nbytes %d, status %d, rc %d, mperrno = %d\n",
449 tag
, waitHandle
, type
, (type
==1)?"send":((type
==2)?"recv":"unknown"),
450 nbytes
, status
, rc
, mperrno
) ;
455 fprintf(stderr
,"mpc_wait : tag %d, handle %08x, status %d\n",
456 tag
, waitHandle
, status
) ;
461 #endif /* __MPL_COMPAT__ */