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_n_4.c 15 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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(OS_DARWIN) || defined(OS_WINDOWS)) && (defined(__GNUC__) && __GNUC__ > 11)
  29. #pragma GCC optimize("no-tree-vectorize")
  30. #endif
  31. #if defined(BULLDOZER) || defined(PILEDRIVER) || defined(STEAMROLLER) || defined(EXCAVATOR)
  32. #include "sgemv_n_microk_bulldozer-4.c"
  33. #elif defined(NEHALEM)
  34. #include "sgemv_n_microk_nehalem-4.c"
  35. #elif defined(SANDYBRIDGE)
  36. #include "sgemv_n_microk_sandy-4.c"
  37. #elif defined(HASWELL) || defined(ZEN)
  38. #include "sgemv_n_microk_haswell-4.c"
  39. #elif defined (SKYLAKEX) || defined (COOPERLAKE) || defined (SAPPHIRERAPIDS)
  40. #include "sgemv_n_microk_haswell-4.c"
  41. #include "sgemv_n_microk_skylakex-8.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_4x8
  49. static void sgemv_kernel_4x8(BLASLONG n, FLOAT **ap, FLOAT *xo, FLOAT *y, BLASLONG lda4, FLOAT *alpha)
  50. {
  51. BLASLONG i;
  52. FLOAT *a0,*a1,*a2,*a3;
  53. FLOAT *b0,*b1,*b2,*b3;
  54. FLOAT *x4;
  55. FLOAT x[8];
  56. a0 = ap[0];
  57. a1 = ap[1];
  58. a2 = ap[2];
  59. a3 = ap[3];
  60. b0 = a0 + lda4 ;
  61. b1 = a1 + lda4 ;
  62. b2 = a2 + lda4 ;
  63. b3 = a3 + lda4 ;
  64. x4 = x + 4;
  65. for ( i=0; i<8; i++)
  66. x[i] = xo[i] * *alpha;
  67. for ( i=0; i< n; i+=4 )
  68. {
  69. y[i] += a0[i]*x[0] + a1[i]*x[1] + a2[i]*x[2] + a3[i]*x[3];
  70. y[i+1] += a0[i+1]*x[0] + a1[i+1]*x[1] + a2[i+1]*x[2] + a3[i+1]*x[3];
  71. y[i+2] += a0[i+2]*x[0] + a1[i+2]*x[1] + a2[i+2]*x[2] + a3[i+2]*x[3];
  72. y[i+3] += a0[i+3]*x[0] + a1[i+3]*x[1] + a2[i+3]*x[2] + a3[i+3]*x[3];
  73. y[i] += b0[i]*x4[0] + b1[i]*x4[1] + b2[i]*x4[2] + b3[i]*x4[3];
  74. y[i+1] += b0[i+1]*x4[0] + b1[i+1]*x4[1] + b2[i+1]*x4[2] + b3[i+1]*x4[3];
  75. y[i+2] += b0[i+2]*x4[0] + b1[i+2]*x4[1] + b2[i+2]*x4[2] + b3[i+2]*x4[3];
  76. y[i+3] += b0[i+3]*x4[0] + b1[i+3]*x4[1] + b2[i+3]*x4[2] + b3[i+3]*x4[3];
  77. }
  78. }
  79. #endif
  80. #ifndef HAVE_KERNEL_4x4
  81. static void sgemv_kernel_4x4(BLASLONG n, FLOAT **ap, FLOAT *xo, FLOAT *y, FLOAT *alpha)
  82. {
  83. BLASLONG i;
  84. FLOAT *a0,*a1,*a2,*a3;
  85. FLOAT x[4];
  86. a0 = ap[0];
  87. a1 = ap[1];
  88. a2 = ap[2];
  89. a3 = ap[3];
  90. for ( i=0; i<4; i++)
  91. x[i] = xo[i] * *alpha;
  92. for ( i=0; i< n; i+=4 )
  93. {
  94. y[i] += a0[i]*x[0] + a1[i]*x[1] + a2[i]*x[2] + a3[i]*x[3];
  95. y[i+1] += a0[i+1]*x[0] + a1[i+1]*x[1] + a2[i+1]*x[2] + a3[i+1]*x[3];
  96. y[i+2] += a0[i+2]*x[0] + a1[i+2]*x[1] + a2[i+2]*x[2] + a3[i+2]*x[3];
  97. y[i+3] += a0[i+3]*x[0] + a1[i+3]*x[1] + a2[i+3]*x[2] + a3[i+3]*x[3];
  98. }
  99. }
  100. #endif
  101. #ifndef HAVE_SGEMV_N_SKYLAKE_KERNEL
  102. #ifndef HAVE_KERNEL_4x2
  103. static void sgemv_kernel_4x2( BLASLONG n, FLOAT **ap, FLOAT *x, FLOAT *y, FLOAT *alpha) __attribute__ ((noinline));
  104. static void sgemv_kernel_4x2( BLASLONG n, FLOAT **ap, FLOAT *x, FLOAT *y, FLOAT *alpha)
  105. {
  106. BLASLONG register i = 0;
  107. __asm__ __volatile__
  108. (
  109. "movss (%2) , %%xmm12 \n\t" // x0
  110. "movss (%6) , %%xmm4 \n\t" // alpha
  111. "movss 4(%2) , %%xmm13 \n\t" // x1
  112. "mulss %%xmm4 , %%xmm12 \n\t" // alpha
  113. "mulss %%xmm4 , %%xmm13 \n\t" // alpha
  114. "shufps $0, %%xmm12, %%xmm12 \n\t"
  115. "shufps $0, %%xmm13, %%xmm13 \n\t"
  116. // ".align 16 \n\t"
  117. "1: \n\t"
  118. "movups (%3,%0,4), %%xmm4 \n\t" // 4 * y
  119. "movups (%4,%0,4), %%xmm8 \n\t"
  120. "movups (%5,%0,4), %%xmm9 \n\t"
  121. "mulps %%xmm12, %%xmm8 \n\t"
  122. "mulps %%xmm13, %%xmm9 \n\t"
  123. "addps %%xmm8 , %%xmm4 \n\t"
  124. "addq $4 , %0 \n\t"
  125. "addps %%xmm9 , %%xmm4 \n\t"
  126. "movups %%xmm4 , -16(%3,%0,4) \n\t" // 4 * y
  127. "subq $4 , %1 \n\t"
  128. "jnz 1b \n\t"
  129. :
  130. "+r" (i), // 0
  131. "+r" (n) // 1
  132. :
  133. "r" (x), // 2
  134. "r" (y), // 3
  135. "r" (ap[0]), // 4
  136. "r" (ap[1]), // 5
  137. "r" (alpha) // 6
  138. : "cc",
  139. "%xmm4", "%xmm5",
  140. "%xmm6", "%xmm7",
  141. "%xmm8", "%xmm9", "%xmm10", "%xmm11",
  142. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  143. "memory"
  144. );
  145. }
  146. #endif
  147. #endif
  148. #ifndef HAVE_KERNEL_4x1
  149. static void sgemv_kernel_4x1(BLASLONG n, FLOAT *ap, FLOAT *x, FLOAT *y, FLOAT *alpha) __attribute__ ((noinline));
  150. static void sgemv_kernel_4x1(BLASLONG n, FLOAT *ap, FLOAT *x, FLOAT *y, FLOAT *alpha)
  151. {
  152. BLASLONG register i = 0;
  153. BLASLONG register n1 = n & -8 ;
  154. BLASLONG register n2 = n & 4 ;
  155. __asm__ __volatile__
  156. (
  157. "movss (%2), %%xmm12 \n\t" // x0
  158. "mulss (%6), %%xmm12 \n\t" // alpha
  159. "shufps $0, %%xmm12, %%xmm12 \n\t"
  160. "cmpq $0, %1 \n\t"
  161. "je 2f \n\t"
  162. // ".align 16 \n\t"
  163. "1: \n\t"
  164. "movups (%3,%0,4), %%xmm4 \n\t" // 4 * y
  165. "movups 16(%3,%0,4), %%xmm5 \n\t" // 4 * y
  166. "movups (%4,%0,4), %%xmm8 \n\t" // 4 * a
  167. "movups 16(%4,%0,4), %%xmm9 \n\t" // 4 * a
  168. "mulps %%xmm12, %%xmm8 \n\t"
  169. "mulps %%xmm12, %%xmm9 \n\t"
  170. "addps %%xmm4 , %%xmm8 \n\t"
  171. "addps %%xmm5 , %%xmm9 \n\t"
  172. "addq $8 , %0 \n\t"
  173. "movups %%xmm8 , -32(%3,%0,4) \n\t" // 4 * y
  174. "movups %%xmm9 , -16(%3,%0,4) \n\t" // 4 * y
  175. "subq $8 , %1 \n\t"
  176. "jnz 1b \n\t"
  177. "2: \n\t"
  178. "testq $0x04, %5 \n\t"
  179. "jz 3f \n\t"
  180. "movups (%3,%0,4), %%xmm4 \n\t" // 4 * y
  181. "movups (%4,%0,4), %%xmm8 \n\t" // 4 * a
  182. "mulps %%xmm12, %%xmm8 \n\t"
  183. "addps %%xmm8 , %%xmm4 \n\t"
  184. "movups %%xmm4 , (%3,%0,4) \n\t" // 4 * y
  185. "addq $4 , %0 \n\t"
  186. "subq $4 , %1 \n\t"
  187. "3: \n\t"
  188. :
  189. "+r" (i), // 0
  190. "+r" (n1) // 1
  191. :
  192. "r" (x), // 2
  193. "r" (y), // 3
  194. "r" (ap), // 4
  195. "r" (n2), // 5
  196. "r" (alpha) // 6
  197. : "cc",
  198. "%xmm4", "%xmm5",
  199. "%xmm6", "%xmm7",
  200. "%xmm8", "%xmm9", "%xmm10", "%xmm11",
  201. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  202. "memory"
  203. );
  204. }
  205. #endif
  206. static void add_y(BLASLONG n, FLOAT *src, FLOAT *dest, BLASLONG inc_dest) __attribute__ ((noinline));
  207. static void add_y(BLASLONG n, FLOAT *src, FLOAT *dest, BLASLONG inc_dest)
  208. {
  209. BLASLONG i;
  210. if ( inc_dest != 1 )
  211. {
  212. for ( i=0; i<n; i++ )
  213. {
  214. *dest += *src;
  215. src++;
  216. dest += inc_dest;
  217. }
  218. return;
  219. }
  220. i=0;
  221. __asm__ __volatile__
  222. (
  223. // ".align 16 \n\t"
  224. "1: \n\t"
  225. "movups (%2,%0,4) , %%xmm12 \n\t"
  226. "movups (%3,%0,4) , %%xmm11 \n\t"
  227. "addps %%xmm12 , %%xmm11 \n\t"
  228. "addq $4 , %0 \n\t"
  229. "movups %%xmm11, -16(%3,%0,4) \n\t"
  230. "subq $4 , %1 \n\t"
  231. "jnz 1b \n\t"
  232. :
  233. "+r" (i), // 0
  234. "+r" (n) // 1
  235. :
  236. "r" (src), // 2
  237. "r" (dest) // 3
  238. : "cc",
  239. "%xmm10", "%xmm11", "%xmm12",
  240. "memory"
  241. );
  242. }
  243. 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)
  244. {
  245. if ( m < 1 || n < 1) return(0);
  246. #ifdef HAVE_SGEMV_N_SKYLAKE_KERNEL
  247. if (m <= 16384 && n <= 48 && !(n == 4))
  248. {
  249. FLOAT * xbuffer_align = x;
  250. FLOAT * ybuffer_align = y;
  251. if (inc_x != 1) {
  252. xbuffer_align = buffer;
  253. for(BLASLONG i=0; i<n; i++) {
  254. xbuffer_align[i] = x[i*inc_x];
  255. }
  256. }
  257. if (inc_y != 1) {
  258. ybuffer_align = buffer + n;
  259. for(BLASLONG i=0; i<m; i++) {
  260. ybuffer_align[i] = y[i*inc_y];
  261. }
  262. }
  263. sgemv_kernel_n_128(m, n , alpha, a, lda, xbuffer_align, ybuffer_align);
  264. if(inc_y != 1) {
  265. for(BLASLONG i=0; i<m; i++) {
  266. y[i*inc_y] = ybuffer_align[i];
  267. }
  268. }
  269. return(0);
  270. }
  271. #endif
  272. BLASLONG i;
  273. FLOAT *a_ptr;
  274. FLOAT *x_ptr;
  275. FLOAT *y_ptr;
  276. FLOAT *ap[4];
  277. BLASLONG n1;
  278. BLASLONG m1;
  279. BLASLONG m2;
  280. BLASLONG m3;
  281. BLASLONG n2;
  282. BLASLONG lda4 = lda << 2;
  283. BLASLONG lda8 = lda << 3;
  284. FLOAT xbuffer[8],*ybuffer;
  285. ybuffer = buffer;
  286. if ( inc_x == 1 )
  287. {
  288. n1 = n >> 3 ;
  289. n2 = n & 7 ;
  290. }
  291. else
  292. {
  293. n1 = n >> 2 ;
  294. n2 = n & 3 ;
  295. }
  296. m3 = m & 3 ;
  297. m1 = m & -4 ;
  298. m2 = (m & (NBMAX-1)) - m3 ;
  299. y_ptr = y;
  300. BLASLONG NB = NBMAX;
  301. while ( NB == NBMAX )
  302. {
  303. m1 -= NB;
  304. if ( m1 < 0)
  305. {
  306. if ( m2 == 0 ) break;
  307. NB = m2;
  308. }
  309. a_ptr = a;
  310. x_ptr = x;
  311. ap[0] = a_ptr;
  312. ap[1] = a_ptr + lda;
  313. ap[2] = ap[1] + lda;
  314. ap[3] = ap[2] + lda;
  315. if ( inc_y != 1 )
  316. memset(ybuffer,0,NB*4);
  317. else
  318. ybuffer = y_ptr;
  319. if ( inc_x == 1 )
  320. {
  321. for( i = 0; i < n1 ; i++)
  322. {
  323. sgemv_kernel_4x8(NB,ap,x_ptr,ybuffer,lda4,&alpha);
  324. ap[0] += lda8;
  325. ap[1] += lda8;
  326. ap[2] += lda8;
  327. ap[3] += lda8;
  328. a_ptr += lda8;
  329. x_ptr += 8;
  330. }
  331. if ( n2 & 4 )
  332. {
  333. sgemv_kernel_4x4(NB,ap,x_ptr,ybuffer,&alpha);
  334. ap[0] += lda4;
  335. ap[1] += lda4;
  336. ap[2] += lda4;
  337. ap[3] += lda4;
  338. a_ptr += lda4;
  339. x_ptr += 4;
  340. }
  341. if ( n2 & 2 )
  342. {
  343. #ifdef HAVE_SGEMV_N_SKYLAKE_KERNEL
  344. sgemv_kernel_n_64(NB, 2, alpha, a_ptr, lda, x_ptr, ybuffer);
  345. #else
  346. sgemv_kernel_4x2(NB,ap,x_ptr,ybuffer,&alpha);
  347. #endif
  348. a_ptr += lda*2;
  349. x_ptr += 2;
  350. }
  351. if ( n2 & 1 )
  352. {
  353. #ifdef HAVE_SGEMV_N_SKYLAKE_KERNEL
  354. sgemv_kernel_n_64(NB, 1, alpha, a_ptr, lda, x_ptr, ybuffer);
  355. #else
  356. sgemv_kernel_4x1(NB,a_ptr,x_ptr,ybuffer,&alpha);
  357. #endif
  358. /* a_ptr += lda;
  359. x_ptr += 1a; */
  360. }
  361. }
  362. else
  363. {
  364. for( i = 0; i < n1 ; i++)
  365. {
  366. xbuffer[0] = x_ptr[0];
  367. x_ptr += inc_x;
  368. xbuffer[1] = x_ptr[0];
  369. x_ptr += inc_x;
  370. xbuffer[2] = x_ptr[0];
  371. x_ptr += inc_x;
  372. xbuffer[3] = x_ptr[0];
  373. x_ptr += inc_x;
  374. sgemv_kernel_4x4(NB,ap,xbuffer,ybuffer,&alpha);
  375. ap[0] += lda4;
  376. ap[1] += lda4;
  377. ap[2] += lda4;
  378. ap[3] += lda4;
  379. a_ptr += lda4;
  380. }
  381. for( i = 0; i < n2 ; i++)
  382. {
  383. xbuffer[0] = x_ptr[0];
  384. x_ptr += inc_x;
  385. sgemv_kernel_4x1(NB,a_ptr,xbuffer,ybuffer,&alpha);
  386. a_ptr += lda;
  387. }
  388. }
  389. a += NB;
  390. if ( inc_y != 1 )
  391. {
  392. add_y(NB,ybuffer,y_ptr,inc_y);
  393. y_ptr += NB * inc_y;
  394. }
  395. else
  396. y_ptr += NB ;
  397. }
  398. if ( m3 == 0 ) return(0);
  399. if ( m3 == 3 )
  400. {
  401. a_ptr = a;
  402. x_ptr = x;
  403. FLOAT temp0 = 0.0;
  404. FLOAT temp1 = 0.0;
  405. FLOAT temp2 = 0.0;
  406. if ( lda == 3 && inc_x ==1 )
  407. {
  408. for( i = 0; i < ( n & -4 ); i+=4 )
  409. {
  410. temp0 += a_ptr[0] * x_ptr[0] + a_ptr[3] * x_ptr[1];
  411. temp1 += a_ptr[1] * x_ptr[0] + a_ptr[4] * x_ptr[1];
  412. temp2 += a_ptr[2] * x_ptr[0] + a_ptr[5] * x_ptr[1];
  413. temp0 += a_ptr[6] * x_ptr[2] + a_ptr[9] * x_ptr[3];
  414. temp1 += a_ptr[7] * x_ptr[2] + a_ptr[10] * x_ptr[3];
  415. temp2 += a_ptr[8] * x_ptr[2] + a_ptr[11] * x_ptr[3];
  416. a_ptr += 12;
  417. x_ptr += 4;
  418. }
  419. for( ; i < n; i++ )
  420. {
  421. temp0 += a_ptr[0] * x_ptr[0];
  422. temp1 += a_ptr[1] * x_ptr[0];
  423. temp2 += a_ptr[2] * x_ptr[0];
  424. a_ptr += 3;
  425. x_ptr ++;
  426. }
  427. }
  428. else
  429. {
  430. for( i = 0; i < n; i++ )
  431. {
  432. temp0 += a_ptr[0] * x_ptr[0];
  433. temp1 += a_ptr[1] * x_ptr[0];
  434. temp2 += a_ptr[2] * x_ptr[0];
  435. a_ptr += lda;
  436. x_ptr += inc_x;
  437. }
  438. }
  439. y_ptr[0] += alpha * temp0;
  440. y_ptr += inc_y;
  441. y_ptr[0] += alpha * temp1;
  442. y_ptr += inc_y;
  443. y_ptr[0] += alpha * temp2;
  444. return(0);
  445. }
  446. if ( m3 == 2 )
  447. {
  448. a_ptr = a;
  449. x_ptr = x;
  450. FLOAT temp0 = 0.0;
  451. FLOAT temp1 = 0.0;
  452. if ( lda == 2 && inc_x ==1 )
  453. {
  454. for( i = 0; i < (n & -4) ; i+=4 )
  455. {
  456. temp0 += a_ptr[0] * x_ptr[0] + a_ptr[2] * x_ptr[1];
  457. temp1 += a_ptr[1] * x_ptr[0] + a_ptr[3] * x_ptr[1];
  458. temp0 += a_ptr[4] * x_ptr[2] + a_ptr[6] * x_ptr[3];
  459. temp1 += a_ptr[5] * x_ptr[2] + a_ptr[7] * x_ptr[3];
  460. a_ptr += 8;
  461. x_ptr += 4;
  462. }
  463. for( ; i < n; i++ )
  464. {
  465. temp0 += a_ptr[0] * x_ptr[0];
  466. temp1 += a_ptr[1] * x_ptr[0];
  467. a_ptr += 2;
  468. x_ptr ++;
  469. }
  470. }
  471. else
  472. {
  473. for( i = 0; i < n; i++ )
  474. {
  475. temp0 += a_ptr[0] * x_ptr[0];
  476. temp1 += a_ptr[1] * x_ptr[0];
  477. a_ptr += lda;
  478. x_ptr += inc_x;
  479. }
  480. }
  481. y_ptr[0] += alpha * temp0;
  482. y_ptr += inc_y;
  483. y_ptr[0] += alpha * temp1;
  484. return(0);
  485. }
  486. if ( m3 == 1 )
  487. {
  488. a_ptr = a;
  489. x_ptr = x;
  490. FLOAT temp = 0.0;
  491. if ( lda == 1 && inc_x ==1 )
  492. {
  493. for( i = 0; i < (n & -4); i+=4 )
  494. {
  495. temp += a_ptr[i] * x_ptr[i] + a_ptr[i+1] * x_ptr[i+1] + a_ptr[i+2] * x_ptr[i+2] + a_ptr[i+3] * x_ptr[i+3];
  496. }
  497. for( ; i < n; i++ )
  498. {
  499. temp += a_ptr[i] * x_ptr[i];
  500. }
  501. }
  502. else
  503. {
  504. for( i = 0; i < n; i++ )
  505. {
  506. temp += a_ptr[0] * x_ptr[0];
  507. a_ptr += lda;
  508. x_ptr += inc_x;
  509. }
  510. }
  511. y_ptr[0] += alpha * temp;
  512. return(0);
  513. }
  514. return(0);
  515. }