1 /*********************************************************************/
2 /*                                                                   */
3 /*             Optimized BLAS libraries                              */
4 /*                     By Kazushige Goto <kgoto@tacc.utexas.edu>     */
5 /*                                                                   */
6 /* Copyright (c) The University of Texas, 2009. All rights reserved. */
7 /* UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING  */
8 /* THIS SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF      */
9 /* MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE,              */
10 /* NON-INFRINGEMENT AND WARRANTIES OF PERFORMANCE, AND ANY WARRANTY  */
11 /* THAT MIGHT OTHERWISE ARISE FROM COURSE OF DEALING OR USAGE OF     */
12 /* TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH RESPECT TO   */
13 /* THE USE OF THE SOFTWARE OR DOCUMENTATION.                         */
14 /* Under no circumstances shall University be liable for incidental, */
15 /* special, indirect, direct or consequential damages or loss of     */
16 /* profits, interruption of business, or related expenses which may  */
17 /* arise from use of Software or Documentation, including but not    */
18 /* limited to those resulting from defects in Software and/or        */
19 /* Documentation, or loss or inaccuracy of data of any kind.         */
20 /*********************************************************************/
21 
22 #include <stdio.h>
23 #include "common.h"
24 #ifdef FUNCTION_PROFILE
25 #include "functable.h"
26 #endif
27 
28 #ifndef CBLAS
29 
NAME(blasint * N,FLOAT * ALPHA,FLOAT * x,blasint * INCX)30 void NAME(blasint *N, FLOAT *ALPHA, FLOAT *x, blasint *INCX){
31 
32   blasint n    = *N;
33   blasint incx = *INCX;
34   FLOAT alpha = *ALPHA;
35 
36 #else
37 
38 void CNAME(blasint n, FLOAT alpha, FLOAT *x, blasint incx){
39 
40 #endif
41 
42 #ifdef SMP
43   int mode, nthreads;
44 #endif
45 
46 #ifndef CBLAS
47   PRINT_DEBUG_NAME;
48 #else
49   PRINT_DEBUG_CNAME;
50 #endif
51 
52   if (incx <= 0 || n <= 0) return;
53 
54   if (alpha == ONE) return;
55 
56   IDEBUG_START;
57 
58   FUNCTION_PROFILE_START();
59 
60 
61 #ifdef SMP
62   nthreads = num_cpu_avail(1);
63 
64   if (nthreads == 1) {
65 #endif
66 
67   SCAL_K(n, 0, 0, alpha, x, incx, NULL, 0, NULL, 0);
68 
69 #ifdef SMP
70   } else {
71 
72 #ifdef DOUBLE
73     mode  =  BLAS_DOUBLE | BLAS_REAL;
74 #else
75     mode  =  BLAS_SINGLE | BLAS_REAL;
76 #endif
77 
78     blas_level1_thread(mode, n, 0, 0,
79 #ifndef CBLAS
80 		       ALPHA,
81 #else
82 		       &alpha,
83 #endif
84 		       x, incx, NULL, 0, NULL, 0, (void *)SCAL_K, nthreads);
85 
86   }
87 #endif
88 
89   FUNCTION_PROFILE_END(1, n, n);
90 
91   IDEBUG_END;
92 
93   return;
94 
95 }
96