root / src / blas / HPL_dger.c
Historique | Voir | Annoter | Télécharger (9,01 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 |
#ifndef HPL_dger
|
53 |
|
54 |
#ifdef STDC_HEADERS
|
55 |
void HPL_dger
|
56 |
( |
57 |
const enum HPL_ORDER ORDER, |
58 |
const int M, |
59 |
const int N, |
60 |
const double ALPHA, |
61 |
const double * X, |
62 |
const int INCX, |
63 |
double * Y,
|
64 |
const int INCY, |
65 |
double * A,
|
66 |
const int LDA |
67 |
) |
68 |
#else
|
69 |
void HPL_dger
|
70 |
( ORDER, M, N, ALPHA, X, INCX, Y, INCY, A, LDA ) |
71 |
const enum HPL_ORDER ORDER; |
72 |
const int M; |
73 |
const int N; |
74 |
const double ALPHA; |
75 |
const double * X; |
76 |
const int INCX; |
77 |
double * Y;
|
78 |
const int INCY; |
79 |
double * A;
|
80 |
const int LDA; |
81 |
#endif
|
82 |
{ |
83 |
/*
|
84 |
* Purpose
|
85 |
* =======
|
86 |
*
|
87 |
* HPL_dger performs the rank 1 operation
|
88 |
*
|
89 |
* A := alpha * x * y^T + A,
|
90 |
*
|
91 |
* where alpha is a scalar, x is an m-element vector, y is an n-element
|
92 |
* vector and A is an m by n matrix.
|
93 |
*
|
94 |
* Arguments
|
95 |
* =========
|
96 |
*
|
97 |
* ORDER (local input) const enum HPL_ORDER
|
98 |
* On entry, ORDER specifies the storage format of the operands
|
99 |
* as follows:
|
100 |
* ORDER = HplRowMajor,
|
101 |
* ORDER = HplColumnMajor.
|
102 |
*
|
103 |
* M (local input) const int
|
104 |
* On entry, M specifies the number of rows of the matrix A.
|
105 |
* M must be at least zero.
|
106 |
*
|
107 |
* N (local input) const int
|
108 |
* On entry, N specifies the number of columns of the matrix A.
|
109 |
* N must be at least zero.
|
110 |
*
|
111 |
* ALPHA (local input) const double
|
112 |
* On entry, ALPHA specifies the scalar alpha. When ALPHA is
|
113 |
* supplied as zero then X and Y need not be set on input.
|
114 |
*
|
115 |
* X (local input) const double *
|
116 |
* On entry, X is an incremented array of dimension at least
|
117 |
* ( 1 + ( m - 1 ) * abs( INCX ) ) that contains the vector x.
|
118 |
*
|
119 |
* INCX (local input) const int
|
120 |
* On entry, INCX specifies the increment for the elements of X.
|
121 |
* INCX must not be zero.
|
122 |
*
|
123 |
* Y (local input) double *
|
124 |
* On entry, Y is an incremented array of dimension at least
|
125 |
* ( 1 + ( n - 1 ) * abs( INCY ) ) that contains the vector y.
|
126 |
*
|
127 |
* INCY (local input) const int
|
128 |
* On entry, INCY specifies the increment for the elements of Y.
|
129 |
* INCY must not be zero.
|
130 |
*
|
131 |
* A (local input/output) double *
|
132 |
* On entry, A points to an array of size equal to or greater
|
133 |
* than LDA * n. Before entry, the leading m by n part of the
|
134 |
* array A must contain the matrix coefficients. On exit, A is
|
135 |
* overwritten by the updated matrix.
|
136 |
*
|
137 |
* LDA (local input) const int
|
138 |
* On entry, LDA specifies the leading dimension of A as
|
139 |
* declared in the calling (sub) program. LDA must be at
|
140 |
* least MAX(1,m).
|
141 |
*
|
142 |
* ---------------------------------------------------------------------
|
143 |
*/
|
144 |
#ifdef HPL_CALL_CBLAS
|
145 |
cblas_dger( ORDER, M, N, ALPHA, X, INCX, Y, INCY, A, LDA ); |
146 |
#endif
|
147 |
#ifdef HPL_CALL_GSLCBLAS
|
148 |
cblas_dger( ORDER, M, N, ALPHA, X, INCX, Y, INCY, A, LDA ); |
149 |
#endif
|
150 |
#ifdef HPL_CALL_VSIPL
|
151 |
register double t0; |
152 |
int i, iaij, ix, iy, j, jaj, jx, jy;
|
153 |
|
154 |
if( ( M == 0 ) || ( N == 0 ) || ( ALPHA == HPL_rzero ) ) return; |
155 |
|
156 |
if( ORDER == HplColumnMajor )
|
157 |
{ |
158 |
for( j = 0, jaj = 0, jy = 0; j < N; j++, jaj += LDA, jy += INCY ) |
159 |
{ |
160 |
t0 = ALPHA * Y[jy]; |
161 |
for( i = 0, iaij = jaj, ix = 0; i < M; i++, iaij += 1, ix += INCX ) |
162 |
{ A[iaij] += X[ix] * t0; } |
163 |
} |
164 |
} |
165 |
else
|
166 |
{ |
167 |
for( j = 0, jaj = 0, jx = 0; j < M; j++, jaj += LDA, jx += INCX ) |
168 |
{ |
169 |
t0 = ALPHA * X[jx]; |
170 |
for( i = 0, iaij = jaj, iy = 0; i < N; i++, iaij += 1, iy += INCY ) |
171 |
{ A[iaij] += Y[iy] * t0; } |
172 |
} |
173 |
} |
174 |
#endif
|
175 |
|
176 |
#ifdef HPL_CALL_FBLAS
|
177 |
double alpha = ALPHA;
|
178 |
#ifdef HPL_USE_F77_INTEGER_DEF
|
179 |
const F77_INTEGER F77M = M, F77N = N,
|
180 |
F77lda = LDA, F77incx = INCX, F77incy = INCY; |
181 |
#else
|
182 |
#define F77M M
|
183 |
#define F77N N
|
184 |
#define F77lda LDA
|
185 |
#define F77incx INCX
|
186 |
#define F77incy INCY
|
187 |
#endif
|
188 |
|
189 |
if( ORDER == HplColumnMajor )
|
190 |
{ F77dger( &F77M, &F77N, &alpha, X, &F77incx, Y, &F77incy, A, &F77lda ); } |
191 |
else
|
192 |
{ F77dger( &F77N, &F77M, &alpha, Y, &F77incy, X, &F77incx, A, &F77lda ); } |
193 |
#endif
|
194 |
|
195 |
#ifdef HPL_CALL_CUBLAS
|
196 |
double alpha = ALPHA;
|
197 |
|
198 |
#define CUBLASM M
|
199 |
#define CUBLASN N
|
200 |
#define CUBLASlda LDA
|
201 |
#define CUBLASincx INCX
|
202 |
#define CUBLASincy INCY
|
203 |
|
204 |
if( ORDER == HplColumnMajor )
|
205 |
{ |
206 |
CUBLAS_DGER( &CUBLASM, &CUBLASN, &alpha, |
207 |
X, &CUBLASincx, Y, &CUBLASincy, A, &CUBLASlda ); |
208 |
} |
209 |
else
|
210 |
{ |
211 |
CUBLAS_DGER( &CUBLASN, &CUBLASM, &alpha, |
212 |
Y, &CUBLASincy, X, &CUBLASincx, A, &CUBLASlda ); } |
213 |
#endif
|
214 |
|
215 |
#ifdef HPL_CALL_ACML
|
216 |
double alpha = ALPHA;
|
217 |
|
218 |
#define ACMLM M
|
219 |
#define ACMLN N
|
220 |
#define ACMLlda LDA
|
221 |
#define ACMLincx INCX
|
222 |
#define ACMLincy INCY
|
223 |
|
224 |
if( ORDER == HplColumnMajor )
|
225 |
{ |
226 |
dger_( &ACMLM, &ACMLN, &alpha, |
227 |
X, &ACMLincx, Y, &ACMLincy, A, &ACMLlda ); |
228 |
} |
229 |
else
|
230 |
{ |
231 |
dger_( &ACMLN, &ACMLM, &alpha, |
232 |
Y, &ACMLincy, X, &ACMLincx, A, &ACMLlda ); } |
233 |
#endif
|
234 |
/*
|
235 |
* End of HPL_dger
|
236 |
*/
|
237 |
} |
238 |
|
239 |
#endif
|