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 ***************************************************************************/
57 /* this is still under construction -- 11/94 */
60 #ifndef __CHAM_COMPAT__
61 #define __CHAM_COMPAT__
65 #include "comm/comm.h"
68 #define RSLHandleInc 32
70 typedef long CHAM_request
;
84 struct tagsToHandles
*tags
;
87 /******************************************************
89 * do whatever initialization is necessary for the
92 * Initial coding: Leslie Hart, 22 Apr 94
93 * Adapted to CHAM: J. Michalakes 11/94
95 *****************************************************/
97 static int dummy
= 0 ;
101 rslCHAMHandleLUT
.nHandles
= RSLHandleInc
;
102 rslCHAMHandleLUT
.nUsed
= 0;
103 rslCHAMHandleLUT
.tags
= (struct tagsToHandles
*)
104 malloc (sizeof (struct tagsToHandles
) * RSLHandleInc
);
107 if (rslCHAMHandleLUT
.tags
== NULL
)
109 fprintf (stderr
, "Fatal Error: malloc failure in rslCHAMInit\n");
116 /******************************************************
117 * rslCHAMWho ( numproc, myproc )
118 * Use the LUT to find an CHAM wait handle from a tag
120 * Initial coding: J. Michalakes 7/13/94
122 *****************************************************/
124 long rslCHAMWho( numproc
, myproc
)
125 int * numproc
, * myproc
;
128 *numproc
= PInumtids
;
132 /******************************************************
133 * rslCHAMFindWaitH (tag)
134 * Use the LUT to find an CHAM wait handle from a tag
136 * Initial coding: Leslie Hart, 22 Apr 94
138 *****************************************************/
140 long rslCHAMFindWaitH (tag
, waitHandle
,
141 buff
, mlen
, datatype
)
142 int tag
; /* Tag for which we lookup a wait handle */
143 CHAM_Request
*waitHandle
;
151 for (i
=0; i
< rslCHAMHandleLUT
.nUsed
; i
++)
153 if (rslCHAMHandleLUT
.tags
[i
].tag
== tag
)
155 *buff
= rslCHAMHandleLUT
.tags
[i
].buff
;
156 *mlen
= rslCHAMHandleLUT
.tags
[i
].mlen
;
157 *datatype
= rslCHAMHandleLUT
.tags
[i
].datatype
;
158 *waitHandle
= rslCHAMHandleLUT
.tags
[i
].Handle
;
160 rslCHAMHandleLUT
.nUsed
--; /* Keep them contiguous */
161 rslCHAMHandleLUT
.tags
[i
].tag
=rslCHAMHandleLUT
.tags
[rslCHAMHandleLUT
.nUsed
].tag
;
162 rslCHAMHandleLUT
.tags
[i
].buff
=
163 rslCHAMHandleLUT
.tags
[rslCHAMHandleLUT
.nUsed
].buff
;
164 rslCHAMHandleLUT
.tags
[i
].mlen
=
165 rslCHAMHandleLUT
.tags
[rslCHAMHandleLUT
.nUsed
].mlen
;
166 rslCHAMHandleLUT
.tags
[i
].datatype
=
167 rslCHAMHandleLUT
.tags
[rslCHAMHandleLUT
.nUsed
].datatype
;
168 rslCHAMHandleLUT
.tags
[i
].Handle
=
169 rslCHAMHandleLUT
.tags
[rslCHAMHandleLUT
.nUsed
].Handle
;
175 /******************************************************
176 * rslCHAMSaveWaitH (tag, waitHandle)
177 * Use the LUT to save an CHAM wait handle referenced by a tag
179 * Initial coding: Leslie Hart, 22 Apr 94
181 *****************************************************/
183 void rslCHAMSaveWaitH (tag
, waitHandle
)
185 CHAM_Request
* waitHandle
;
187 /* Make sure there is enough space, if not, try a realloc */
188 /* If the realloc fails we're in deep trouble */
189 if (rslCHAMHandleLUT
.nUsed
== rslCHAMHandleLUT
.nHandles
)
191 struct tagsToHandles
*tags
; /* Temp pointer */
192 tags
= (struct tagsToHandles
*)
193 realloc (rslCHAMHandleLUT
.tags
,
194 sizeof (struct tagsToHandles
) * (rslCHAMHandleLUT
.nHandles
+ RSLHandleInc
));
197 rslCHAMHandleLUT
.tags
= tags
;
198 rslCHAMHandleLUT
.nHandles
+= RSLHandleInc
;
203 fprintf (stderr
, "Fatal Error: realloc failure in rslCHAMSaveWaitH\n");
209 /* Stash the handle */
210 rslCHAMHandleLUT
.tags
[rslCHAMHandleLUT
.nUsed
].tag
= tag
;
211 rslCHAMHandleLUT
.tags
[rslCHAMHandleLUT
.nUsed
].Handle
= *waitHandle
;
212 rslCHAMHandleLUT
.nUsed
++;
215 /******************************************************
216 * rslCHAMISend (buff, mlen, tag, dest)
217 * Post a non blocking send an stash a wait handle
219 * Initial coding: Leslie Hart, 22 Apr 94
221 *****************************************************/
223 void rslCHAMISend (buff
, mlen
, tag
, dest
)
229 CHAM_Request waitHandle
;
238 rslCHAMSaveWaitH (tag
, &waitHandle
);
241 /******************************************************
242 * rslCHAMIRecv (buff, mlen, tag)
243 * Post a non blocking receive an stash a wait handle
245 * Initial coding: Leslie Hart, 22 Apr 94
247 *****************************************************/
249 void rslCHAMIRecv (buff
, mlen
, tag
)
254 CHAM_Request waitHandle
;
263 rslCHAMSaveWaitH (tag
, waitHandle
);
266 /******************************************************
268 * Wait for a pending send/recv
270 * Initial coding: Leslie Hart, 22 Apr 94
272 *****************************************************/
274 void rslCHAMWait (tag
, flag
)
277 CHAM_Request waitHandle
;
280 rslCHAMFindWaitH (tag
, &waitHandle
);
281 if ( flag
== 1 ) /* receive */
282 CHAM_Wait ( &waitHandle
, &status
);
284 CHAM_Wait ( &waitHandle
, &status
);
287 #endif /* __CHAM_COMPAT__ */