1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin. */
3 /* All rights reserved. */
5 /* Redistribution and use in source and binary forms, with or */
6 /* without modification, are permitted provided that the following */
7 /* conditions are met: */
9 /* 1. Redistributions of source code must retain the above */
10 /* copyright notice, this list of conditions and the following */
13 /* 2. Redistributions in binary form must reproduce the above */
14 /* copyright notice, this list of conditions and the following */
15 /* disclaimer in the documentation and/or other materials */
16 /* provided with the distribution. */
18 /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
19 /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
20 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
21 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
23 /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
24 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
25 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
26 /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
27 /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
28 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
29 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
30 /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
31 /* POSSIBILITY OF SUCH DAMAGE. */
33 /* The views and conclusions contained in the software and */
34 /* documentation are those of the authors and should not be */
35 /* interpreted as representing official policies, either expressed */
36 /* or implied, of The University of Texas at Austin. */
37 /*********************************************************************/
41 #ifdef FUNCTION_PROFILE
42 #include "functable.h"
54 #define ERROR_NAME "XGERU "
56 #define ERROR_NAME "XGERC "
60 #define ERROR_NAME "ZGERU "
62 #define ERROR_NAME "ZGERC "
66 #define ERROR_NAME "CGERU "
68 #define ERROR_NAME "CGERC "
75 #define GER_THREAD xger_thread_U
78 #define GER_THREAD xger_thread_C
80 #define GERV_THREAD xger_thread_V
85 #define GER_THREAD zger_thread_U
88 #define GER_THREAD zger_thread_C
90 #define GERV_THREAD zger_thread_V
95 #define GER_THREAD cger_thread_U
98 #define GER_THREAD cger_thread_C
100 #define GERV_THREAD cger_thread_V
106 void NAME(blasint *M, blasint *N, FLOAT *Alpha,
107 FLOAT *x, blasint *INCX,
108 FLOAT *y, blasint *INCY,
109 FLOAT *a, blasint *LDA){
113 FLOAT alpha_r = Alpha[0];
114 FLOAT alpha_i = Alpha[1];
115 blasint incx = *INCX;
116 blasint incy = *INCY;
129 if (lda < MAX(1,m)) info = 9;
130 if (incy == 0) info = 7;
131 if (incx == 0) info = 5;
136 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
142 void CNAME(enum CBLAS_ORDER order,
143 blasint m, blasint n,
145 void *vx, blasint incx,
146 void *vy, blasint incy,
147 void *va, blasint lda) {
149 FLOAT* Alpha = (FLOAT*) VAlpha;
150 FLOAT* a = (FLOAT*) va;
151 FLOAT* x = (FLOAT*) vx;
152 FLOAT* y = (FLOAT*) vy;
154 FLOAT alpha_r = Alpha[0];
155 FLOAT alpha_i = Alpha[1];
167 if (order == CblasColMajor) {
170 if (lda < MAX(1,m)) info = 9;
171 if (incy == 0) info = 7;
172 if (incx == 0) info = 5;
177 if (order == CblasRowMajor) {
192 if (lda < MAX(1,m)) info = 9;
193 if (incy == 0) info = 7;
194 if (incx == 0) info = 5;
200 BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
206 /* Quick return if possible. */
207 if (m == 0 || n == 0) return;
209 if ((alpha_r == 0.) && (alpha_i == 0.)) return;
213 FUNCTION_PROFILE_START();
215 if (incy < 0) y -= (n - 1) * incy * 2;
216 if (incx < 0) x -= (m - 1) * incx * 2;
218 STACK_ALLOC(2 * m, FLOAT, buffer);
221 // Threshold chosen so that speed-up is > 1 on a Xeon E5-2630
222 if(1L * m * n > 36L * sizeof(FLOAT) * sizeof(FLOAT) * GEMM_MULTITHREAD_THRESHOLD)
223 nthreads = num_cpu_avail(2);
230 #if !defined(CBLAS) || !defined(CONJ)
231 GER(m, n, 0, alpha_r, alpha_i, x, incx, y, incy, a, lda, buffer);
233 if (order == CblasColMajor) {
234 GER(m, n, 0, alpha_r, alpha_i, x, incx, y, incy, a, lda, buffer);
236 GERV(m, n, 0, alpha_r, alpha_i, x, incx, y, incy, a, lda, buffer);
244 #if !defined(CBLAS) || !defined(CONJ)
245 GER_THREAD(m, n, Alpha, x, incx, y, incy, a, lda, buffer, nthreads);
247 if (order == CblasColMajor) {
248 GER_THREAD(m, n, Alpha, x, incx, y, incy, a, lda, buffer, nthreads);
250 GERV_THREAD(m, n, Alpha, x, incx, y, incy, a, lda, buffer, nthreads);
259 FUNCTION_PROFILE_END(4, m * n + m + n, 2 * m * n);