3
"$Id: pvmfrag.c,v 1.4 1997/06/25 22:09:37 pvmsrc Exp $";
6
* PVM version 3.4: Parallel Virtual Machine System
7
* University of Tennessee, Knoxville TN.
8
* Oak Ridge National Laboratory, Oak Ridge TN.
9
* Emory University, Atlanta GA.
10
* Authors: J. J. Dongarra, G. E. Fagg, M. Fischer
11
* G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
12
* P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
13
* (C) 1997 All Rights Reserved
17
* Permission to use, copy, modify, and distribute this software and
18
* its documentation for any purpose and without fee is hereby granted
19
* provided that the above copyright notice appear in all copies and
20
* that both the copyright notice and this permission notice appear in
21
* supporting documentation.
23
* Neither the Institutions (Emory University, Oak Ridge National
24
* Laboratory, and University of Tennessee) nor the Authors make any
25
* representations about the suitability of this software for any
26
* purpose. This software is provided ``as is'' without express or
29
* PVM version 3 was funded in part by the U.S. Department of Energy,
30
* the National Science Foundation and the State of Tennessee.
39
* Revision 1.4 1997/06/25 22:09:37 pvmsrc
40
* Markus adds his frigging name to the author list of
41
* every file he ever looked at...
43
* Revision 1.3 1997/04/24 20:58:53 pvmsrc
44
* intialize fr_rip to 0
46
* Revision 1.2 1997/01/28 19:27:27 pvmsrc
47
* New Copyright Notice & Authors.
49
* Revision 1.1 1996/09/23 23:44:37 pvmsrc
52
* Revision 1.3 1995/05/17 16:42:49 manchek
53
* added support for CSPP shared memory.
54
* use CLUMP_ALLOC option to clump frag headers
56
* Revision 1.2 1994/06/03 20:38:24 manchek
59
* Revision 1.1 1993/08/30 23:26:51 manchek
71
extern void pvmbailout();
81
/* NOTE: If we were doing flushes on node, we'd have to set dcache_stride
82
to 32 for single node systems and 64 for multinode systems.
83
But since we only do this for cross node systems, we already know
87
int dcache_stride = 64;
92
#define FRAG_CLUMP 500
94
static struct frag freefrags; /* free frag header cache */
95
static int numfrags = 0;
107
freefrags.fr_link = freefrags.fr_rlink = &freefrags;
108
if (!(fp = TALLOC(FRAG_CLUMP, struct frag, "frgs")))
109
return (struct frag *)0;
110
for (n = FRAG_CLUMP; n-- > 0; ) {
111
LISTPUTBEFORE(&freefrags, fp, fr_link, fr_rlink);
114
numfrags = FRAG_CLUMP;
117
fp = freefrags.fr_link;
118
LISTDELETE(fp, fr_link, fr_rlink);
121
fp = TALLOC(1, struct frag, "frag");
134
freefrags.fr_link = freefrags.fr_rlink = &freefrags;
135
LISTPUTBEFORE(&freefrags, fp, fr_link, fr_rlink);
145
/**********************
148
**********************/
152
* Create a new frag with 1 reference, not in a list.
153
* If len is nonzero, len bytes are allocated as data space.
154
* Else, the frag has no data (is a master or will get data later).
159
int len; /* (max) buffer size or 0 */
163
if (!(fp = frag_get_header()))
166
if (len) { /* slave frag */
167
fp->fr_link = fp->fr_rlink = 0;
168
if (!(fp->fr_dat = fp->fr_buf = da_new(len))) {
174
} else { /* master */
175
fp->fr_link = fp->fr_rlink = fp;
176
fp->fr_dat = fp->fr_buf = 0;
185
fp->fr_num_unpacked = 0;
188
pvmlogprintf("fr_new() %d = %lx\n", len, fp);
193
pvmlogerror("fr_new() can't get memory\n");
195
return (struct frag*)0;
201
* Create a new frag with 1 reference, not in a list.
202
* Its buffer is assumed to be a writable, dense, non-databuf.
207
char *cp; /* buffer */
208
int len; /* buffer size */
212
if (!(fp = frag_get_header()))
215
fp->fr_link = fp->fr_rlink = 0;
216
fp->fr_dat = fp->fr_buf = cp;
217
fp->fr_max = fp->fr_len = len;
225
pvmlogerror("fr_snew() can't get memory\n");
227
return (struct frag*)0;
233
* Reduce frag refcount by 1. If result is < 1:
234
* If the frag is a master, unref all its slave frags
235
* Else, unref its data.
236
* Then, free the frag.
241
struct frag *fp; /* master frag */
244
pvmlogprintf("fr_unref() %lx ref %d\n", fp, fp->fr_u.ref);
246
if (fp->fr_u.ref-- == 1) {
247
struct frag *fp2, *fp3;
249
if (fp->fr_buf) { /* slave frag */
252
if (fp->fr_num_unpacked) {
253
unsigned int addr = (unsigned int)(fp->fr_dat);
254
int nbytes = fp->fr_num_unpacked;
256
nbytes += (addr & 0x3f);
258
dcache_flush_region(addr, nbytes);
261
da_unref(fp->fr_buf);
263
} else { /* master frag */
265
/* unref all frags in chain */
266
for (fp2 = fp->fr_link; fp2 != fp; fp2 = fp3) {
268
LISTDELETE(fp2, fr_link, fr_rlink);