Original WRF subgrid support version from John Michalakes without fire
[wrffire.git] / wrfv2_fire / external / RSL / RSL / rsl.h
blobec57dacf30c6dc4a161c5c9d17e74bf3443db584
1 /***********************************************************************
3 COPYRIGHT
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.
9 Copyright notice
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
25 the Software.
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 RSL_H
59 #define RSL_H
61 /**************************************************************/
62 /* Any changes to this file should be followed by make clean */
63 /* before remaking the RSL library */
64 /**************************************************************/
66 /**************************************************************/
67 /* not likely that you will need to change things below here */
69 /* this definition used in cd.c */
70 #define HARD_CODED_BOUNDARY_WIDTH_FIX_ME_PLEASE 5
72 #define RSL_MAXDOMAINS MAXDOM_MAKE /* FORTRAN */
74 #define RSL_MAXPROC MAXPROC_MAKE /* FORTRAN */
76 /* increased from 5 to 7 10/4/96 to accomodate 168 pt stencil */
77 /* decreased to 3 (2 + 1 for garbage row) to save memory -- only estore
78 in sound needs 168 pt stencil and we'll handle that as a special case */
79 #define RSL_DEFAULT_PADAREA 4 /* FORTRAN */
81 #define RSL_MLOW 1 /* FORTRAN */
82 #define RSL_MHIGH 2 /* FORTRAN */
83 #define RSL_NLOW 3 /* FORTRAN */
84 #define RSL_NHIGH 4 /* FORTRAN */
85 #define RSL_DBDY 5 /* FORTRAN */
86 #define RSL_CLOSEST 6 /* FORTRAN */
88 #define DOT_BDY_INFO_LEN 10 /* FORTRAN */
90 #define RSL_MLOW_X 7 /* FORTRAN */
91 #define RSL_MHIGH_X 8 /* FORTRAN */
92 #define RSL_NLOW_X 9 /* FORTRAN */
93 #define RSL_NHIGH_X 10 /* FORTRAN */
94 #define RSL_DBDY_X 11 /* FORTRAN */
95 #define RSL_CLOSEST_X 12 /* FORTRAN */
97 #define CROSS_BDY_INFO_LEN 12 /* FORTRAN */
99 #define RSL_00 7 /* FORTRAN */
100 #define RSL_M0 8 /* FORTRAN */
101 #define RSL_0N 9 /* FORTRAN */
102 #define RSL_MN 10 /* FORTRAN */
104 #define MLOW (RSL_MLOW-1)
105 #define MHIGH (RSL_MHIGH-1)
106 #define NLOW (RSL_NLOW-1)
107 #define NHIGH (RSL_NHIGH-1)
109 #define MAX_RUNPAD 6
110 #define MAX_KINDPAD 8
111 /* break ties in boundary classification */
112 #define M_WINS 0 /* FORTRAN */
113 #define N_WINS 1 /* FORTRAN */
114 #define DIAG_WINS 2 /* FORTRAN */
116 #ifdef SHOW_RSL_CONFIGURATION
117 /* SHOW_RSL_CONFIGURATION is only every defined externally. This
118 next bit is never actually used. Rather it is used by the top
119 level makefile to show the configuration of the model when the
120 user types make showconfig. */
121 show config: ---if the library were completely remade---
122 show config:"RSL_IMAX" would be set to: RSL_IMAX
123 show config:"RSL_JMAX" would be set to: RSL_JMAX
124 show config:"RSL_MAXDOMAINS" would be set to: RSL_MAXDOMAINS
125 show config:"RSL_MAXPROC" would be set to: RSL_MAXPROC
126 show config: ---See also the makefile---
127 #endif
130 /* this should become runtime setaable from the fortran someday */
132 #define RSL_TRUE 1 /* FORTRAN */
133 #define RSL_FALSE 0 /* FORTRAN */
134 #define RSL_INVALID -1 /* FORTRAN */
135 #define RSL_VALID 1 /* FORTRAN */
137 #define RSL_IRAX 3 /* FORTRAN */
138 #define RSL_MAXCHILDREN (RSL_IRAX*RSL_IRAX)
139 #define RSL_MAXKIDS RSL_MAXCHILDREN
140 #define RSL_MAXDESCRIPTORS 2048
141 /* settings below will allow for 20000 fields */
142 #define MAX_BASE_TABLE_ENTRIES 20000
144 #if (ALLOW_RSL_168PT == 1)
145 # define RSL_MAXSTEN 168 /* MAX NUMBER OF STENCIL PTS */
146 #else
147 # define RSL_MAXSTEN 24 /* MAX NUMBER OF STENCIL PTS */
148 #endif
151 #define RSL_REAL 0 /* FORTRAN */
152 #define RSL_DOUBLE 1 /* FORTRAN */
153 #define RSL_COMPLEX 2 /* FORTRAN */
154 #define RSL_INTEGER 3 /* FORTRAN */
155 #define RSL_CHARACTER 4 /* FORTRAN */
157 #define RSL_REAL_F90 100 /* FORTRAN */
158 #define RSL_DOUBLE_F90 101 /* FORTRAN */
159 #define RSL_COMPLEX_F90 102 /* FORTRAN */
160 #define RSL_INTEGER_F90 103 /* FORTRAN */
161 #define RSL_CHARACTER_F90 104 /* FORTRAN */
163 /* traversal orders */
164 /* A = Ascending, D = Descending, applied to dim in order left to right */
165 #define MINMAJ_AA 0 /* FORTRAN */
166 #define MINMAJ_AD 1 /* FORTRAN */
167 #define MINMAJ_DA 2 /* FORTRAN */
168 #define MINMAJ_DD 3 /* FORTRAN */
169 #define MAJMIN_AA 1000 /* FORTRAN */
170 #define MAJMIN_AD 1001 /* FORTRAN */
171 #define MAJMIN_DA 1002 /* FORTRAN */
172 #define MAJMIN_DD 1003 /* FORTRAN */
173 #define MINMAJ MINMAJ_AA /* FORTRAN */
174 #define MAJMIN MAJMIN_AA /* FORTRAN */
176 #define MNMJ(X) ( ( (X) / 1000 ) == 0 )
177 #define D1(X) ( 2 & (X) )
178 #define D2(X) ( 1 & (X) )
179 #define A1(X) ( ! A1 )
180 #define A2(X) ( ! A2 )
182 /* nested domain shapes */
183 #define RSL_REGULAR_NEST 55 /* FORTRAN */
184 #define RSL_RAGGED_NEST 56 /* FORTRAN */
186 /* packing strategies */
187 #define MINNS_MAJEW_2D 0
188 #define MINEW_MAJNS_2D 1
189 #define MINNS_MAJEW_K_3D 2
190 #define MINEW_MAJNS_K_3D 3
191 #define K_MIDNS_MAJEW_3D 4
192 #define MINNS_K_MAJEW_3D 5
194 /* io strategies */
196 #define IO_REPL 99 /* FORTRAN */
198 #define IO2D_IJ 0 /* FORTRAN */
199 #define IO2D_JI 1 /* FORTRAN */
200 #define IO3D_IJK 2 /* FORTRAN */
201 #define IO3D_JIK 3 /* FORTRAN */
202 #define IO2D 4 /* FORTRAN */
203 #define IO3D 5 /* FORTRAN */
204 #define IO3D_KIJ 6 /* FORTRAN */
205 #define IO3D_IKJ 7 /* FORTRAN */
207 #define IO2D_IJ_RAW 10 /* FORTRAN */
208 #define IO2D_JI_RAW 11 /* FORTRAN */
209 #define IO3D_IJK_RAW 12 /* FORTRAN */
210 #define IO3D_JIK_RAW 13 /* FORTRAN */
212 #define IO2D_IJ_PORTAL 20 /* FORTRAN */
213 #define IO2D_JI_PORTAL 21 /* FORTRAN */
214 #define IO3D_IJK_PORTAL 22 /* FORTRAN */
215 #define IO3D_JIK_PORTAL 23 /* FORTRAN */
217 #define IO2D_IJ_INTERNAL 24 /* FORTRAN */
218 #define IO2D_JI_INTERNAL 25 /* FORTRAN */
219 #define IO3D_IJK_INTERNAL 26 /* FORTRAN */
220 #define IO3D_JIK_INTERNAL 27 /* FORTRAN */
221 #define IO3D_KIJ_INTERNAL 28 /* FORTRAN */
222 #define IO3D_IKJ_INTERNAL 29 /* FORTRAN */
224 #define IO2D_IJ_88 30 /* FORTRAN */
225 #define IO2D_JI_88 31 /* FORTRAN */
226 #define IO3D_IJK_88 32 /* FORTRAN */
227 #define IO3D_JIK_88 33 /* FORTRAN */
229 #define RSL_MAXDIM 3
231 /* type declarations */
233 typedef int * int_p ;
234 #if !(defined(SUNDEBUG) || defined(crayx1))
235 #ifndef NEC_TUNE
236 typedef short rsl_processor_t ;
237 typedef short rsl_index_t ;
238 typedef short rsl_dimlen_t ;
239 #else
240 typedef int rsl_processor_t ;
241 typedef int rsl_index_t ;
242 typedef int rsl_dimlen_t ;
243 #endif
244 #else
245 typedef int rsl_processor_t ;
246 typedef int rsl_index_t ;
247 typedef int rsl_dimlen_t ;
248 #endif
249 typedef long rsl_point_id_t ;
251 #ifdef crayx1
252 typedef int rsl_tag_t ;
253 #else
254 #ifndef NEC_TUNE
255 typedef unsigned char rsl_tag_t ;
256 #else
257 typedef int rsl_tag_t ;
258 #endif
259 #endif
261 typedef struct rsl_list {
262 struct rsl_list * next ;
263 void * data ; /* pointer to some node */
264 #ifdef crayx1
265 int info1 ; /* blank info field */
266 int info2 ; /* blank info field */
267 #else
268 short info1 ; /* blank info field */
269 short info2 ; /* blank info field */
270 #endif
271 } rsl_list_t ;
274 typedef struct rsl_runrec { /* added 1/9/95 for rsl_compute_islab */
275 int i, j, ig, jg, runlength ;
276 } rsl_runrec_t ;
278 typedef struct bcast_point_desc {
279 rsl_point_id_t nest_id ; /* pt in nest */
280 rsl_point_id_t parent_id ; /* cd pt */
281 unsigned char cn, cm ; /* indices of point, with respect to cd pt */
282 } bcast_point_desc_t ;
284 typedef bcast_point_desc_t merge_point_desc_t ;
286 typedef struct rsl_fldspec {
287 struct rsl_fldspec * next ;
288 void * base ;
289 rsl_tag_t ndim ;
290 rsl_tag_t elemsz ;
291 rsl_tag_t memsize ;
292 rsl_tag_t type ;
293 int f90_table_index ;
294 rsl_tag_t strategy ;
295 rsl_tag_t decomp[ RSL_MAXDIM ] ;
296 rsl_index_t gdex[ RSL_MAXDIM ] ;
297 rsl_dimlen_t glen[ RSL_MAXDIM ] ;
298 rsl_dimlen_t llen[ RSL_MAXDIM ] ;
299 rsl_dimlen_t stag[ RSL_MAXDIM ] ; /* 0 = not staggered; 1 = staggered */
300 } rsl_fldspec_t ;
302 typedef struct message_desc {
303 rsl_tag_t tag;
304 /* should be MESSAGE_DESC or BLANK_MESSAGE_DESC */
305 int mh ; /* handle */
306 int nflds ; /* number of field specs in message */
307 int nbytes ; /* for blank messages */
308 rsl_fldspec_t *fldspecs ;
309 } message_desc_t ;
311 typedef struct rsl_plist_elem {
312 struct rsl_plist_elem *next ;
313 rsl_point_id_t id ;
314 rsl_processor_t P ;
315 } rsl_plist_elem_t ;
317 typedef struct rsl_child_info {
318 rsl_point_id_t child[RSL_MAXCHILDREN] ;
319 rsl_processor_t P[RSL_MAXCHILDREN] ;
320 } rsl_child_info_t ;
322 typedef struct rsl_point {
323 rsl_processor_t P ; /* physical processor number */
324 int valid ; /* a valid point? */
325 rsl_tag_t trimmed ; /* was this point trimmed */
326 rsl_tag_t cross ; /* member of the cross grid */
327 rsl_tag_t info_1 ; /* misc tag info */
328 rsl_tag_t info_2 ; /* misc tag info */
329 rsl_point_id_t id ;
330 rsl_point_id_t mother_id ;
331 rsl_processor_t mother_P ;
332 rsl_tag_t which_kid_am_i_m ;
333 rsl_tag_t which_kid_am_i_n ;
335 /* on whole grid */
337 /* counter-clockwise and clockwise below refer
338 to the direction of the traversal in fill_boundary
339 that determined the boundary association...
340 we store both to allow for several resolution
341 strategies on corners. */
343 /* dot grid */
344 rsl_index_t bdy_cclockwise ; /* direction to boundary (counter) */
345 rsl_index_t bdy_clockwise ; /* direction to boundary (clockwise) */
346 rsl_index_t dbdy ; /* distance to boundary */
348 /* these next four fields are computed differently,
349 in that they do not take into account corners.
350 They simply measure the distance from the point
351 to the boundary in question. */
352 rsl_index_t dist_mlow ; /* distance to southern bdy */
353 rsl_index_t dist_mhigh ; /* " to northern bdy */
354 rsl_index_t dist_nlow ; /* " to western bdy */
355 rsl_index_t dist_nhigh ; /* " to eastern bdy */
357 /* on cross grid */
358 /* cross grid */
359 rsl_index_t bdy_x_cclockwise ; /* direction to boundary (counter) */
360 rsl_index_t bdy_x_clockwise ; /* direction to boundary (clockwise) */
361 rsl_index_t dbdy_x ; /* distance to boundary */
363 rsl_index_t dist_mlow_x ; /* distance to southern bdy */
364 rsl_index_t dist_mhigh_x ; /* " to northern bdy */
365 rsl_index_t dist_nlow_x ; /* " to western bdy */
366 rsl_index_t dist_nhigh_x ; /* " to eastern bdy */
368 rsl_child_info_t *children_p ;
369 } rsl_point_t ;
371 typedef struct rsl_hemi_rec {
372 int oig , ojg ;
373 int nbytes ;
374 int curs ;
375 char * data ;
376 struct rsl_hemi_rec * next ;
377 } rsl_hemi_rec_t ;
379 typedef struct rsl_domain_info {
380 int valid ;
381 int decomposed ;
383 /* parent domain descriptor */
384 int parent ;
385 int nestshape ; /* RSL_REGULAR_NEST, RSL_RAGGED_NEST */
387 /* information about parent, children */
388 int parent_bcast_compiled ;
389 int parent_merge_compiled ;
390 int child_bcast_compiled[RSL_MAXDOMAINS] ;
391 int child_merge_compiled[RSL_MAXDOMAINS] ;
393 /* pointer to MN domain data structure (array of points) */
394 rsl_point_t *domain ;
396 /* pointer to MZ domain data structure (array of points) (20010222) */
397 rsl_point_t *domain_mz ;
399 /* pointer to NZ domain data structure (array of points) (20010222) */
400 rsl_point_t *domain_nz ;
402 /* MN decomp */
403 /* dimensions of the global domain data structure */
404 rsl_dimlen_t len_m ;
405 rsl_dimlen_t len_n ;
406 rsl_dimlen_t eff_m ;
407 rsl_dimlen_t eff_n ;
408 rsl_dimlen_t loc_m ;
409 rsl_dimlen_t loc_n ;
410 /* dimensions of the global domain data structure (20010222) */
411 rsl_dimlen_t len_z ;
412 rsl_dimlen_t eff_z ;
413 rsl_dimlen_t loc_z ;
414 /* MZ decomp (20010223) */
415 /* dimensions of the global domain data structure */
416 rsl_dimlen_t len_mz_m ;
417 rsl_dimlen_t len_mz_n ;
418 rsl_dimlen_t eff_mz_m ;
419 rsl_dimlen_t eff_mz_n ;
420 rsl_dimlen_t loc_mz_m ;
421 rsl_dimlen_t loc_mz_n ;
422 rsl_dimlen_t len_mz_z ;
423 rsl_dimlen_t eff_mz_z ;
424 rsl_dimlen_t loc_mz_z ;
425 /* NZ decomp (20010223 */
426 /* dimensions of the global domain data structure */
427 rsl_dimlen_t len_nz_m ;
428 rsl_dimlen_t len_nz_n ;
429 rsl_dimlen_t eff_nz_m ;
430 rsl_dimlen_t eff_nz_n ;
431 rsl_dimlen_t loc_nz_m ;
432 rsl_dimlen_t loc_nz_n ;
433 rsl_dimlen_t len_nz_z ;
434 rsl_dimlen_t eff_nz_z ;
435 rsl_dimlen_t loc_nz_z ;
437 /* list of stencils used on this domain (just keep handles) */
438 int stenlist[RSL_MAXDESCRIPTORS] ;
439 int stencurs ;
440 int periodlist[RSL_MAXDESCRIPTORS] ;
441 int periodcurs ;
442 int xposelist[RSL_MAXDESCRIPTORS] ;
443 int xposecurs ;
445 message_desc_t *old_state_vect, *new_state_vect ;
447 /* coordinates of the domain in its parent (sort of) */
448 rsl_index_t coord_m ;
449 rsl_index_t coord_n ;
451 /* nesting ratio in parent domain */
452 int irax_m ;
453 int irax_n ;
455 /* trimming constants -- these are used to tell rsl how much shorter
456 in a dimension the effective range of a nest is than the declared
457 range -- it might be declared longer because it has to be a
458 multiple of irax_[mn] */
459 int trim_m ;
460 int trim_n ;
462 rsl_index_t nest_level ; /* 0 is mother domain */
463 rsl_list_t *pts ; /* list of points on this processor */
464 rsl_list_t *ghost_pts ; /* list of points communicating with us */
465 rsl_list_t *iruns ; /* list of runs in idimension 1/9/95 */
466 rsl_index_t ilocaloffset ; /* ns offset global to local in domain ds */
467 rsl_index_t jlocaloffset ; /* ew offset global to local in domain ds */
469 rsl_index_t ilocaloffset_mz ;
470 rsl_index_t jlocaloffset_mz ;
471 rsl_index_t klocaloffset_mz ;
473 rsl_index_t ilocaloffset_nz ;
474 rsl_index_t jlocaloffset_nz ;
475 rsl_index_t klocaloffset_nz ;
477 rsl_index_t old_ilocaloffset ;
478 rsl_index_t old_jlocaloffset ;
479 int maskid ; /* maximum stencil specified for this domain */
481 /* added for RSL_COMPUTE -- in comp_world.c */
482 /* these are worked out in rsl_new_decomp.c */
483 int idif, jdif ;
484 /* these are for iterating with j-major */
485 int nrun[MAX_KINDPAD+1];
486 int *(js[MAX_KINDPAD+1]) ;
487 int *(is[MAX_KINDPAD+1]), *(ie[MAX_KINDPAD+1]), *(jg2n[MAX_KINDPAD+1]) ;
488 /* these are for iterating with i-major */
489 int nruni[MAX_KINDPAD+1];
490 int *(is2[MAX_KINDPAD+1]) ;
491 int *(js2[MAX_KINDPAD+1]), *(je2[MAX_KINDPAD+1]), *(ig2n[MAX_KINDPAD+1]) ;
493 rsl_processor_t bcast_recv_Pnpts[RSL_MAXPROC] ;
494 rsl_processor_t bcast_recv_Plist[RSL_MAXPROC] ;
495 rsl_processor_t bcast_recv_Ptags[RSL_MAXPROC] ;
496 int Nbcast_recv_Plist ;
497 rsl_processor_t bcast_send_Pnpts[RSL_MAXPROC] ;
498 rsl_processor_t bcast_send_Plist[RSL_MAXPROC] ;
499 int Nbcast_send_Plist ;
501 rsl_list_t *bcast_Xlist ;
504 rsl_processor_t merge_recv_Pnpts[RSL_MAXPROC] ;
505 rsl_processor_t merge_recv_Plist[RSL_MAXPROC] ;
506 rsl_processor_t merge_recv_Ptags[RSL_MAXPROC] ;
507 int Nmerge_recv_Plist ;
508 rsl_processor_t merge_send_Pnpts[RSL_MAXPROC] ;
509 rsl_processor_t merge_send_Plist[RSL_MAXPROC] ;
510 int Nmerge_send_Plist ;
512 rsl_list_t *merge_Xlist ;
515 int other_hemi_proclist_built ;
516 rsl_hemi_rec_t * other_hemi_procbufs[RSL_MAXPROC] ;
517 int hemi_sendPlist[RSL_MAXPROC] ;
518 int hemi_recvPlist[RSL_MAXPROC] ;
519 int hemi_recv_tags[RSL_MAXPROC] ;
521 int is_write, is_read, ie_write, ie_read ;
522 int js_write, js_read, je_write, je_read ;
524 } rsl_domain_info_t ;
527 /* March 1998 -- structure for new packing strategy */
528 #ifdef crayx1
529 struct packrec_struct {
530 void * base ;
531 int offset ;
532 int n ; /* number of bytes in an element */
533 int nelems ; /* number of elements */
534 int stride ; /* number of bytes between each element */
535 int f90_table_index ;
536 int endstop ;
537 int valid ;
538 int curs ; /* position of data in pack buf */
540 typedef struct packrec_struct packrec_t ;
542 #else
543 struct packrec_struct {
544 void * base ;
545 int offset ;
546 int n ; /* number of bytes in an element */
547 int nelems ; /* number of elements */
548 int stride ; /* number of bytes between each element */
549 int f90_table_index ;
550 int endstop ;
551 int valid ;
553 typedef struct packrec_struct packrec_t ;
554 #endif
556 typedef struct rsl_procrec {
557 struct rsl_procrec * next ;
558 rsl_processor_t P ;
559 int sendsize ; /* size of send buf needed for this processor */
560 int recvsize ; /* size of recv buf needed for this processor */
561 int npts ;
562 int recv_npts ;
563 int nsends ; /* diagnostic -- keeps running total number of sends */
564 int nrecvs ; /* diagnostic -- keeps running total number of sends */
565 rsl_list_t *point_list ;
566 /* Mar 1998 */
567 rsl_list_t *recv_point_list ;
568 packrec_t * pack_table ;
569 int pack_table_size ;
570 int pack_table_nbytes ;
571 packrec_t * unpack_table ;
572 int unpack_table_size ;
573 int unpack_table_nbytes ;
574 } rsl_procrec_t ;
576 typedef struct rsl_ptrec {
577 struct rsl_ptrec * next ;
578 rsl_point_t *pt ;
579 rsl_index_t ig, jg ;
580 rsl_list_t *send_messages ;
581 rsl_list_t *recv_messages ;
582 #ifdef crayx1
583 int nsendmsgs ;
584 int nrecvmsgs ;
585 #else
586 short nsendmsgs ;
587 short nrecvmsgs ;
588 #endif
589 } rsl_ptrec_t ;
591 typedef struct rsl_point_hdr {
592 rsl_index_t d, ig, jg, dummy ; /* dummy maintains alignment */
593 int nmsgs ;
594 } rsl_point_hdr_t ;
596 typedef struct rsl_message_hdr { /* packet hdr for message */
597 int sp ;
598 } rsl_message_hdr_t ;
600 typedef struct rsl_fld_hdr { /* packet hdr for fld */
601 void * base ; /* base address; byte pointer arithmetic */
602 #ifdef crayx1
603 int len ; /* number of bytes to follow */
604 #else
605 short len ; /* number of bytes to follow */
606 #endif
607 } rsl_fld_hdr_t ;
609 /* global data */
611 #ifdef DEFINE_GLOBAL
612 # define EXTERN
613 #else
614 # define EXTERN extern
615 #endif
617 EXTERN rsl_domain_info_t domain_info[RSL_MAXDOMAINS] ;
618 /* message descriptors */
619 EXTERN void * mh_descriptors[RSL_MAXDESCRIPTORS] ;
620 /* stencil descriptors */
621 EXTERN void * sh_descriptors[RSL_MAXDESCRIPTORS] ;
622 /* xpose descriptors */
623 EXTERN void * xp_descriptors[RSL_MAXDESCRIPTORS] ;
624 /* period descriptors */
625 EXTERN void * pr_descriptors[RSL_MAXDESCRIPTORS] ;
626 EXTERN int rsl_ndomains ; /* number of active domains */
627 EXTERN int rsl_nproc ; /* number of compute processors */
628 EXTERN int rsl_nproc_all ; /* total # of processors (compute and monitor) */
629 EXTERN int rsl_nproc_n ; /* number of processors decomposing maj dimension */
630 EXTERN int rsl_nproc_m ; /* number of processors decomposing min dimension */
631 EXTERN int rsl_myproc ; /* my physical processor id */
632 EXTERN int rsl_idum ; /* dummy integer variable */
633 EXTERN int rsl_padarea ; /* pad area */
634 EXTERN int io_seq_compute ;
635 EXTERN int io_seq_monitor ;
636 EXTERN char mess[1024] ; /* misc. message buffer for errors and warns */
637 EXTERN char * rsl_noprobe ; /* set from environment */
639 EXTERN int rsl_debug_flg ; /* set by rsl_debug */
640 EXTERN int old_offsets ; /* used in rsl_new_decomp.c */
642 EXTERN int regular_decomp ;
643 EXTERN int sw_allow_dynpad ;
645 /* rsl macros */
647 #define RSL_FATAL(N) rsl_fatal(N)
648 #define RSL_TEST_ERR(T,M) {if(T){fprintf(stderr,"%d rsl error (\"%s\":%d) %s\n",rsl_myproc,__FILE__,__LINE__,M);RSL_FATAL(5);}}
649 #define RSL_TEST_WRN(T,M) {if(T){fprintf(stderr,"%d rsl warning (\"%s\":%d) %s\n",rsl_myproc,__FILE__,__LINE__,M);}}
651 #if 1
652 #ifndef NEC_TUNE
653 #define RSL_MALLOC(T,N) (T *)rsl_malloc(__FILE__,__LINE__,(sizeof(T))*(N))
654 #define RSL_FREE(P) rsl_free(P)
655 #else
656 #define RSL_MALLOC(T,N) (T *)calloc(N, sizeof(T))
657 #define RSL_FREE(P) free(P)
658 #endif
659 #else
660 /* Bob Olson's stuff */
661 #define RSL_MALLOC(T,N) (T *)nexus_debug_malloc((sizeof(T))*(N),__FILE__,__LINE__)
662 #define RSL_FREE(P) nexus_debug_free(P,__FILE__,__LINE__)
663 #endif
665 #define MONITOR_ONLY(S) { int x ; \
666 RSL_C_IAMMONITOR( &x ) ; \
667 if ( x==0 ) \
668 sprintf(mess,"%s: callable only by monitor",S) ; \
669 RSL_TEST_ERR( x == 0,mess) ; }
672 This uses the low 26 bits of a 32 bit message type to encode a message
673 type, a FROM processor designation and a TO processor designation. Note
674 the limits of this encoding:
676 o 10 bits available for processor id (limit is 1024 processors)
677 o 6 bits available for message tag - 1, because we are not
678 allowing 0. (limit is thus 63 possible tags)
680 This is a potential machine or message passing interface dependency.
681 Note, though, that under the proposed MPI standard, this would not
682 be a problem because there are no FORCED type ranges to avoid and
683 all .
685 rev: 95/02/15 -- jm. Modified to drop the TO field (never used) and
686 shorten the TAG field by 1 bit so that the total number of bits
687 required is 15 (compatibility with minimum MPI standard and, in
688 particular for the Fujitsu AP1000 at ANU). Note the new limits
689 from this encoding:
691 o 10 bits available for processor id (limit is 1024 processors)
692 (FROM only is encoded now)
693 o 5 bits available for message tag - 1, because we are not
694 allowing 0. (limit is now 31 possible tags).
697 #if 0
698 # define MTYPE_FROMTO(Y,F,T) ((((Y)&0x3f)<<20)|(((F)&0x3ff)<<10)|(((T)&0x3ff)))
699 # define MTYPE_TAG(X) (((X)>>20)&0x3f)
700 # define MTYPE_FROM(X) (((X)>>10)&0x3ff)
701 # define MTYPE_TO(X) ((X)&0x3ff)
702 #else
703 # if 1
704 /* T is ignored and not encoded in the message tag, Y has been shorted 1 bit */
705 # define MTYPE_FROMTO(Y,F,T) (((((Y)&0x1f)<<10)|(((F)&0x3ff))) | 0 )
706 # define MTYPE_TAG(X) (((X)>>10)&0x1f)
707 # define MTYPE_FROM(X) ((X)&0x3ff)
708 # else
709 /* update May 2002, increase upper bound on processors to 4096 (12 bits)*/
710 # define MTYPE_FROMTO(Y,F,T) (((((Y)&0x1f)<<12)|(((F)&0xfff))) | 0 )
711 # define MTYPE_TAG(X) (((X)>>12)&0x1f)
712 # define MTYPE_FROM(X) ((X)&0xfff)
713 # endif
714 #endif
717 #define INDEX_2(A,B,NB) ( (B) + (A)*(NB) )
718 #define INDEX_3(A,B,NB,C,NC) INDEX_2( (A), INDEX_2( (B), (C), (NC) ), (NB)*(NC) )
720 #if 0
721 /* new encoding for these --
722 7 bits -- domain id maximum number is 127
723 12 bits -- ig index maximum number is 4095
724 12 bits -- jg index maximum number is 4095
725 ----
726 31 bits
728 #define POINTID(D,J,I) ((((((D)&0x7f))<<24)|(((J)&0xfff)<<12)|((I)&0xfff))|0L)
729 #define ID_DOMAIN(M) ((((M)>>24)&0x7f)|0L)
730 #define ID_JDEX(M) ((((M)>>12)&0xfff)|0L)
731 #define ID_IDEX(M) (((M) &0xfff)|0L)
732 #else
733 /* make ig and jg work as signed quantities */
734 /* new encoding for these --
735 7 bits -- domain id maximum number is 127
736 12 bits -- ig index range is -2048 to 2047
737 12 bits -- jg index range is is -2048 to 2047
738 ----
739 31 bits
741 #define POINTID(D,J,I) ((((((D)&0x7f))<<24)|(((J)&0xfff)<<12)|((I)&0xfff))|0L)
742 #define ID_DOMAIN(M) ((((M)>>24)&0x7f)|0L)
743 #define ID_JDEX(M) (((((M)>>12)&0xfff)&0x800)?((((M)>>12)&0xfff)|(-4096L)):((((M)>>12)&0xfff)|0L))
744 #define ID_IDEX(M) (((M)&0x800)?(((M) &0xfff)|(-4096L)):(((M) &0xfff)|0L))
745 #endif
747 #define IS_INVALID(M) ( (M) == RSL_INVALID )
749 /* forward declarations */
751 rsl_point_id_t pointid() ;
752 rsl_index_t id_domain(), id_jdex(), id_idex() ;
754 /* RSL PT DESCRIPTORS */
756 #define RSL_4PT 4 /* FORTRAN */
757 #define RSL_8PT 8 /* FORTRAN */
758 #define RSL_12PT 12 /* FORTRAN */
759 #define RSL_24PT 24 /* FORTRAN */
760 #define RSL_48PT 48 /* FORTRAN */
761 #define RSL_80PT 80 /* FORTRAN */
762 #define RSL_120PT 120 /* FORTRAN */
763 #if (ALLOW_RSL_168PT == 1)
764 /* new -- added for MM5's upper radiative boundary stencil 9/26/96 */
765 #define RSL_168PT 168 /* FORTRAN */
766 #endif
768 #define RSL_NORTHSOUTH 1 /* FORTRAN */
769 #define RSL_EASTWEST 2 /* FORTRAN */
770 #define RSL_NORTHSOUTH_STAG 11 /* FORTRAN */
771 #define RSL_EASTWEST_STAG 12 /* FORTRAN */
772 #define RSL_NOTDECOMPOSED 3 /* FORTRAN */
774 #define RSL_M 1 /* FORTRAN */
775 #define RSL_N 2 /* FORTRAN */
776 #define RSL_M_STAG 11 /* FORTRAN */
777 #define RSL_N_STAG 12 /* FORTRAN */
779 /* message tags */
781 #define MSG_NEWDECOMPOSITION 100
782 #define MSG_MONITOR_REQUEST 101
783 #define MSG_STENCOM 1
784 #define MSG_READ_RESPONSE 2
785 #define MSG_WRITE_RESPONSE 3
786 #define MSG_WRITE_COMPUTE_RESPONSE 4
787 #define MSG_SPECIAL1_RESPONSE 5
788 #define MSG_SPECIAL2_RESPONSE 6
789 #define MSG_FROM_PARENT 7
790 #define MSG_BCAST_SETUP 8
791 #define MSG_MERGE_SETUP 9
792 #define MSG_TO_PARENT 10
793 #define MSG_MON_BCAST 11
794 #define MSG_REDISTCOM 12
795 #define MSG_PERCOM 13
796 #define MSG_XPOSECOM 14
798 #define MSG_IO_FORTRAN 1
799 #define MSG_IO_SOCKET 2
801 /* values for request mode2 when writing to sockets
802 Raw mode just writes a byte stream,
804 Fortran mode puts control words at beginning and end of each write
805 with byte count in control word.
807 Portal mode puts a portal style dimension descriptor at the
808 head of each new write.
811 #define MSG_MODE2_RAW 1
812 #define MSG_MODE2_FORTRAN 2
813 #define MSG_MODE2_PORTAL 3
814 #define MSG_MODE2_88 4
816 /* monitor request types */
817 #define RSL_READ_REQUEST 100
818 #define RSL_READ_RESPONSE 101
819 #define RSL_READ_SPECIAL1 102
820 #define RSL_READ_SPECIAL2 103
821 #define RSL_READ_SPECIAL3 104
822 #define RSL_SHUTDOWN_REQUEST 105
823 #define RSL_WRITE_REQUEST 106
824 #define RSL_WRITE_RESPONSE 107
826 /* descriptor tags */
828 #define MESSAGE_DESC 0
829 #define STENCIL_DESC 1
830 #define BLANK_MESSAGE_DESC 2
831 #define PERIOD_DESC 3
832 #define XPOSE_DESC 4
834 /* xpose switches */
835 #define XPOSE_MN_MZ 0
836 #define XPOSE_MZ_MN 0
838 #define XPOSE_MZ_NZ 1
839 #define XPOSE_NZ_MZ 1
841 #define XPOSE_MN_NZ 2
842 #define XPOSE_NZ_MN 2
844 /* defines for MPI2 compat */
846 #ifndef MPI2_SUPPORT
847 typedef int MPI_Fint;
848 # define MPI_Comm_c2f(comm) (MPI_Fint)(comm)
849 # define MPI_Comm_f2c(comm) (MPI_Comm)(comm)
850 #endif
852 /* other includes */
854 #include "rsl_comm.h"
855 #include "compat.h"
856 #include "buf_for_proc.h"
857 #include "stencil_def.h" /* stencil_def.h must follow message_def.h */
858 #include "xpose_def.h" /* xpose_def.h must follow message_def.h */
859 #include "period_def.h" /* period_def.h must follow message_def.h */
860 #include "rsl_io.h"
862 #if (( defined(vpp) || defined(vpp2) ) && ! defined(sx))
863 #define bcopy(a,b,c) vbcopy_C(a,b,c)
864 #endif
866 void * rsl_malloc(), * malloc() ;
867 void * get_base_for_index() ;
869 #ifdef NEC_TUNE
870 extern void copymem( void *, int, void *, int, int, int ) ;
871 #endif
874 #endif /* nothing after this line */