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.

dgemv_t_power10.c 19 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /***************************************************************************
  2. Copyright (c) 2018, 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. #define NBMAX 1024
  29. //#define PREFETCH 1
  30. #include <altivec.h>
  31. #define HAVE_KERNEL4x8_ASM 1
  32. #if defined(HAVE_KERNEL4x8_ASM)
  33. #if !__has_builtin(__builtin_vsx_disassemble_pair)
  34. #define __builtin_vsx_disassemble_pair __builtin_mma_disassemble_pair
  35. #endif
  36. typedef __vector unsigned char vec_t;
  37. static void dgemv_kernel_4x8(BLASLONG n, BLASLONG lda, FLOAT *ap, FLOAT *x, FLOAT *y, FLOAT alpha) {
  38. BLASLONG i;
  39. FLOAT *a0, *a1, *a2, *a3, *a4, *a5, *a6, *a7;
  40. __vector_pair vx, vp;
  41. vec_t res[2],res1[2];
  42. register __vector double temp0 = {0, 0};
  43. register __vector double temp1 = {0, 0};
  44. register __vector double temp2 = {0, 0};
  45. register __vector double temp3 = {0, 0};
  46. register __vector double temp4 = {0, 0};
  47. register __vector double temp5 = {0, 0};
  48. register __vector double temp6 = {0, 0};
  49. register __vector double temp7 = {0, 0};
  50. a0 = ap;
  51. a1 = ap + lda;
  52. a2 = a1 + lda;
  53. a3 = a2 + lda;
  54. a4 = a3 + lda;
  55. a5 = a4 + lda;
  56. a6 = a5 + lda;
  57. a7 = a6 + lda;
  58. for (i = 0; i < n/2; i += 2) {
  59. vp = *((__vector_pair *)((void *)&a0[i*2]));
  60. vx = *((__vector_pair *)((void *)&x[i*2]));
  61. __builtin_vsx_disassemble_pair (res, &vx);
  62. __builtin_vsx_disassemble_pair (res1, &vp);
  63. temp0 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp0);
  64. temp0 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp0);
  65. vp = *((__vector_pair *)((void *)&a1[i*2]));
  66. __builtin_vsx_disassemble_pair (res1, &vp);
  67. temp1 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp1);
  68. temp1 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp1);
  69. vp = *((__vector_pair *)((void *)&a2[i*2]));
  70. __builtin_vsx_disassemble_pair (res1, &vp);
  71. temp2 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp2);
  72. temp2 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp2);
  73. vp = *((__vector_pair *)((void *)&a3[i*2]));
  74. __builtin_vsx_disassemble_pair (res1, &vp);
  75. temp3 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp3);
  76. temp3 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp3);
  77. vp = *((__vector_pair *)((void *)&a4[i*2]));
  78. __builtin_vsx_disassemble_pair (res1, &vp);
  79. temp4 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp4);
  80. temp4 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp4);
  81. vp = *((__vector_pair *)((void *)&a5[i*2]));
  82. __builtin_vsx_disassemble_pair (res1, &vp);
  83. temp5 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp5);
  84. temp5 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp5);
  85. vp = *((__vector_pair *)((void *)&a6[i*2]));
  86. __builtin_vsx_disassemble_pair (res1, &vp);
  87. temp6 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp6);
  88. temp6 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp6);
  89. vp = *((__vector_pair *)((void *)&a7[i*2]));
  90. __builtin_vsx_disassemble_pair (res1, &vp);
  91. temp7 = vec_madd ((__vector double)res[0], (__vector double)res1[0], temp7);
  92. temp7 = vec_madd ((__vector double)res[1], (__vector double)res1[1], temp7);
  93. }
  94. y[0] += alpha * (temp0[0] + temp0[1]);
  95. y[1] += alpha * (temp1[0] + temp1[1]);
  96. y[2] += alpha * (temp2[0] + temp2[1]);
  97. y[3] += alpha * (temp3[0] + temp3[1]);
  98. y[4] += alpha * (temp4[0] + temp4[1]);
  99. y[5] += alpha * (temp5[0] + temp5[1]);
  100. y[6] += alpha * (temp6[0] + temp6[1]);
  101. y[7] += alpha * (temp7[0] + temp7[1]);
  102. }
  103. #else
  104. static void dgemv_kernel_4x8(BLASLONG n, BLASLONG lda, FLOAT *ap, FLOAT *x, FLOAT *y, FLOAT alpha) {
  105. BLASLONG i;
  106. #if defined(PREFETCH)
  107. BLASLONG j, c, k;
  108. #endif
  109. FLOAT *a0, *a1, *a2, *a3, *a4, *a5, *a6, *a7;
  110. __vector double *va0, *va1, *va2, *va3, *va4, *va5, *va6, *va7, *v_x;
  111. register __vector double temp0 = {0, 0};
  112. register __vector double temp1 = {0, 0};
  113. register __vector double temp2 = {0, 0};
  114. register __vector double temp3 = {0, 0};
  115. register __vector double temp4 = {0, 0};
  116. register __vector double temp5 = {0, 0};
  117. register __vector double temp6 = {0, 0};
  118. register __vector double temp7 = {0, 0};
  119. a0 = ap;
  120. a1 = ap + lda;
  121. a2 = a1 + lda;
  122. a3 = a2 + lda;
  123. a4 = a3 + lda;
  124. a5 = a4 + lda;
  125. a6 = a5 + lda;
  126. a7 = a6 + lda;
  127. va0 = (__vector double*) a0;
  128. va1 = (__vector double*) a1;
  129. va2 = (__vector double*) a2;
  130. va3 = (__vector double*) a3;
  131. va4 = (__vector double*) a4;
  132. va5 = (__vector double*) a5;
  133. va6 = (__vector double*) a6;
  134. va7 = (__vector double*) a7;
  135. v_x = (__vector double*) x;
  136. #if defined(PREFETCH)
  137. c = n >> 1;
  138. for (j = 0; j < c; j += 64) {
  139. k = (c - j) > 64 ? 64 : (c - j);
  140. __builtin_prefetch(v_x + 64);
  141. __builtin_prefetch(va0 + 64);
  142. __builtin_prefetch(va1 + 64);
  143. __builtin_prefetch(va2 + 64);
  144. __builtin_prefetch(va3 + 64);
  145. __builtin_prefetch(va4 + 64);
  146. __builtin_prefetch(va5 + 64);
  147. __builtin_prefetch(va6 + 64);
  148. __builtin_prefetch(va7 + 64);
  149. for (i = 0; i < k; i += 2) {
  150. #else
  151. for (i = 0; i < n/2; i += 2) {
  152. #endif
  153. temp0 += v_x[i] * va0[i];
  154. temp1 += v_x[i] * va1[i];
  155. temp2 += v_x[i] * va2[i];
  156. temp3 += v_x[i] * va3[i];
  157. temp4 += v_x[i] * va4[i];
  158. temp5 += v_x[i] * va5[i];
  159. temp6 += v_x[i] * va6[i];
  160. temp7 += v_x[i] * va7[i];
  161. temp0 += v_x[i + 1] * va0[i + 1];
  162. temp1 += v_x[i + 1] * va1[i + 1];
  163. temp2 += v_x[i + 1] * va2[i + 1];
  164. temp3 += v_x[i + 1] * va3[i + 1];
  165. temp4 += v_x[i + 1] * va4[i + 1];
  166. temp5 += v_x[i + 1] * va5[i + 1];
  167. temp6 += v_x[i + 1] * va6[i + 1];
  168. temp7 += v_x[i + 1] * va7[i + 1];
  169. }
  170. #if defined(PREFETCH)
  171. va0 += 64;
  172. va1 += 64;
  173. va2 += 64;
  174. va3 += 64;
  175. va4 += 64;
  176. va5 += 64;
  177. va6 += 64;
  178. va7 += 64;
  179. v_x += 64;
  180. }
  181. #endif
  182. y[0] += alpha * (temp0[0] + temp0[1]);
  183. y[1] += alpha * (temp1[0] + temp1[1]);
  184. y[2] += alpha * (temp2[0] + temp2[1]);
  185. y[3] += alpha * (temp3[0] + temp3[1]);
  186. y[4] += alpha * (temp4[0] + temp4[1]);
  187. y[5] += alpha * (temp5[0] + temp5[1]);
  188. y[6] += alpha * (temp6[0] + temp6[1]);
  189. y[7] += alpha * (temp7[0] + temp7[1]);
  190. }
  191. #endif
  192. static void dgemv_kernel_4x4(BLASLONG n, BLASLONG lda, FLOAT *ap, FLOAT *x, FLOAT *y, FLOAT alpha) {
  193. BLASLONG i = 0;
  194. FLOAT *a0, *a1, *a2, *a3;
  195. a0 = ap;
  196. a1 = ap + lda;
  197. a2 = a1 + lda;
  198. a3 = a2 + lda;
  199. __vector double* va0 = (__vector double*) a0;
  200. __vector double* va1 = (__vector double*) a1;
  201. __vector double* va2 = (__vector double*) a2;
  202. __vector double* va3 = (__vector double*) a3;
  203. __vector double* v_x = (__vector double*) x;
  204. register __vector double temp0 = {0, 0};
  205. register __vector double temp1 = {0, 0};
  206. register __vector double temp2 = {0, 0};
  207. register __vector double temp3 = {0, 0};
  208. register __vector double temp4 = {0, 0};
  209. register __vector double temp5 = {0, 0};
  210. register __vector double temp6 = {0, 0};
  211. register __vector double temp7 = {0, 0};
  212. for (i = 0; i < n / 2; i += 2) {
  213. temp0 += v_x[i] * va0[i];
  214. temp1 += v_x[i] * va1[i];
  215. temp2 += v_x[i] * va2[i];
  216. temp3 += v_x[i] * va3[i];
  217. temp4 += v_x[i + 1] * va0[i + 1];
  218. temp5 += v_x[i + 1] * va1[i + 1];
  219. temp6 += v_x[i + 1] * va2[i + 1];
  220. temp7 += v_x[i + 1] * va3[i + 1];
  221. }
  222. temp0 += temp4;
  223. temp1 += temp5;
  224. temp2 += temp6;
  225. temp3 += temp7;
  226. y[0] += alpha * (temp0[0] + temp0[1]);
  227. y[1] += alpha * (temp1[0] + temp1[1]);
  228. y[2] += alpha * (temp2[0] + temp2[1]);
  229. y[3] += alpha * (temp3[0] + temp3[1]);
  230. }
  231. static void dgemv_kernel_4x2(BLASLONG n, BLASLONG lda, FLOAT *ap, FLOAT *x, FLOAT *y, FLOAT alpha, BLASLONG inc_y) {
  232. BLASLONG i;
  233. FLOAT *a0, *a1;
  234. a0 = ap;
  235. a1 = ap + lda;
  236. __vector double* va0 = (__vector double*) a0;
  237. __vector double* va1 = (__vector double*) a1;
  238. __vector double* v_x = (__vector double*) x;
  239. __vector double temp0 = {0, 0};
  240. __vector double temp1 = {0, 0};
  241. for (i = 0; i < n / 2; i += 2) {
  242. temp0 += v_x[i] * va0[i] + v_x[i + 1] * va0[i + 1];
  243. temp1 += v_x[i] * va1[i] + v_x[i + 1] * va1[i + 1];
  244. }
  245. y[0] += alpha * (temp0[0] + temp0[1]);
  246. y[inc_y] += alpha * (temp1[0] + temp1[1]);
  247. }
  248. static void dgemv_kernel_4x1(BLASLONG n, FLOAT *ap, FLOAT *x, FLOAT *y, FLOAT alpha) {
  249. BLASLONG i;
  250. FLOAT *a0;
  251. a0 = ap;
  252. __vector double* va0 = (__vector double*) a0;
  253. __vector double* v_x = (__vector double*) x;
  254. __vector double temp0 = {0, 0};
  255. for (i = 0; i < n / 2; i += 2) {
  256. temp0 += v_x[i] * va0[i] + v_x[i + 1] * va0[i + 1];
  257. }
  258. *y += alpha * (temp0[0] + temp0[1]);
  259. }
  260. static void copy_x(BLASLONG n, FLOAT *src, FLOAT *dest, BLASLONG inc_src) {
  261. BLASLONG i;
  262. for (i = 0; i < n; i++) {
  263. *dest++ = *src;
  264. src += inc_src;
  265. }
  266. }
  267. 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) {
  268. BLASLONG i;
  269. BLASLONG j;
  270. FLOAT *a_ptr;
  271. FLOAT *x_ptr;
  272. FLOAT *y_ptr;
  273. BLASLONG n1;
  274. BLASLONG m1;
  275. BLASLONG m2;
  276. BLASLONG m3;
  277. BLASLONG n2;
  278. FLOAT ybuffer[8] __attribute__((aligned(16)));
  279. FLOAT *xbuffer;
  280. if (m < 1) return (0);
  281. if (n < 1) return (0);
  282. xbuffer = buffer;
  283. n1 = n >> 3;
  284. n2 = n & 7;
  285. m3 = m & 3;
  286. m1 = m - m3;
  287. m2 = (m & (NBMAX - 1)) - m3;
  288. BLASLONG NB = NBMAX;
  289. while (NB == NBMAX) {
  290. m1 -= NB;
  291. if (m1 < 0) {
  292. if (m2 == 0) break;
  293. NB = m2;
  294. }
  295. y_ptr = y;
  296. a_ptr = a;
  297. x_ptr = x;
  298. if (inc_x != 1)
  299. copy_x(NB, x_ptr, xbuffer, inc_x);
  300. else
  301. xbuffer = x_ptr;
  302. BLASLONG lda8 = lda << 3;
  303. if (inc_y == 1) {
  304. for (i = 0; i < n1; i++) {
  305. dgemv_kernel_4x8(NB, lda, a_ptr, xbuffer, y_ptr, alpha);
  306. y_ptr += 8;
  307. a_ptr += lda8;
  308. #if defined(PREFETCH)
  309. __builtin_prefetch(y_ptr+64);
  310. #endif
  311. }
  312. } else {
  313. for (i = 0; i < n1; i++) {
  314. ybuffer[0] = 0;
  315. ybuffer[1] = 0;
  316. ybuffer[2] = 0;
  317. ybuffer[3] = 0;
  318. ybuffer[4] = 0;
  319. ybuffer[5] = 0;
  320. ybuffer[6] = 0;
  321. ybuffer[7] = 0;
  322. dgemv_kernel_4x8(NB, lda, a_ptr, xbuffer, ybuffer, alpha);
  323. *y_ptr += ybuffer[0];
  324. y_ptr += inc_y;
  325. *y_ptr += ybuffer[1];
  326. y_ptr += inc_y;
  327. *y_ptr += ybuffer[2];
  328. y_ptr += inc_y;
  329. *y_ptr += ybuffer[3];
  330. y_ptr += inc_y;
  331. *y_ptr += ybuffer[4];
  332. y_ptr += inc_y;
  333. *y_ptr += ybuffer[5];
  334. y_ptr += inc_y;
  335. *y_ptr += ybuffer[6];
  336. y_ptr += inc_y;
  337. *y_ptr += ybuffer[7];
  338. y_ptr += inc_y;
  339. a_ptr += lda8;
  340. }
  341. }
  342. if (n2 & 4) {
  343. ybuffer[0] = 0;
  344. ybuffer[1] = 0;
  345. ybuffer[2] = 0;
  346. ybuffer[3] = 0;
  347. dgemv_kernel_4x4(NB, lda, a_ptr, xbuffer, ybuffer, alpha);
  348. a_ptr += lda<<2;
  349. *y_ptr += ybuffer[0];
  350. y_ptr += inc_y;
  351. *y_ptr += ybuffer[1];
  352. y_ptr += inc_y;
  353. *y_ptr += ybuffer[2];
  354. y_ptr += inc_y;
  355. *y_ptr += ybuffer[3];
  356. y_ptr += inc_y;
  357. }
  358. if (n2 & 2) {
  359. dgemv_kernel_4x2(NB, lda, a_ptr, xbuffer, y_ptr, alpha, inc_y);
  360. a_ptr += lda << 1;
  361. y_ptr += 2 * inc_y;
  362. }
  363. if (n2 & 1) {
  364. dgemv_kernel_4x1(NB, a_ptr, xbuffer, y_ptr, alpha);
  365. a_ptr += lda;
  366. y_ptr += inc_y;
  367. }
  368. a += NB;
  369. x += NB * inc_x;
  370. }
  371. if (m3 == 0) return (0);
  372. x_ptr = x;
  373. a_ptr = a;
  374. if (m3 == 3) {
  375. FLOAT xtemp0 = *x_ptr * alpha;
  376. x_ptr += inc_x;
  377. FLOAT xtemp1 = *x_ptr * alpha;
  378. x_ptr += inc_x;
  379. FLOAT xtemp2 = *x_ptr * alpha;
  380. FLOAT *aj = a_ptr;
  381. y_ptr = y;
  382. if (lda == 3 && inc_y == 1) {
  383. for (j = 0; j < (n & -4); j += 4) {
  384. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1 + aj[2] * xtemp2;
  385. y_ptr[j + 1] += aj[3] * xtemp0 + aj[4] * xtemp1 + aj[5] * xtemp2;
  386. y_ptr[j + 2] += aj[6] * xtemp0 + aj[7] * xtemp1 + aj[8] * xtemp2;
  387. y_ptr[j + 3] += aj[9] * xtemp0 + aj[10] * xtemp1 + aj[11] * xtemp2;
  388. aj += 12;
  389. }
  390. for (; j < n; j++) {
  391. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1 + aj[2] * xtemp2;
  392. aj += 3;
  393. }
  394. } else {
  395. if (inc_y == 1) {
  396. BLASLONG register lda2 = lda << 1;
  397. BLASLONG register lda4 = lda << 2;
  398. BLASLONG register lda3 = lda2 + lda;
  399. for (j = 0; j < (n & -4); j += 4) {
  400. y_ptr[j] += *aj * xtemp0 + *(aj + 1) * xtemp1 + *(aj + 2) * xtemp2;
  401. y_ptr[j + 1] += *(aj + lda) * xtemp0 + *(aj + lda + 1) * xtemp1 + *(aj + lda + 2) * xtemp2;
  402. y_ptr[j + 2] += *(aj + lda2) * xtemp0 + *(aj + lda2 + 1) * xtemp1 + *(aj + lda2 + 2) * xtemp2;
  403. y_ptr[j + 3] += *(aj + lda3) * xtemp0 + *(aj + lda3 + 1) * xtemp1 + *(aj + lda3 + 2) * xtemp2;
  404. aj += lda4;
  405. }
  406. for (; j < n; j++) {
  407. y_ptr[j] += *aj * xtemp0 + *(aj + 1) * xtemp1 + *(aj + 2) * xtemp2;
  408. aj += lda;
  409. }
  410. } else {
  411. for (j = 0; j < n; j++) {
  412. *y_ptr += *aj * xtemp0 + *(aj + 1) * xtemp1 + *(aj + 2) * xtemp2;
  413. y_ptr += inc_y;
  414. aj += lda;
  415. }
  416. }
  417. }
  418. return (0);
  419. }
  420. if (m3 == 2) {
  421. FLOAT xtemp0 = *x_ptr * alpha;
  422. x_ptr += inc_x;
  423. FLOAT xtemp1 = *x_ptr * alpha;
  424. FLOAT *aj = a_ptr;
  425. y_ptr = y;
  426. if (lda == 2 && inc_y == 1) {
  427. for (j = 0; j < (n & -4); j += 4) {
  428. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1;
  429. y_ptr[j + 1] += aj[2] * xtemp0 + aj[3] * xtemp1;
  430. y_ptr[j + 2] += aj[4] * xtemp0 + aj[5] * xtemp1;
  431. y_ptr[j + 3] += aj[6] * xtemp0 + aj[7] * xtemp1;
  432. aj += 8;
  433. }
  434. for (; j < n; j++) {
  435. y_ptr[j] += aj[0] * xtemp0 + aj[1] * xtemp1;
  436. aj += 2;
  437. }
  438. } else {
  439. if (inc_y == 1) {
  440. BLASLONG register lda2 = lda << 1;
  441. BLASLONG register lda4 = lda << 2;
  442. BLASLONG register lda3 = lda2 + lda;
  443. for (j = 0; j < (n & -4); j += 4) {
  444. y_ptr[j] += *aj * xtemp0 + *(aj + 1) * xtemp1;
  445. y_ptr[j + 1] += *(aj + lda) * xtemp0 + *(aj + lda + 1) * xtemp1;
  446. y_ptr[j + 2] += *(aj + lda2) * xtemp0 + *(aj + lda2 + 1) * xtemp1;
  447. y_ptr[j + 3] += *(aj + lda3) * xtemp0 + *(aj + lda3 + 1) * xtemp1;
  448. aj += lda4;
  449. }
  450. for (; j < n; j++) {
  451. y_ptr[j] += *aj * xtemp0 + *(aj + 1) * xtemp1;
  452. aj += lda;
  453. }
  454. } else {
  455. for (j = 0; j < n; j++) {
  456. *y_ptr += *aj * xtemp0 + *(aj + 1) * xtemp1;
  457. y_ptr += inc_y;
  458. aj += lda;
  459. }
  460. }
  461. }
  462. return (0);
  463. }
  464. FLOAT xtemp = *x_ptr * alpha;
  465. FLOAT *aj = a_ptr;
  466. y_ptr = y;
  467. if (lda == 1 && inc_y == 1) {
  468. for (j = 0; j < (n & -4); j += 4) {
  469. y_ptr[j] += aj[j] * xtemp;
  470. y_ptr[j + 1] += aj[j + 1] * xtemp;
  471. y_ptr[j + 2] += aj[j + 2] * xtemp;
  472. y_ptr[j + 3] += aj[j + 3] * xtemp;
  473. }
  474. for (; j < n; j++) {
  475. y_ptr[j] += aj[j] * xtemp;
  476. }
  477. } else {
  478. if (inc_y == 1) {
  479. BLASLONG register lda2 = lda << 1;
  480. BLASLONG register lda4 = lda << 2;
  481. BLASLONG register lda3 = lda2 + lda;
  482. for (j = 0; j < (n & -4); j += 4) {
  483. y_ptr[j] += *aj * xtemp;
  484. y_ptr[j + 1] += *(aj + lda) * xtemp;
  485. y_ptr[j + 2] += *(aj + lda2) * xtemp;
  486. y_ptr[j + 3] += *(aj + lda3) * xtemp;
  487. aj += lda4;
  488. }
  489. for (; j < n; j++) {
  490. y_ptr[j] += *aj * xtemp;
  491. aj += lda;
  492. }
  493. } else {
  494. for (j = 0; j < n; j++) {
  495. *y_ptr += *aj * xtemp;
  496. y_ptr += inc_y;
  497. aj += lda;
  498. }
  499. }
  500. }
  501. return (0);
  502. }