root / src / pgesv / HPL_rollT.c
Historique | Voir | Annoter | Télécharger (10,03 ko)
1 |
/*
|
---|---|
2 |
* -- High Performance Computing Linpack Benchmark (HPL)
|
3 |
* HPL - 2.0 - September 10, 2008
|
4 |
* Antoine P. Petitet
|
5 |
* University of Tennessee, Knoxville
|
6 |
* Innovative Computing Laboratory
|
7 |
* (C) Copyright 2000-2008 All Rights Reserved
|
8 |
*
|
9 |
* -- Copyright notice and Licensing terms:
|
10 |
*
|
11 |
* Redistribution and use in source and binary forms, with or without
|
12 |
* modification, are permitted provided that the following conditions
|
13 |
* are met:
|
14 |
*
|
15 |
* 1. Redistributions of source code must retain the above copyright
|
16 |
* notice, this list of conditions and the following disclaimer.
|
17 |
*
|
18 |
* 2. Redistributions in binary form must reproduce the above copyright
|
19 |
* notice, this list of conditions, and the following disclaimer in the
|
20 |
* documentation and/or other materials provided with the distribution.
|
21 |
*
|
22 |
* 3. All advertising materials mentioning features or use of this
|
23 |
* software must display the following acknowledgement:
|
24 |
* This product includes software developed at the University of
|
25 |
* Tennessee, Knoxville, Innovative Computing Laboratory.
|
26 |
*
|
27 |
* 4. The name of the University, the name of the Laboratory, or the
|
28 |
* names of its contributors may not be used to endorse or promote
|
29 |
* products derived from this software without specific written
|
30 |
* permission.
|
31 |
*
|
32 |
* -- Disclaimer:
|
33 |
*
|
34 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
35 |
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
36 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
37 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
|
38 |
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
39 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
40 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
41 |
* DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
42 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
43 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
44 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
45 |
* ---------------------------------------------------------------------
|
46 |
*/
|
47 |
/*
|
48 |
* Include files
|
49 |
*/
|
50 |
#include "hpl.h" |
51 |
|
52 |
#define I_SEND 0 |
53 |
#define I_RECV 1 |
54 |
|
55 |
#ifdef STDC_HEADERS
|
56 |
void HPL_rollT
|
57 |
( |
58 |
HPL_T_panel * PBCST, |
59 |
int * IFLAG,
|
60 |
HPL_T_panel * PANEL, |
61 |
const int N, |
62 |
double * U,
|
63 |
const int LDU, |
64 |
const int * IPLEN, |
65 |
const int * IPMAP, |
66 |
const int * IPMAPM1 |
67 |
) |
68 |
#else
|
69 |
void HPL_rollT
|
70 |
( PBCST, IFLAG, PANEL, N, U, LDU, IPLEN, IPMAP, IPMAPM1 ) |
71 |
HPL_T_panel * PBCST; |
72 |
int * IFLAG;
|
73 |
HPL_T_panel * PANEL; |
74 |
const int N; |
75 |
double * U;
|
76 |
const int LDU; |
77 |
const int * IPLEN; |
78 |
const int * IPMAP; |
79 |
const int * IPMAPM1; |
80 |
#endif
|
81 |
{ |
82 |
/*
|
83 |
* Purpose
|
84 |
* =======
|
85 |
*
|
86 |
* HPL_rollT rolls the local arrays containing the local pieces of U, so
|
87 |
* that on exit to this function U is replicated in every process row.
|
88 |
* In addition, this function probe for the presence of the column panel
|
89 |
* and forwards it when available.
|
90 |
*
|
91 |
* Arguments
|
92 |
* =========
|
93 |
*
|
94 |
* PBCST (local input/output) HPL_T_panel *
|
95 |
* On entry, PBCST points to the data structure containing the
|
96 |
* panel (to be broadcast) information.
|
97 |
*
|
98 |
* IFLAG (local input/output) int *
|
99 |
* On entry, IFLAG indicates whether or not the broadcast has
|
100 |
* already been completed. If not, probing will occur, and the
|
101 |
* outcome will be contained in IFLAG on exit.
|
102 |
*
|
103 |
* PANEL (local input/output) HPL_T_panel *
|
104 |
* On entry, PANEL points to the data structure containing the
|
105 |
* panel (to be rolled) information.
|
106 |
*
|
107 |
* N (local input) const int
|
108 |
* On entry, N specifies the local number of rows of U. N must
|
109 |
* be at least zero.
|
110 |
*
|
111 |
* U (local input/output) double *
|
112 |
* On entry, U is an array of dimension (LDU,*) containing the
|
113 |
* local pieces of U in each process row.
|
114 |
*
|
115 |
* LDU (local input) const int
|
116 |
* On entry, LDU specifies the local leading dimension of U. LDU
|
117 |
* should be at least MAX(1,N).
|
118 |
*
|
119 |
* IPLEN (global input) const int *
|
120 |
* On entry, IPLEN is an array of dimension NPROW+1. This array
|
121 |
* is such that IPLEN[i+1] - IPLEN[i] is the number of rows of U
|
122 |
* in each process row.
|
123 |
*
|
124 |
* IPMAP (global input) const int *
|
125 |
* On entry, IMAP is an array of dimension NPROW. This array
|
126 |
* contains the logarithmic mapping of the processes. In other
|
127 |
* words, IMAP[myrow] is the absolute coordinate of the sorted
|
128 |
* process.
|
129 |
*
|
130 |
* IPMAPM1 (global input) const int *
|
131 |
* On entry, IMAPM1 is an array of dimension NPROW. This array
|
132 |
* contains the inverse of the logarithmic mapping contained in
|
133 |
* IMAP: For i in [0.. NPROW) IMAPM1[IMAP[i]] = i.
|
134 |
*
|
135 |
* ---------------------------------------------------------------------
|
136 |
*/
|
137 |
/*
|
138 |
* .. Local Variables ..
|
139 |
*/
|
140 |
#if 0
|
141 |
MPI_Datatype type[2];
|
142 |
#endif
|
143 |
MPI_Status status; |
144 |
MPI_Request request; |
145 |
MPI_Comm comm; |
146 |
int Cmsgid=MSGID_BEGIN_PFACT, ibufR, ibufS,
|
147 |
ierr=MPI_SUCCESS, il, k, l, lengthR, |
148 |
lengthS, mydist, myrow, next, npm1, nprow, |
149 |
partner, prev; |
150 |
/* ..
|
151 |
* .. Executable Statements ..
|
152 |
*/
|
153 |
if( N <= 0 ) return; |
154 |
|
155 |
npm1 = ( nprow = PANEL->grid->nprow ) - 1; myrow = PANEL->grid->myrow;
|
156 |
comm = PANEL->grid->col_comm; |
157 |
/*
|
158 |
* Rolling phase
|
159 |
*/
|
160 |
mydist = IPMAPM1[myrow]; |
161 |
prev = IPMAP[MModSub1( mydist, nprow )]; |
162 |
next = IPMAP[MModAdd1( mydist, nprow )]; |
163 |
|
164 |
for( k = 0; k < npm1; k++ ) |
165 |
{ |
166 |
l = (int)( (unsigned int)(k) >> 1 ); |
167 |
|
168 |
if( ( ( mydist + k ) & 1 ) != 0 ) |
169 |
{ |
170 |
il = MModAdd( mydist, l, nprow ); |
171 |
lengthS = IPLEN[il+1] - ( ibufS = IPLEN[il] );
|
172 |
il = MModSub( mydist, l+1, nprow );
|
173 |
lengthR = IPLEN[il+1] - ( ibufR = IPLEN[il] ); partner = prev;
|
174 |
} |
175 |
else
|
176 |
{ |
177 |
il = MModSub( mydist, l, nprow ); |
178 |
lengthS = IPLEN[il+1] - ( ibufS = IPLEN[il] );
|
179 |
il = MModAdd( mydist, l+1, nprow );
|
180 |
lengthR = IPLEN[il+1] - ( ibufR = IPLEN[il] ); partner = next;
|
181 |
} |
182 |
|
183 |
if( lengthR > 0 ) |
184 |
{ |
185 |
#if 0
|
186 |
if( ierr == MPI_SUCCESS )
|
187 |
{
|
188 |
if( LDU == N )
|
189 |
ierr = MPI_Type_contiguous( lengthR * LDU, MPI_DOUBLE,
|
190 |
&type[I_RECV] );
|
191 |
else
|
192 |
ierr = MPI_Type_vector( lengthR, N, LDU, MPI_DOUBLE,
|
193 |
&type[I_RECV] );
|
194 |
}
|
195 |
if( ierr == MPI_SUCCESS )
|
196 |
ierr = MPI_Type_commit( &type[I_RECV] );
|
197 |
if( ierr == MPI_SUCCESS )
|
198 |
ierr = MPI_Irecv( Mptr( U, 0, ibufR, LDU ), 1, type[I_RECV],
|
199 |
partner, Cmsgid, comm, &request );
|
200 |
#else
|
201 |
/*
|
202 |
* In our case, LDU is N - Do not use the MPI datatype.
|
203 |
*/
|
204 |
if( ierr == MPI_SUCCESS )
|
205 |
ierr = MPI_Irecv( Mptr( U, 0, ibufR, LDU ), lengthR*LDU,
|
206 |
MPI_DOUBLE, partner, Cmsgid, comm, &request ); |
207 |
#endif
|
208 |
} |
209 |
|
210 |
if( lengthS > 0 ) |
211 |
{ |
212 |
#if 0
|
213 |
if( ierr == MPI_SUCCESS )
|
214 |
{
|
215 |
if( LDU == N )
|
216 |
ierr = MPI_Type_contiguous( lengthS*LDU, MPI_DOUBLE,
|
217 |
&type[I_SEND] );
|
218 |
else
|
219 |
ierr = MPI_Type_vector( lengthS, N, LDU, MPI_DOUBLE,
|
220 |
&type[I_SEND] );
|
221 |
}
|
222 |
if( ierr == MPI_SUCCESS )
|
223 |
ierr = MPI_Type_commit( &type[I_SEND] );
|
224 |
if( ierr == MPI_SUCCESS )
|
225 |
ierr = MPI_Send( Mptr( U, 0, ibufS, LDU ), 1, type[I_SEND],
|
226 |
partner, Cmsgid, comm );
|
227 |
if( ierr == MPI_SUCCESS )
|
228 |
ierr = MPI_Type_free( &type[I_SEND] );
|
229 |
#else
|
230 |
/*
|
231 |
* In our case, LDU is N - Do not use the MPI datatype.
|
232 |
*/
|
233 |
if( ierr == MPI_SUCCESS )
|
234 |
ierr = MPI_Send( Mptr( U, 0, ibufS, LDU ), lengthS*LDU,
|
235 |
MPI_DOUBLE, partner, Cmsgid, comm ); |
236 |
#endif
|
237 |
} |
238 |
|
239 |
if( lengthR > 0 ) |
240 |
{ |
241 |
if( ierr == MPI_SUCCESS )
|
242 |
ierr = MPI_Wait( &request, &status ); |
243 |
#if 0
|
244 |
if( ierr == MPI_SUCCESS )
|
245 |
ierr = MPI_Type_free( &type[I_RECV] );
|
246 |
#endif
|
247 |
} |
248 |
/*
|
249 |
* Probe for column panel - forward it when available
|
250 |
*/
|
251 |
if( *IFLAG == HPL_KEEP_TESTING ) (void) HPL_bcast( PBCST, IFLAG ); |
252 |
} |
253 |
|
254 |
if( ierr != MPI_SUCCESS )
|
255 |
{ HPL_pabort( __LINE__, "HPL_rollT", "MPI call failed" ); } |
256 |
/*
|
257 |
* End of HPL_rollT
|
258 |
*/
|
259 |
} |