Statistiques
| Révision :

root / src / blas / HPL_dger.c @ 9

Historique | Voir | Annoter | Télécharger (8,45 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_VSIPL
148
   register double           t0;
149
   int                       i, iaij, ix, iy, j, jaj, jx, jy;
150

    
151
   if( ( M == 0 ) || ( N == 0 ) || ( ALPHA == HPL_rzero ) ) return;
152
 
153
   if( ORDER == HplColumnMajor )
154
   {
155
      for( j = 0, jaj = 0, jy = 0; j < N; j++, jaj += LDA, jy += INCY )
156
      {
157
         t0 = ALPHA * Y[jy];
158
         for( i = 0, iaij = jaj, ix = 0; i < M; i++, iaij += 1, ix += INCX )
159
         { A[iaij] += X[ix] * t0; }
160
      }
161
   }
162
   else
163
   {
164
      for( j = 0, jaj = 0, jx = 0; j < M; j++, jaj += LDA, jx += INCX )
165
      {
166
         t0 = ALPHA * X[jx];
167
         for( i = 0, iaij = jaj, iy = 0; i < N; i++, iaij += 1, iy += INCY )
168
         { A[iaij] += Y[iy] * t0; }
169
      }
170
   }
171
#endif
172

    
173
#ifdef HPL_CALL_FBLAS
174
   double                    alpha = ALPHA;
175
#ifdef HPL_USE_F77_INTEGER_DEF
176
   const F77_INTEGER         F77M    = M,   F77N    = N,
177
                             F77lda  = LDA, F77incx = INCX, F77incy = INCY;
178
#else
179
#define F77M                 M
180
#define F77N                 N
181
#define F77lda               LDA
182
#define F77incx              INCX
183
#define F77incy              INCY
184
#endif
185

    
186
   if( ORDER == HplColumnMajor )
187
   {  F77dger( &F77M, &F77N, &alpha, X, &F77incx, Y, &F77incy, A, &F77lda ); }
188
   else
189
   {  F77dger( &F77N, &F77M, &alpha, Y, &F77incy, X, &F77incx, A, &F77lda ); }
190
#endif
191

    
192
#ifdef HPL_CALL_CUBLAS
193
   double                    alpha = ALPHA;
194

    
195
#define CUBLASM                 M
196
#define CUBLASN                 N
197
#define CUBLASlda               LDA
198
#define CUBLASincx              INCX
199
#define CUBLASincy              INCY
200

    
201
   if( ORDER == HplColumnMajor )
202
   {  
203
     CUBLAS_DGER( &CUBLASM, &CUBLASN, &alpha, 
204
                  X, &CUBLASincx, Y, &CUBLASincy, A, &CUBLASlda ); 
205
   }
206
   else
207
   {  
208
     CUBLAS_DGER( &CUBLASN, &CUBLASM, &alpha, 
209
                  Y, &CUBLASincy, X, &CUBLASincx, A, &CUBLASlda ); }
210
#endif
211
/*
212
 * End of HPL_dger
213
 */
214
}
215

    
216
#endif