You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sgemv_t_4.c 15 kB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /***************************************************************************
  2. Copyright (c) 2014, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *****************************************************************************/
  27. #include "common.h"
  28. #if (defined(__GNUC__) && __GNUC__ > 11)
  29. #pragma GCC optimize("no-tree-vectorize")
  30. #endif
  31. #if defined(NEHALEM)
  32. #include "sgemv_t_microk_nehalem-4.c"
  33. #elif defined(BULLDOZER) || defined(PILEDRIVER) || defined(STEAMROLLER) || defined(EXCAVATOR)
  34. #include "sgemv_t_microk_bulldozer-4.c"
  35. #elif defined(SANDYBRIDGE)
  36. #include "sgemv_t_microk_sandy-4.c"
  37. #elif defined(HASWELL) || defined(ZEN)
  38. #include "sgemv_t_microk_haswell-4.c"
  39. #elif defined (SKYLAKEX) || defined (COOPERLAKE) || defined (SAPPHIRERAPIDS)
  40. #include "sgemv_t_microk_haswell-4.c"
  41. #include "sgemv_t_microk_skylakex.c"
  42. #endif
  43. #if defined(STEAMROLLER) || defined(EXCAVATOR)
  44. #define NBMAX 2048
  45. #else
  46. #define NBMAX 4096
  47. #endif
  48. #ifndef HAVE_KERNEL_4x4
  49. static void sgemv_kernel_4x4(BLASLONG n, FLOAT **ap, FLOAT *x, FLOAT *y)
  50. {
  51. BLASLONG i;
  52. FLOAT *a0,*a1,*a2,*a3;
  53. a0 = ap[0];
  54. a1 = ap[1];
  55. a2 = ap[2];
  56. a3 = ap[3];
  57. FLOAT temp0 = 0.0;
  58. FLOAT temp1 = 0.0;
  59. FLOAT temp2 = 0.0;
  60. FLOAT temp3 = 0.0;
  61. for ( i=0; i< n; i+=4 )
  62. {
  63. temp0 += a0[i]*x[i] + a0[i+1]*x[i+1] + a0[i+2]*x[i+2] + a0[i+3]*x[i+3];
  64. temp1 += a1[i]*x[i] + a1[i+1]*x[i+1] + a1[i+2]*x[i+2] + a1[i+3]*x[i+3];
  65. temp2 += a2[i]*x[i] + a2[i+1]*x[i+1] + a2[i+2]*x[i+2] + a2[i+3]*x[i+3];
  66. temp3 += a3[i]*x[i] + a3[i+1]*x[i+1] + a3[i+2]*x[i+2] + a3[i+3]*x[i+3];
  67. }
  68. y[0] = temp0;
  69. y[1] = temp1;
  70. y[2] = temp2;
  71. y[3] = temp3;
  72. }
  73. #endif
  74. static void sgemv_kernel_4x2(BLASLONG n, FLOAT *ap0, FLOAT *ap1, FLOAT *x, FLOAT *y) __attribute__ ((noinline));
  75. static void sgemv_kernel_4x2(BLASLONG n, FLOAT *ap0, FLOAT *ap1, FLOAT *x, FLOAT *y)
  76. {
  77. BLASLONG i;
  78. i=0;
  79. __asm__ __volatile__
  80. (
  81. "xorps %%xmm10 , %%xmm10 \n\t"
  82. "xorps %%xmm11 , %%xmm11 \n\t"
  83. "testq $4 , %1 \n\t"
  84. "jz 2f \n\t"
  85. "movups (%5,%0,4) , %%xmm14 \n\t" // x
  86. "movups (%3,%0,4) , %%xmm12 \n\t" // ap0
  87. "movups (%4,%0,4) , %%xmm13 \n\t" // ap1
  88. "mulps %%xmm14 , %%xmm12 \n\t"
  89. "mulps %%xmm14 , %%xmm13 \n\t"
  90. "addq $4 , %0 \n\t"
  91. "addps %%xmm12 , %%xmm10 \n\t"
  92. "subq $4 , %1 \n\t"
  93. "addps %%xmm13 , %%xmm11 \n\t"
  94. "2: \n\t"
  95. "cmpq $0, %1 \n\t"
  96. "je 3f \n\t"
  97. // ".align 16 \n\t"
  98. "1: \n\t"
  99. "movups (%5,%0,4) , %%xmm14 \n\t" // x
  100. "movups (%3,%0,4) , %%xmm12 \n\t" // ap0
  101. "movups (%4,%0,4) , %%xmm13 \n\t" // ap1
  102. "mulps %%xmm14 , %%xmm12 \n\t"
  103. "mulps %%xmm14 , %%xmm13 \n\t"
  104. "addps %%xmm12 , %%xmm10 \n\t"
  105. "addps %%xmm13 , %%xmm11 \n\t"
  106. "movups 16(%5,%0,4) , %%xmm14 \n\t" // x
  107. "movups 16(%3,%0,4) , %%xmm12 \n\t" // ap0
  108. "movups 16(%4,%0,4) , %%xmm13 \n\t" // ap1
  109. "mulps %%xmm14 , %%xmm12 \n\t"
  110. "mulps %%xmm14 , %%xmm13 \n\t"
  111. "addps %%xmm12 , %%xmm10 \n\t"
  112. "addps %%xmm13 , %%xmm11 \n\t"
  113. "addq $8 , %0 \n\t"
  114. "subq $8 , %1 \n\t"
  115. "jnz 1b \n\t"
  116. "3: \n\t"
  117. "haddps %%xmm10, %%xmm10 \n\t"
  118. "haddps %%xmm11, %%xmm11 \n\t"
  119. "haddps %%xmm10, %%xmm10 \n\t"
  120. "haddps %%xmm11, %%xmm11 \n\t"
  121. "movss %%xmm10, (%2) \n\t"
  122. "movss %%xmm11,4(%2) \n\t"
  123. :
  124. "+r" (i), // 0
  125. "+r" (n) // 1
  126. :
  127. "r" (y), // 2
  128. "r" (ap0), // 3
  129. "r" (ap1), // 4
  130. "r" (x) // 5
  131. : "cc",
  132. "%xmm4", "%xmm5", "%xmm10", "%xmm11",
  133. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  134. "memory"
  135. );
  136. }
  137. static void sgemv_kernel_4x1(BLASLONG n, FLOAT *ap, FLOAT *x, FLOAT *y) __attribute__ ((noinline));
  138. static void sgemv_kernel_4x1(BLASLONG n, FLOAT *ap, FLOAT *x, FLOAT *y)
  139. {
  140. BLASLONG i;
  141. i=0;
  142. __asm__ __volatile__
  143. (
  144. "xorps %%xmm9 , %%xmm9 \n\t"
  145. "xorps %%xmm10 , %%xmm10 \n\t"
  146. "testq $4 , %1 \n\t"
  147. "jz 2f \n\t"
  148. "movups (%3,%0,4) , %%xmm12 \n\t"
  149. "movups (%4,%0,4) , %%xmm11 \n\t"
  150. "mulps %%xmm11 , %%xmm12 \n\t"
  151. "addq $4 , %0 \n\t"
  152. "addps %%xmm12 , %%xmm10 \n\t"
  153. "subq $4 , %1 \n\t"
  154. "2: \n\t"
  155. "cmpq $0, %1 \n\t"
  156. "je 3f \n\t"
  157. // ".align 16 \n\t"
  158. "1: \n\t"
  159. "movups (%3,%0,4) , %%xmm12 \n\t"
  160. "movups 16(%3,%0,4) , %%xmm14 \n\t"
  161. "movups (%4,%0,4) , %%xmm11 \n\t"
  162. "movups 16(%4,%0,4) , %%xmm13 \n\t"
  163. "mulps %%xmm11 , %%xmm12 \n\t"
  164. "mulps %%xmm13 , %%xmm14 \n\t"
  165. "addq $8 , %0 \n\t"
  166. "addps %%xmm12 , %%xmm10 \n\t"
  167. "subq $8 , %1 \n\t"
  168. "addps %%xmm14 , %%xmm9 \n\t"
  169. "jnz 1b \n\t"
  170. "3: \n\t"
  171. "addps %%xmm9 , %%xmm10 \n\t"
  172. "haddps %%xmm10, %%xmm10 \n\t"
  173. "haddps %%xmm10, %%xmm10 \n\t"
  174. "movss %%xmm10, (%2) \n\t"
  175. :
  176. "+r" (i), // 0
  177. "+r" (n) // 1
  178. :
  179. "r" (y), // 2
  180. "r" (ap), // 3
  181. "r" (x) // 4
  182. : "cc",
  183. "%xmm9", "%xmm10" ,
  184. "%xmm11", "%xmm12", "%xmm13", "%xmm14",
  185. "memory"
  186. );
  187. }
  188. static void copy_x(BLASLONG n, FLOAT *src, FLOAT *dest, BLASLONG inc_src)
  189. {
  190. BLASLONG i;
  191. for ( i=0; i<n; i++ )
  192. {
  193. *dest = *src;
  194. dest++;
  195. src += inc_src;
  196. }
  197. }
  198. static void add_y(BLASLONG n, FLOAT da , FLOAT *src, FLOAT *dest, BLASLONG inc_dest) __attribute__ ((noinline));
  199. static void add_y(BLASLONG n, FLOAT da , FLOAT *src, FLOAT *dest, BLASLONG inc_dest)
  200. {
  201. BLASLONG i;
  202. if ( inc_dest != 1 )
  203. {
  204. for ( i=0; i<n; i++ )
  205. {
  206. *dest += src[i] * da;
  207. dest += inc_dest;
  208. }
  209. return;
  210. }
  211. i=0;
  212. __asm__ __volatile__
  213. (
  214. "movss (%2) , %%xmm10 \n\t"
  215. "shufps $0 , %%xmm10 , %%xmm10 \n\t"
  216. // ".align 16 \n\t"
  217. "1: \n\t"
  218. "movups (%3,%0,4) , %%xmm12 \n\t"
  219. "movups (%4,%0,4) , %%xmm11 \n\t"
  220. "mulps %%xmm10 , %%xmm12 \n\t"
  221. "addq $4 , %0 \n\t"
  222. "addps %%xmm12 , %%xmm11 \n\t"
  223. "subq $4 , %1 \n\t"
  224. "movups %%xmm11, -16(%4,%0,4) \n\t"
  225. "jnz 1b \n\t"
  226. :
  227. "+r" (i), // 0
  228. "+r" (n) // 1
  229. :
  230. "r" (&da), // 2
  231. "r" (src), // 3
  232. "r" (dest) // 4
  233. : "cc",
  234. "%xmm10", "%xmm11", "%xmm12",
  235. "memory"
  236. );
  237. }
  238. int CNAME(BLASLONG m, BLASLONG n, BLASLONG dummy1, FLOAT alpha, FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG inc_x, FLOAT *y, BLASLONG inc_y, FLOAT *buffer)
  239. {
  240. BLASLONG register i;
  241. BLASLONG register j;
  242. FLOAT *a_ptr;
  243. FLOAT *x_ptr;
  244. FLOAT *y_ptr;
  245. BLASLONG n0;
  246. BLASLONG n1;
  247. BLASLONG m1;
  248. BLASLONG m2;
  249. BLASLONG m3;
  250. BLASLONG n2;
  251. FLOAT ybuffer[4],*xbuffer;
  252. FLOAT *ytemp;
  253. if ( m < 1 ) return(0);
  254. if ( n < 1 ) return(0);
  255. #ifdef HAVE_SGEMV_T_SKYLAKE_KERNEL
  256. if (lda == m && n <= 16384 && m <= 8)
  257. {
  258. FLOAT * xbuffer_align = x;
  259. FLOAT * ybuffer_align = y;
  260. if (inc_x != 1) {
  261. xbuffer_align = buffer;
  262. for(BLASLONG i=0; i<m; i++) {
  263. xbuffer_align[i] = x[i*inc_x];
  264. }
  265. }
  266. if (inc_y != 1) {
  267. ybuffer_align = buffer + m;
  268. for(BLASLONG i=0; i<n; i++) {
  269. ybuffer_align[i] = y[i*inc_y];
  270. }
  271. }
  272. sgemv_kernel_t(m, n , alpha, a, xbuffer_align, ybuffer_align);
  273. if(inc_y != 1) {
  274. for(BLASLONG i=0; i<n; i++) {
  275. y[i*inc_y] = ybuffer_align[i];
  276. }
  277. }
  278. return(0);
  279. }
  280. #endif
  281. xbuffer = buffer;
  282. ytemp = buffer + (m < NBMAX ? m : NBMAX);
  283. n0 = n / NBMAX;
  284. n1 = (n % NBMAX) >> 2 ;
  285. n2 = n & 3 ;
  286. m3 = m & 3 ;
  287. m1 = m & -4 ;
  288. m2 = (m & (NBMAX-1)) - m3 ;
  289. BLASLONG NB = NBMAX;
  290. while ( NB == NBMAX )
  291. {
  292. m1 -= NB;
  293. if ( m1 < 0)
  294. {
  295. if ( m2 == 0 ) break;
  296. NB = m2;
  297. }
  298. y_ptr = y;
  299. a_ptr = a;
  300. x_ptr = x;
  301. if ( inc_x == 1 )
  302. xbuffer = x_ptr;
  303. else
  304. copy_x(NB,x_ptr,xbuffer,inc_x);
  305. FLOAT *ap[4];
  306. FLOAT *yp;
  307. BLASLONG register lda4 = 4 * lda;
  308. ap[0] = a_ptr;
  309. ap[1] = a_ptr + lda;
  310. ap[2] = ap[1] + lda;
  311. ap[3] = ap[2] + lda;
  312. if ( n0 > 0 )
  313. {
  314. BLASLONG nb1 = NBMAX / 4;
  315. for( j=0; j<n0; j++)
  316. {
  317. yp = ytemp;
  318. for( i = 0; i < nb1 ; i++)
  319. {
  320. sgemv_kernel_4x4(NB,ap,xbuffer,yp);
  321. ap[0] += lda4 ;
  322. ap[1] += lda4 ;
  323. ap[2] += lda4 ;
  324. ap[3] += lda4 ;
  325. yp += 4;
  326. }
  327. add_y(nb1*4, alpha, ytemp, y_ptr, inc_y );
  328. y_ptr += nb1 * inc_y * 4;
  329. a_ptr += nb1 * lda4 ;
  330. }
  331. }
  332. yp = ytemp;
  333. for( i = 0; i < n1 ; i++)
  334. {
  335. sgemv_kernel_4x4(NB,ap,xbuffer,yp);
  336. ap[0] += lda4 ;
  337. ap[1] += lda4 ;
  338. ap[2] += lda4 ;
  339. ap[3] += lda4 ;
  340. yp += 4;
  341. }
  342. if ( n1 > 0 )
  343. {
  344. add_y(n1*4, alpha, ytemp, y_ptr, inc_y );
  345. y_ptr += n1 * inc_y * 4;
  346. a_ptr += n1 * lda4 ;
  347. }
  348. if ( n2 & 2 )
  349. {
  350. sgemv_kernel_4x2(NB,ap[0],ap[1],xbuffer,ybuffer);
  351. a_ptr += lda * 2;
  352. *y_ptr += ybuffer[0] * alpha;
  353. y_ptr += inc_y;
  354. *y_ptr += ybuffer[1] * alpha;
  355. y_ptr += inc_y;
  356. }
  357. if ( n2 & 1 )
  358. {
  359. sgemv_kernel_4x1(NB,a_ptr,xbuffer,ybuffer);
  360. // a_ptr += lda;
  361. *y_ptr += ybuffer[0] * alpha;
  362. // y_ptr += inc_y;
  363. }
  364. a += NB;
  365. x += NB * inc_x;
  366. }
  367. if ( m3 == 0 ) return(0);
  368. x_ptr = x;
  369. a_ptr = a;
  370. if ( m3 == 3 )
  371. {
  372. FLOAT xtemp0 = *x_ptr * alpha;
  373. x_ptr += inc_x;
  374. FLOAT xtemp1 = *x_ptr * alpha;
  375. x_ptr += inc_x;
  376. FLOAT xtemp2 = *x_ptr * alpha;
  377. FLOAT *aj = a_ptr;
  378. y_ptr = y;
  379. if ( lda == 3 && inc_y == 1 )
  380. {
  381. for ( j=0; j< ( n & -4) ; j+=4 )
  382. {
  383. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1 + aj[2] * xtemp2;
  384. y_ptr[j+1] += aj[3] * xtemp0 + aj[4] * xtemp1 + aj[5] * xtemp2;
  385. y_ptr[j+2] += aj[6] * xtemp0 + aj[7] * xtemp1 + aj[8] * xtemp2;
  386. y_ptr[j+3] += aj[9] * xtemp0 + aj[10] * xtemp1 + aj[11] * xtemp2;
  387. aj += 12;
  388. }
  389. for ( ; j<n; j++ )
  390. {
  391. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1 + aj[2] * xtemp2;
  392. aj += 3;
  393. }
  394. }
  395. else
  396. {
  397. if ( inc_y == 1 )
  398. {
  399. BLASLONG register lda2 = lda << 1;
  400. BLASLONG register lda4 = lda << 2;
  401. BLASLONG register lda3 = lda2 + lda;
  402. for ( j=0; j< ( n & -4 ); j+=4 )
  403. {
  404. y_ptr[j] += *aj * xtemp0 + *(aj+1) * xtemp1 + *(aj+2) * xtemp2;
  405. y_ptr[j+1] += *(aj+lda) * xtemp0 + *(aj+lda+1) * xtemp1 + *(aj+lda+2) * xtemp2;
  406. y_ptr[j+2] += *(aj+lda2) * xtemp0 + *(aj+lda2+1) * xtemp1 + *(aj+lda2+2) * xtemp2;
  407. y_ptr[j+3] += *(aj+lda3) * xtemp0 + *(aj+lda3+1) * xtemp1 + *(aj+lda3+2) * xtemp2;
  408. aj += lda4;
  409. }
  410. for ( ; j< n ; j++ )
  411. {
  412. y_ptr[j] += *aj * xtemp0 + *(aj+1) * xtemp1 + *(aj+2) * xtemp2 ;
  413. aj += lda;
  414. }
  415. }
  416. else
  417. {
  418. for ( j=0; j<n; j++ )
  419. {
  420. *y_ptr += *aj * xtemp0 + *(aj+1) * xtemp1 + *(aj+2) * xtemp2;
  421. y_ptr += inc_y;
  422. aj += lda;
  423. }
  424. }
  425. }
  426. return(0);
  427. }
  428. if ( m3 == 2 )
  429. {
  430. FLOAT xtemp0 = *x_ptr * alpha;
  431. x_ptr += inc_x;
  432. FLOAT xtemp1 = *x_ptr * alpha;
  433. FLOAT *aj = a_ptr;
  434. y_ptr = y;
  435. if ( lda == 2 && inc_y == 1 )
  436. {
  437. for ( j=0; j< ( n & -4) ; j+=4 )
  438. {
  439. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1 ;
  440. y_ptr[j+1] += aj[2] * xtemp0 + aj[3] * xtemp1 ;
  441. y_ptr[j+2] += aj[4] * xtemp0 + aj[5] * xtemp1 ;
  442. y_ptr[j+3] += aj[6] * xtemp0 + aj[7] * xtemp1 ;
  443. aj += 8;
  444. }
  445. for ( ; j<n; j++ )
  446. {
  447. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1 ;
  448. aj += 2;
  449. }
  450. }
  451. else
  452. {
  453. if ( inc_y == 1 )
  454. {
  455. BLASLONG register lda2 = lda << 1;
  456. BLASLONG register lda4 = lda << 2;
  457. BLASLONG register lda3 = lda2 + lda;
  458. for ( j=0; j< ( n & -4 ); j+=4 )
  459. {
  460. y_ptr[j] += *aj * xtemp0 + *(aj+1) * xtemp1 ;
  461. y_ptr[j+1] += *(aj+lda) * xtemp0 + *(aj+lda+1) * xtemp1 ;
  462. y_ptr[j+2] += *(aj+lda2) * xtemp0 + *(aj+lda2+1) * xtemp1 ;
  463. y_ptr[j+3] += *(aj+lda3) * xtemp0 + *(aj+lda3+1) * xtemp1 ;
  464. aj += lda4;
  465. }
  466. for ( ; j< n ; j++ )
  467. {
  468. y_ptr[j] += *aj * xtemp0 + *(aj+1) * xtemp1 ;
  469. aj += lda;
  470. }
  471. }
  472. else
  473. {
  474. for ( j=0; j<n; j++ )
  475. {
  476. *y_ptr += *aj * xtemp0 + *(aj+1) * xtemp1 ;
  477. y_ptr += inc_y;
  478. aj += lda;
  479. }
  480. }
  481. }
  482. return(0);
  483. }
  484. FLOAT xtemp = *x_ptr * alpha;
  485. FLOAT *aj = a_ptr;
  486. y_ptr = y;
  487. if ( lda == 1 && inc_y == 1 )
  488. {
  489. for ( j=0; j< ( n & -4) ; j+=4 )
  490. {
  491. y_ptr[j] += aj[j] * xtemp;
  492. y_ptr[j+1] += aj[j+1] * xtemp;
  493. y_ptr[j+2] += aj[j+2] * xtemp;
  494. y_ptr[j+3] += aj[j+3] * xtemp;
  495. }
  496. for ( ; j<n ; j++ )
  497. {
  498. y_ptr[j] += aj[j] * xtemp;
  499. }
  500. }
  501. else
  502. {
  503. if ( inc_y == 1 )
  504. {
  505. BLASLONG register lda2 = lda << 1;
  506. BLASLONG register lda4 = lda << 2;
  507. BLASLONG register lda3 = lda2 + lda;
  508. for ( j=0; j< ( n & -4 ); j+=4 )
  509. {
  510. y_ptr[j] += *aj * xtemp;
  511. y_ptr[j+1] += *(aj+lda) * xtemp;
  512. y_ptr[j+2] += *(aj+lda2) * xtemp;
  513. y_ptr[j+3] += *(aj+lda3) * xtemp;
  514. aj += lda4 ;
  515. }
  516. for ( ; j<n; j++ )
  517. {
  518. y_ptr[j] += *aj * xtemp;
  519. aj += lda;
  520. }
  521. }
  522. else
  523. {
  524. for ( j=0; j<n; j++ )
  525. {
  526. *y_ptr += *aj * xtemp;
  527. y_ptr += inc_y;
  528. aj += lda;
  529. }
  530. }
  531. }
  532. return(0);
  533. }