added README_changes.txt
[wrffire.git] / wrfv2_fire / external / RSL / RSL / default_decomposition.c
blobc867d5778de393d95d449b8204437a01fd19017d
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 ***************************************************************************/
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include "rsl.h"
61 static struct default_decomp {
62 int (*default_decomp_fcn)() ;
63 } default_decomp[RSL_MAXDOMAINS] ;
64 static int *def_decomp_info[RSL_MAXDOMAINS] ;
66 /* this is called from various parts of the code to decompose a
67 domain if it has not been decomposed already */
68 default_decomposition( d_p, mloc_p, nloc_p )
69 int_p d_p, mloc_p, nloc_p ;
71 int px, py ;
72 int (*f)() ;
73 int retval ;
74 int zloc_p,
75 mloc_mz_p, nloc_mz_p, zloc_mz_p,
76 mloc_nz_p, nloc_nz_p, zloc_nz_p ;
78 py = rsl_nproc_m ;
79 px = rsl_nproc_n ;
81 f = default_decomp[*d_p].default_decomp_fcn ;
83 retval = RSL_FDECOMPOSE (
84 d_p,
86 &py,
87 &px,
88 def_decomp_info[*d_p],
89 mloc_p, nloc_p, &zloc_p,
90 &mloc_mz_p, &nloc_mz_p, &zloc_mz_p,
91 &mloc_nz_p, &nloc_nz_p, &zloc_nz_p ) ;
93 /* these have been added for the parallel matrix transpose, 20010223.
94 default_decomp is called many places in RSL, and rather than thread
95 all this through, I have opted to just store the additional info
96 from teh decomposition algorithma and store it in the domain info */
97 domain_info[*d_p].loc_m = *mloc_p ;
98 domain_info[*d_p].loc_n = *nloc_p ;
99 domain_info[*d_p].loc_z = zloc_p ;
100 domain_info[*d_p].loc_mz_m = mloc_mz_p ;
101 domain_info[*d_p].loc_mz_n = nloc_mz_p ;
102 domain_info[*d_p].loc_mz_z = zloc_mz_p ;
103 domain_info[*d_p].loc_nz_m = mloc_nz_p ;
104 domain_info[*d_p].loc_nz_n = nloc_nz_p ;
105 domain_info[*d_p].loc_nz_z = zloc_nz_p ;
107 return(retval) ;
111 SET_DEF_DECOMP_FCN --- Replace the default mapping routine.
113 This provides a mechanism to replace the mapping function currently
114 in effect with a different routine, specified by the functional
115 pointer Arg1. This is the routine that will be called by RSL
116 whenever a new domain is created. The user program can provide
117 additional information to the mapping function using
118 SET_DEF_DECOMP_INFO.
120 Mapping function:
121 The user-supplied function for decomposing the domain should have
122 the following form.
124 Verbatim:
125 $ INTEGER FUNCTION MAPPING ( in, out, info, m, n, py, px )
126 BREAKTHEEXAMPLECODE
128 In and out are m by n integer arrays. Each element of the in array is
129 set to RSL_VALID for valid points in the domain or RSL_INVALID if the
130 point is not considered to be part of the domain and therefore not
131 to be allocated to a processor (as might be the case if extra memory
132 is allocated but not used). The function generates an out array
133 such that every point that was RSL_VALID in the in array is given
134 a processor number between 0 (zero) and py times px minus 1. Integers
135 m and n are the in and out array dimensions; integer py is the number
136 of processors decomposing m; integer px is the number of processors
137 decomposing n.
139 See also:
140 SET_DEF_DECOMP_INFO
143 SET_DEF_DECOMP_FCN ( f )
144 int
145 (*f)() ; /* (I) Function to use as default decomposition. */
147 int i ;
149 for ( i = 0 ; i < RSL_MAXDOMAINS ; i++ )
150 default_decomp[i].default_decomp_fcn = f ;
153 SET_DEF_DECOMP_FCN1 ( d_p, f )
154 int_p d_p ;
156 (*f)() ; /* (I) Function to use as default decomposition. */
158 int i ;
159 int d ;
161 d = *d_p ;
162 RSL_TEST_ERR(d < 0 || d >= RSL_MAXDOMAINS,
163 "rsl_compile_stencil: bad domain descriptor" ) ;
164 default_decomp[*d_p].default_decomp_fcn = f ;
169 SET_DEF_DECOMP_INFO --- Provide data to RSL to pass to the mapping routine.
171 Notes:
172 When RSL calls the default mapping function, the data provided as Arg2
173 will be passed as the third argument to the function. This provides
174 mechanism for moving data such as timing information from the user program
175 to the mapping routine for use in calculating the domain decomposition.
177 See also:
178 SET_DEF_DECOMP_FCN
182 SET_DEF_DECOMP_INFO ( d_p, inf )
183 int_p
184 d_p ; /* (I) RSL domain descriptor */
185 void *
186 inf ; /* (I) Pointer to memory that will be passed as-is to the decomposition routine */
188 def_decomp_info[*d_p] = (int_p) inf ;