root / src / pfact / HPL_pdpanrlN.c @ 9
Historique | Voir | Annoter | Télécharger (9,98 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 |
#ifdef STDC_HEADERS
|
53 |
void HPL_pdpanrlN
|
54 |
( |
55 |
HPL_T_panel * PANEL, |
56 |
const int M, |
57 |
const int N, |
58 |
const int ICOFF, |
59 |
double * WORK
|
60 |
) |
61 |
#else
|
62 |
void HPL_pdpanrlN
|
63 |
( PANEL, M, N, ICOFF, WORK ) |
64 |
HPL_T_panel * PANEL; |
65 |
const int M; |
66 |
const int N; |
67 |
const int ICOFF; |
68 |
double * WORK;
|
69 |
#endif
|
70 |
{ |
71 |
/*
|
72 |
* Purpose
|
73 |
* =======
|
74 |
*
|
75 |
* HPL_pdpanrlN factorizes a panel of columns that is a sub-array of a
|
76 |
* larger one-dimensional panel A using the Right-looking variant of the
|
77 |
* usual one-dimensional algorithm. The lower triangular N0-by-N0 upper
|
78 |
* block of the panel is stored in no-transpose form (i.e. just like the
|
79 |
* input matrix itself).
|
80 |
*
|
81 |
* Bi-directional exchange is used to perform the swap::broadcast
|
82 |
* operations at once for one column in the panel. This results in a
|
83 |
* lower number of slightly larger messages than usual. On P processes
|
84 |
* and assuming bi-directional links, the running time of this function
|
85 |
* can be approximated by (when N is equal to N0):
|
86 |
*
|
87 |
* N0 * log_2( P ) * ( lat + ( 2*N0 + 4 ) / bdwth ) +
|
88 |
* N0^2 * ( M - N0/3 ) * gam2-3
|
89 |
*
|
90 |
* where M is the local number of rows of the panel, lat and bdwth are
|
91 |
* the latency and bandwidth of the network for double precision real
|
92 |
* words, and gam2-3 is an estimate of the Level 2 and Level 3 BLAS
|
93 |
* rate of execution. The recursive algorithm allows indeed to almost
|
94 |
* achieve Level 3 BLAS performance in the panel factorization. On a
|
95 |
* large number of modern machines, this operation is however latency
|
96 |
* bound, meaning that its cost can be estimated by only the latency
|
97 |
* portion N0 * log_2(P) * lat. Mono-directional links will double this
|
98 |
* communication cost.
|
99 |
*
|
100 |
* Note that one iteration of the the main loop is unrolled. The local
|
101 |
* computation of the absolute value max of the next column is performed
|
102 |
* just after its update by the current column. This allows to bring the
|
103 |
* current column only once through cache at each step. The current
|
104 |
* implementation does not perform any blocking for this sequence of
|
105 |
* BLAS operations, however the design allows for plugging in an optimal
|
106 |
* (machine-specific) specialized BLAS-like kernel. This idea has been
|
107 |
* suggested to us by Fred Gustavson, IBM T.J. Watson Research Center.
|
108 |
*
|
109 |
* Arguments
|
110 |
* =========
|
111 |
*
|
112 |
* PANEL (local input/output) HPL_T_panel *
|
113 |
* On entry, PANEL points to the data structure containing the
|
114 |
* panel information.
|
115 |
*
|
116 |
* M (local input) const int
|
117 |
* On entry, M specifies the local number of rows of sub(A).
|
118 |
*
|
119 |
* N (local input) const int
|
120 |
* On entry, N specifies the local number of columns of sub(A).
|
121 |
*
|
122 |
* ICOFF (global input) const int
|
123 |
* On entry, ICOFF specifies the row and column offset of sub(A)
|
124 |
* in A.
|
125 |
*
|
126 |
* WORK (local workspace) double *
|
127 |
* On entry, WORK is a workarray of size at least 2*(4+2*N0).
|
128 |
*
|
129 |
* ---------------------------------------------------------------------
|
130 |
*/
|
131 |
/*
|
132 |
* .. Local Variables ..
|
133 |
*/
|
134 |
double * A, * Acur, * Anxt;
|
135 |
#ifdef HPL_CALL_VSIPL
|
136 |
vsip_mview_d * Av0, * Av1, * Xv1, * Yv0, * Yv1; |
137 |
#endif
|
138 |
int Mm1, Nm1, curr, ii, iip1, jj, lda, m=M;
|
139 |
/* ..
|
140 |
* .. Executable Statements ..
|
141 |
*/
|
142 |
#ifdef HPL_DETAILED_TIMING
|
143 |
HPL_ptimer( HPL_TIMING_PFACT ); |
144 |
#endif
|
145 |
A = PANEL->A; lda = PANEL->lda; |
146 |
curr = (int)( PANEL->grid->myrow == PANEL->prow );
|
147 |
|
148 |
Nm1 = N - 1; jj = ICOFF;
|
149 |
if( curr != 0 ) { ii = ICOFF; iip1 = ii+1; Mm1 = m-1; } |
150 |
else { ii = 0; iip1 = ii; Mm1 = m; } |
151 |
#ifdef HPL_CALL_VSIPL
|
152 |
/*
|
153 |
* Admit the blocks
|
154 |
*/
|
155 |
(void) vsip_blockadmit_d( PANEL->Ablock, VSIP_TRUE );
|
156 |
(void) vsip_blockadmit_d( PANEL->L1block, VSIP_TRUE );
|
157 |
/*
|
158 |
* Create the matrix views
|
159 |
*/
|
160 |
Av0 = vsip_mbind_d( PANEL->Ablock, 0, 1, lda, lda, PANEL->pmat->nq ); |
161 |
Yv0 = vsip_mbind_d( PANEL->L1block, 0, 1, PANEL->jb, PANEL->jb, PANEL->jb ); |
162 |
#endif
|
163 |
/*
|
164 |
* Find local absolute value max in first column - initialize WORK[0:3]
|
165 |
*/
|
166 |
HPL_dlocmax( PANEL, m, ii, jj, WORK ); |
167 |
|
168 |
while( Nm1 >= 1 ) |
169 |
{ |
170 |
Acur = Mptr( A, iip1, jj, lda ); Anxt = Mptr( Acur, 0, 1, lda ); |
171 |
/*
|
172 |
* Swap and broadcast the current row
|
173 |
*/
|
174 |
HPL_pdmxswp( PANEL, m, ii, jj, WORK ); |
175 |
HPL_dlocswpN( PANEL, ii, jj, WORK ); |
176 |
/*
|
177 |
* Scale current column by its absolute value max entry - Update trai-
|
178 |
* ling sub-matrix and find local absolute value max in next column (On-
|
179 |
* ly one pass through cache for each current column). This sequence of
|
180 |
* operations could benefit from a specialized blocked implementation.
|
181 |
*/
|
182 |
if( WORK[0] != HPL_rzero ) |
183 |
HPL_dscal( Mm1, HPL_rone / WORK[0], Acur, 1 ); |
184 |
HPL_daxpy( Mm1, -WORK[4+jj+1], Acur, 1, Anxt, 1 ); |
185 |
HPL_dlocmax( PANEL, Mm1, iip1, jj+1, WORK );
|
186 |
#ifdef HPL_CALL_VSIPL
|
187 |
if( Nm1 > 1 ) |
188 |
{ |
189 |
/*
|
190 |
* Create the matrix subviews
|
191 |
*/
|
192 |
Av1 = vsip_msubview_d( Av0, PANEL->ii+iip1, PANEL->jj+jj+2,
|
193 |
Mm1, Nm1-1 );
|
194 |
Xv1 = vsip_msubview_d( Av0, PANEL->ii+iip1, PANEL->jj+jj, |
195 |
Mm1, 1 );
|
196 |
Yv1 = vsip_msubview_d( Yv0, jj, jj+2, 1, Nm1-1 ); |
197 |
|
198 |
vsip_gemp_d( -HPL_rone, Xv1, VSIP_MAT_NTRANS, Yv1, VSIP_MAT_NTRANS, |
199 |
HPL_rone, Av1 ); |
200 |
/*
|
201 |
* Destroy the matrix subviews
|
202 |
*/
|
203 |
(void) vsip_mdestroy_d( Yv1 );
|
204 |
(void) vsip_mdestroy_d( Xv1 );
|
205 |
(void) vsip_mdestroy_d( Av1 );
|
206 |
} |
207 |
#else
|
208 |
if( Nm1 > 1 ) |
209 |
HPL_dger( HplColumnMajor, Mm1, Nm1-1, -HPL_rone, Acur, 1, |
210 |
WORK+4+jj+2, 1, Mptr( Anxt, 0, 1, lda ), lda ); |
211 |
#endif
|
212 |
/*
|
213 |
* Same thing as above but with worse data access on y (A += x * y^T)
|
214 |
*
|
215 |
* if( Nm1 > 1 ) )
|
216 |
* HPL_dger( HplColumnMajor, Mm1, Nm1-1, -HPL_rone, Acur, 1,
|
217 |
* Mptr( L1, jj, jj+2, n0 ), n0, Mptr( Anxt, 0, 1, lda ),
|
218 |
* lda );
|
219 |
*/
|
220 |
if( curr != 0 ) { ii = iip1; iip1++; m = Mm1; Mm1--; } |
221 |
|
222 |
Nm1--; jj++; |
223 |
} |
224 |
/*
|
225 |
* Swap and broadcast last row - Scale last column by its absolute value
|
226 |
* max entry
|
227 |
*/
|
228 |
HPL_pdmxswp( PANEL, m, ii, jj, WORK ); |
229 |
HPL_dlocswpN( PANEL, ii, jj, WORK ); |
230 |
if( WORK[0] != HPL_rzero ) |
231 |
HPL_dscal( Mm1, HPL_rone / WORK[0], Mptr( A, iip1, jj, lda ), 1 ); |
232 |
#ifdef HPL_CALL_VSIPL
|
233 |
/*
|
234 |
* Release the blocks
|
235 |
*/
|
236 |
(void) vsip_blockrelease_d( vsip_mgetblock_d( Yv0 ), VSIP_TRUE );
|
237 |
(void) vsip_blockrelease_d( vsip_mgetblock_d( Av0 ), VSIP_TRUE );
|
238 |
/*
|
239 |
* Destroy the matrix views
|
240 |
*/
|
241 |
(void) vsip_mdestroy_d( Yv0 );
|
242 |
(void) vsip_mdestroy_d( Av0 );
|
243 |
#endif
|
244 |
#ifdef HPL_DETAILED_TIMING
|
245 |
HPL_ptimer( HPL_TIMING_PFACT ); |
246 |
#endif
|
247 |
/*
|
248 |
* End of HPL_pdpanrlN
|
249 |
*/
|
250 |
} |