1 | /*************************************************************************/ |
---|
2 | /* */ |
---|
3 | /* Copyright (c) 1994 Stanford University */ |
---|
4 | /* */ |
---|
5 | /* All rights reserved. */ |
---|
6 | /* */ |
---|
7 | /* Permission is given to use, copy, and modify this software for any */ |
---|
8 | /* non-commercial purpose as long as this copyright notice is not */ |
---|
9 | /* removed. All other uses, including redistribution in whole or in */ |
---|
10 | /* part, are forbidden without prior written permission. */ |
---|
11 | /* */ |
---|
12 | /* This software is provided with absolutely no warranty and no */ |
---|
13 | /* support. */ |
---|
14 | /* */ |
---|
15 | /*************************************************************************/ |
---|
16 | |
---|
17 | /* Set all the pointers to the proper locations for the q_multi and |
---|
18 | rhs_multi data structures */ |
---|
19 | |
---|
20 | #include "decs.h" |
---|
21 | |
---|
22 | /////////////// |
---|
23 | void link_all() |
---|
24 | { |
---|
25 | long i; |
---|
26 | long j; |
---|
27 | |
---|
28 | for (j = 0; j < nprocs; j++) |
---|
29 | { |
---|
30 | linkup(psium[j]); |
---|
31 | linkup(psilm[j]); |
---|
32 | linkup(psib[j]); |
---|
33 | linkup(ga[j]); |
---|
34 | linkup(gb[j]); |
---|
35 | linkup(work2[j]); |
---|
36 | linkup(work3[j]); |
---|
37 | linkup(work6[j]); |
---|
38 | linkup(tauz[j]); |
---|
39 | linkup(oldga[j]); |
---|
40 | linkup(oldgb[j]); |
---|
41 | for (i = 0; i <= 1; i++) |
---|
42 | { |
---|
43 | linkup(psi[j][i]); |
---|
44 | linkup(psim[j][i]); |
---|
45 | linkup(work1[j][i]); |
---|
46 | linkup(work4[j][i]); |
---|
47 | linkup(work5[j][i]); |
---|
48 | linkup(work7[j][i]); |
---|
49 | linkup(temparray[j][i]); |
---|
50 | } |
---|
51 | } |
---|
52 | link_multi(); |
---|
53 | } |
---|
54 | |
---|
55 | ///////////////////////////// |
---|
56 | void linkup(double **row_ptr) |
---|
57 | { |
---|
58 | long i; |
---|
59 | double *a; |
---|
60 | double **row; |
---|
61 | double **y; |
---|
62 | long x_part; |
---|
63 | long y_part; |
---|
64 | |
---|
65 | x_part = (jm - 2) / xprocs + 2; |
---|
66 | y_part = (im - 2) / yprocs + 2; |
---|
67 | row = row_ptr; |
---|
68 | y = row + y_part; |
---|
69 | a = (double *) y; |
---|
70 | for (i = 0; i < y_part; i++) |
---|
71 | { |
---|
72 | *row = (double *) a; |
---|
73 | row++; |
---|
74 | a += x_part; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | ////////////////// |
---|
79 | void link_multi() |
---|
80 | { |
---|
81 | long i; |
---|
82 | long j; |
---|
83 | long l; |
---|
84 | double *a; |
---|
85 | double **row; |
---|
86 | double **y; |
---|
87 | unsigned long z; |
---|
88 | unsigned long zz; |
---|
89 | long x_part; |
---|
90 | long y_part; |
---|
91 | unsigned long d_size; |
---|
92 | |
---|
93 | z = ((unsigned long) q_multi + nprocs * sizeof(double ***)); |
---|
94 | |
---|
95 | if (nprocs % 2 == 1) { /* To make sure that the actual data |
---|
96 | starts double word aligned, add an extra |
---|
97 | pointer */ |
---|
98 | z += sizeof(double ***); |
---|
99 | } |
---|
100 | |
---|
101 | d_size = numlev * sizeof(double **); |
---|
102 | if (numlev % 2 == 1) { /* To make sure that the actual data |
---|
103 | starts double word aligned, add an extra |
---|
104 | pointer */ |
---|
105 | d_size += sizeof(double **); |
---|
106 | } |
---|
107 | for (i = 0; i < numlev; i++) { |
---|
108 | d_size += ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); |
---|
109 | } |
---|
110 | for (i = 0; i < nprocs; i++) { |
---|
111 | q_multi[i] = (double ***) z; |
---|
112 | z += d_size; |
---|
113 | } |
---|
114 | for (j = 0; j < nprocs; j++) { |
---|
115 | zz = (unsigned long) q_multi[j]; |
---|
116 | zz += numlev * sizeof(double **); |
---|
117 | if (numlev % 2 == 1) { /* To make sure that the actual data |
---|
118 | starts double word aligned, add an extra |
---|
119 | pointer */ |
---|
120 | zz += sizeof(double **); |
---|
121 | } |
---|
122 | for (i = 0; i < numlev; i++) { |
---|
123 | d_size = ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); |
---|
124 | q_multi[j][i] = (double **) zz; |
---|
125 | zz += d_size; |
---|
126 | } |
---|
127 | } |
---|
128 | |
---|
129 | for (l = 0; l < numlev; l++) { |
---|
130 | x_part = (jmx[l] - 2) / xprocs + 2; |
---|
131 | y_part = (imx[l] - 2) / yprocs + 2; |
---|
132 | for (j = 0; j < nprocs; j++) { |
---|
133 | row = q_multi[j][l]; |
---|
134 | y = row + y_part; |
---|
135 | a = (double *) y; |
---|
136 | for (i = 0; i < y_part; i++) { |
---|
137 | *row = (double *) a; |
---|
138 | row++; |
---|
139 | a += x_part; |
---|
140 | } |
---|
141 | } |
---|
142 | } |
---|
143 | |
---|
144 | z = ((unsigned long) rhs_multi + nprocs * sizeof(double ***)); |
---|
145 | if (nprocs % 2 == 1) { /* To make sure that the actual data |
---|
146 | starts double word aligned, add an extra |
---|
147 | pointer */ |
---|
148 | z += sizeof(double ***); |
---|
149 | } |
---|
150 | |
---|
151 | d_size = numlev * sizeof(double **); |
---|
152 | if (numlev % 2 == 1) { /* To make sure that the actual data |
---|
153 | starts double word aligned, add an extra |
---|
154 | pointer */ |
---|
155 | d_size += sizeof(double **); |
---|
156 | } |
---|
157 | for (i = 0; i < numlev; i++) { |
---|
158 | d_size += ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); |
---|
159 | } |
---|
160 | for (i = 0; i < nprocs; i++) { |
---|
161 | rhs_multi[i] = (double ***) z; |
---|
162 | z += d_size; |
---|
163 | } |
---|
164 | for (j = 0; j < nprocs; j++) { |
---|
165 | zz = (unsigned long) rhs_multi[j]; |
---|
166 | zz += numlev * sizeof(double **); |
---|
167 | if (numlev % 2 == 1) { /* To make sure that the actual data |
---|
168 | starts double word aligned, add an extra |
---|
169 | pointer */ |
---|
170 | zz += sizeof(double **); |
---|
171 | } |
---|
172 | for (i = 0; i < numlev; i++) { |
---|
173 | d_size = ((imx[i] - 2) / yprocs + 2) * ((jmx[i] - 2) / xprocs + 2) * sizeof(double) + ((imx[i] - 2) / yprocs + 2) * sizeof(double *); |
---|
174 | rhs_multi[j][i] = (double **) zz; |
---|
175 | zz += d_size; |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | for (l = 0; l < numlev; l++) |
---|
180 | { |
---|
181 | x_part = (jmx[l] - 2) / xprocs + 2; |
---|
182 | y_part = (imx[l] - 2) / yprocs + 2; |
---|
183 | for (j = 0; j < nprocs; j++) |
---|
184 | { |
---|
185 | row = rhs_multi[j][l]; |
---|
186 | y = row + y_part; |
---|
187 | a = (double *) y; |
---|
188 | for (i = 0; i < y_part; i++) |
---|
189 | { |
---|
190 | *row = (double *) a; |
---|
191 | row++; |
---|
192 | a += x_part; |
---|
193 | } |
---|
194 | } |
---|
195 | } |
---|
196 | } |
---|