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.

zgemv_t_4.c 20 kB

7 years ago
7 years ago
7 years ago
7 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /***************************************************************************
  2. Copyright (c) 2019, 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. static void zgemv_kernel_4x4(BLASLONG n, FLOAT **ap, FLOAT *x, FLOAT *y,
  30. FLOAT *alpha) {
  31. register FLOAT *ap0 = ap[0];
  32. register FLOAT *ap1 = ap[1];
  33. register FLOAT *ap2 = ap[2];
  34. register FLOAT *ap3 = ap[3];
  35. __asm__("vzero %%v16\n\t"
  36. "vzero %%v17\n\t"
  37. "vzero %%v18\n\t"
  38. "vzero %%v19\n\t"
  39. "vzero %%v20\n\t"
  40. "vzero %%v21\n\t"
  41. "vzero %%v22\n\t"
  42. "vzero %%v23\n\t"
  43. "xgr %%r1,%%r1\n\t"
  44. "srlg %[n],%[n],1\n\t"
  45. "0:\n\t"
  46. "pfd 1,1024(%%r1,%[ap0])\n\t"
  47. "pfd 1,1024(%%r1,%[ap1])\n\t"
  48. "pfd 1,1024(%%r1,%[ap2])\n\t"
  49. "pfd 1,1024(%%r1,%[ap3])\n\t"
  50. "pfd 1,1024(%%r1,%[x])\n\t"
  51. "vl %%v0,0(%%r1,%[x])\n\t"
  52. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  53. "vleg %%v1,8(%%r1,%[x]),0\n\t"
  54. "wflcdb %%v1,%%v1\n\t"
  55. "vleg %%v1,0(%%r1,%[x]),1\n\t"
  56. #else
  57. "vleg %%v1,0(%%r1,%[x]),1\n\t"
  58. "vflcdb %%v1,%%v1\n\t"
  59. "vleg %%v1,8(%%r1,%[x]),0\n\t"
  60. #endif
  61. "vlrepg %%v24,0(%%r1,%[ap0])\n\t"
  62. "vlrepg %%v25,8(%%r1,%[ap0])\n\t"
  63. "vlrepg %%v26,0(%%r1,%[ap1])\n\t"
  64. "vlrepg %%v27,8(%%r1,%[ap1])\n\t"
  65. "vlrepg %%v28,0(%%r1,%[ap2])\n\t"
  66. "vlrepg %%v29,8(%%r1,%[ap2])\n\t"
  67. "vlrepg %%v30,0(%%r1,%[ap3])\n\t"
  68. "vlrepg %%v31,8(%%r1,%[ap3])\n\t"
  69. "vfmadb %%v16,%%v24,%%v0,%%v16\n\t"
  70. "vfmadb %%v20,%%v25,%%v1,%%v20\n\t"
  71. "vfmadb %%v17,%%v26,%%v0,%%v17\n\t"
  72. "vfmadb %%v21,%%v27,%%v1,%%v21\n\t"
  73. "vfmadb %%v18,%%v28,%%v0,%%v18\n\t"
  74. "vfmadb %%v22,%%v29,%%v1,%%v22\n\t"
  75. "vfmadb %%v19,%%v30,%%v0,%%v19\n\t"
  76. "vfmadb %%v23,%%v31,%%v1,%%v23\n\t"
  77. "vl %%v0,16(%%r1,%[x])\n\t"
  78. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  79. "vleg %%v1,24(%%r1,%[x]),0\n\t"
  80. "wflcdb %%v1,%%v1\n\t"
  81. "vleg %%v1,16(%%r1,%[x]),1\n\t"
  82. #else
  83. "vleg %%v1,16(%%r1,%[x]),1\n\t"
  84. "vflcdb %%v1,%%v1\n\t"
  85. "vleg %%v1,24(%%r1,%[x]),0\n\t"
  86. #endif
  87. "vlrepg %%v24,16(%%r1,%[ap0])\n\t"
  88. "vlrepg %%v25,24(%%r1,%[ap0])\n\t"
  89. "vlrepg %%v26,16(%%r1,%[ap1])\n\t"
  90. "vlrepg %%v27,24(%%r1,%[ap1])\n\t"
  91. "vlrepg %%v28,16(%%r1,%[ap2])\n\t"
  92. "vlrepg %%v29,24(%%r1,%[ap2])\n\t"
  93. "vlrepg %%v30,16(%%r1,%[ap3])\n\t"
  94. "vlrepg %%v31,24(%%r1,%[ap3])\n\t"
  95. "vfmadb %%v16,%%v24,%%v0,%%v16\n\t"
  96. "vfmadb %%v20,%%v25,%%v1,%%v20\n\t"
  97. "vfmadb %%v17,%%v26,%%v0,%%v17\n\t"
  98. "vfmadb %%v21,%%v27,%%v1,%%v21\n\t"
  99. "vfmadb %%v18,%%v28,%%v0,%%v18\n\t"
  100. "vfmadb %%v22,%%v29,%%v1,%%v22\n\t"
  101. "vfmadb %%v19,%%v30,%%v0,%%v19\n\t"
  102. "vfmadb %%v23,%%v31,%%v1,%%v23\n\t"
  103. "agfi %%r1,32\n\t"
  104. "brctg %[n],0b\n\t"
  105. "vfadb %%v16,%%v16,%%v20\n\t"
  106. "vfadb %%v17,%%v17,%%v21\n\t"
  107. "vfadb %%v18,%%v18,%%v22\n\t"
  108. "vfadb %%v19,%%v19,%%v23\n\t"
  109. "vpdi %%v20,%%v16,%%v16,4\n\t"
  110. "vpdi %%v21,%%v17,%%v17,4\n\t"
  111. "vpdi %%v22,%%v18,%%v18,4\n\t"
  112. "vpdi %%v23,%%v19,%%v19,4\n\t"
  113. #if !defined(XCONJ)
  114. "vlrepg %%v24,0(%[alpha])\n\t"
  115. "vleg %%v25,8(%[alpha]),0\n\t"
  116. "wflcdb %%v25,%%v25\n\t"
  117. "vleg %%v25,8(%[alpha]),1\n\t"
  118. #else
  119. "vleg %%v24,0(%[alpha]),1\n\t"
  120. "vflcdb %%v24,%%v24\n\t"
  121. "vleg %%v24,0(%[alpha]),0\n\t"
  122. "vlrepg %%v25,8(%[alpha])\n\t"
  123. #endif
  124. "vl %%v26,0(%[y])\n\t"
  125. "vl %%v27,16(%[y])\n\t"
  126. "vl %%v28,32(%[y])\n\t"
  127. "vl %%v29,48(%[y])\n\t"
  128. "vfmadb %%v26,%%v16,%%v24,%%v26\n\t"
  129. "vfmadb %%v26,%%v20,%%v25,%%v26\n\t"
  130. "vfmadb %%v27,%%v17,%%v24,%%v27\n\t"
  131. "vfmadb %%v27,%%v21,%%v25,%%v27\n\t"
  132. "vfmadb %%v28,%%v18,%%v24,%%v28\n\t"
  133. "vfmadb %%v28,%%v22,%%v25,%%v28\n\t"
  134. "vfmadb %%v29,%%v19,%%v24,%%v29\n\t"
  135. "vfmadb %%v29,%%v23,%%v25,%%v29\n\t"
  136. "vst %%v26,0(%[y])\n\t"
  137. "vst %%v27,16(%[y])\n\t"
  138. "vst %%v28,32(%[y])\n\t"
  139. "vst %%v29,48(%[y])"
  140. : "+m"(*(FLOAT (*)[8]) y),[n] "+&r"(n)
  141. : [y] "a"(y), "m"(*(const FLOAT (*)[n * 2]) ap0),[ap0] "a"(ap0),
  142. "m"(*(const FLOAT (*)[n * 2]) ap1),[ap1] "a"(ap1),
  143. "m"(*(const FLOAT (*)[n * 2]) ap2),[ap2] "a"(ap2),
  144. "m"(*(const FLOAT (*)[n * 2]) ap3),[ap3] "a"(ap3),
  145. "m"(*(const FLOAT (*)[n * 2]) x),[x] "a"(x),
  146. "m"(*(const FLOAT (*)[2]) alpha),[alpha] "a"(alpha)
  147. : "cc", "r1", "v0", "v1", "v16", "v17", "v18", "v19", "v20", "v21",
  148. "v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30",
  149. "v31");
  150. }
  151. static void zgemv_kernel_4x2(BLASLONG n, FLOAT **ap, FLOAT *x, FLOAT *y,
  152. FLOAT *alpha) {
  153. register FLOAT *ap0 = ap[0];
  154. register FLOAT *ap1 = ap[1];
  155. __asm__("vzero %%v16\n\t"
  156. "vzero %%v17\n\t"
  157. "vzero %%v18\n\t"
  158. "vzero %%v19\n\t"
  159. "xgr %%r1,%%r1\n\t"
  160. "srlg %[n],%[n],1\n\t"
  161. "0:\n\t"
  162. "pfd 1,1024(%%r1,%[ap0])\n\t"
  163. "pfd 1,1024(%%r1,%[ap1])\n\t"
  164. "pfd 1,1024(%%r1,%[x])\n\t"
  165. "vl %%v0,0(%%r1,%[x])\n\t"
  166. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  167. "vleg %%v1,8(%%r1,%[x]),0\n\t"
  168. "wflcdb %%v1,%%v1\n\t"
  169. "vleg %%v1,0(%%r1,%[x]),1\n\t"
  170. #else
  171. "vleg %%v1,0(%%r1,%[x]),1\n\t"
  172. "vflcdb %%v1,%%v1\n\t"
  173. "vleg %%v1,8(%%r1,%[x]),0\n\t"
  174. #endif
  175. "vlrepg %%v20,0(%%r1,%[ap0])\n\t"
  176. "vlrepg %%v21,8(%%r1,%[ap0])\n\t"
  177. "vlrepg %%v22,0(%%r1,%[ap1])\n\t"
  178. "vlrepg %%v23,8(%%r1,%[ap1])\n\t"
  179. "vfmadb %%v16,%%v20,%%v0,%%v16\n\t"
  180. "vfmadb %%v18,%%v21,%%v1,%%v18\n\t"
  181. "vfmadb %%v17,%%v22,%%v0,%%v17\n\t"
  182. "vfmadb %%v19,%%v23,%%v1,%%v19\n\t"
  183. "vl %%v0,16(%%r1,%[x])\n\t"
  184. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  185. "vleg %%v1,24(%%r1,%[x]),0\n\t"
  186. "wflcdb %%v1,%%v1\n\t"
  187. "vleg %%v1,16(%%r1,%[x]),1\n\t"
  188. #else
  189. "vleg %%v1,16(%%r1,%[x]),1\n\t"
  190. "vflcdb %%v1,%%v1\n\t"
  191. "vleg %%v1,24(%%r1,%[x]),0\n\t"
  192. #endif
  193. "vlrepg %%v20,16(%%r1,%[ap0])\n\t"
  194. "vlrepg %%v21,24(%%r1,%[ap0])\n\t"
  195. "vlrepg %%v22,16(%%r1,%[ap1])\n\t"
  196. "vlrepg %%v23,24(%%r1,%[ap1])\n\t"
  197. "vfmadb %%v16,%%v20,%%v0,%%v16\n\t"
  198. "vfmadb %%v18,%%v21,%%v1,%%v18\n\t"
  199. "vfmadb %%v17,%%v22,%%v0,%%v17\n\t"
  200. "vfmadb %%v19,%%v23,%%v1,%%v19\n\t"
  201. "agfi %%r1,32\n\t"
  202. "brctg %[n],0b\n\t"
  203. "vfadb %%v16,%%v16,%%v18\n\t"
  204. "vfadb %%v17,%%v17,%%v19\n\t"
  205. "vpdi %%v18,%%v16,%%v16,4\n\t"
  206. "vpdi %%v19,%%v17,%%v17,4\n\t"
  207. #if !defined(XCONJ)
  208. "vlrepg %%v20,0(%[alpha])\n\t"
  209. "vleg %%v21,8(%[alpha]),0\n\t"
  210. "wflcdb %%v21,%%v21\n\t"
  211. "vleg %%v21,8(%[alpha]),1\n\t"
  212. #else
  213. "vleg %%v20,0(%[alpha]),1\n\t"
  214. "vflcdb %%v20,%%v20\n\t"
  215. "vleg %%v20,0(%[alpha]),0\n\t"
  216. "vlrepg %%v21,8(%[alpha])\n\t"
  217. #endif
  218. "vl %%v22,0(%[y])\n\t"
  219. "vl %%v23,16(%[y])\n\t"
  220. "vfmadb %%v22,%%v16,%%v20,%%v22\n\t"
  221. "vfmadb %%v22,%%v18,%%v21,%%v22\n\t"
  222. "vfmadb %%v23,%%v17,%%v20,%%v23\n\t"
  223. "vfmadb %%v23,%%v19,%%v21,%%v23\n\t"
  224. "vst %%v22,0(%[y])\n\t"
  225. "vst %%v23,16(%[y])\n\t"
  226. : "+m"(*(FLOAT (*)[4]) y),[n] "+&r"(n)
  227. : [y] "a"(y), "m"(*(const FLOAT (*)[n * 2]) ap0),[ap0] "a"(ap0),
  228. "m"(*(const FLOAT (*)[n * 2]) ap1),[ap1] "a"(ap1),
  229. "m"(*(const FLOAT (*)[n * 2]) x),[x] "a"(x),
  230. "m"(*(const FLOAT (*)[2]) alpha),[alpha] "a"(alpha)
  231. : "cc", "r1", "v0", "v1", "v16", "v17", "v18", "v19", "v20", "v21",
  232. "v22", "v23");
  233. }
  234. static void zgemv_kernel_4x1(BLASLONG n, FLOAT *ap, FLOAT *x, FLOAT *y,
  235. FLOAT *alpha) {
  236. __asm__("vzero %%v16\n\t"
  237. "vzero %%v17\n\t"
  238. "xgr %%r1,%%r1\n\t"
  239. "srlg %[n],%[n],1\n\t"
  240. "0:\n\t"
  241. "pfd 1,1024(%%r1,%[ap])\n\t"
  242. "pfd 1,1024(%%r1,%[x])\n\t"
  243. "vl %%v0,0(%%r1,%[x])\n\t"
  244. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  245. "vleg %%v1,8(%%r1,%[x]),0\n\t"
  246. "wflcdb %%v1,%%v1\n\t"
  247. "vleg %%v1,0(%%r1,%[x]),1\n\t"
  248. #else
  249. "vleg %%v1,0(%%r1,%[x]),1\n\t"
  250. "vflcdb %%v1,%%v1\n\t"
  251. "vleg %%v1,8(%%r1,%[x]),0\n\t"
  252. #endif
  253. "vlrepg %%v18,0(%%r1,%[ap])\n\t"
  254. "vlrepg %%v19,8(%%r1,%[ap])\n\t"
  255. "vfmadb %%v16,%%v18,%%v0,%%v16\n\t"
  256. "vfmadb %%v17,%%v19,%%v1,%%v17\n\t"
  257. "vl %%v0,16(%%r1,%[x])\n\t"
  258. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  259. "vleg %%v1,24(%%r1,%[x]),0\n\t"
  260. "wflcdb %%v1,%%v1\n\t"
  261. "vleg %%v1,16(%%r1,%[x]),1\n\t"
  262. #else
  263. "vleg %%v1,16(%%r1,%[x]),1\n\t"
  264. "vflcdb %%v1,%%v1\n\t"
  265. "vleg %%v1,24(%%r1,%[x]),0\n\t"
  266. #endif
  267. "vlrepg %%v18,16(%%r1,%[ap])\n\t"
  268. "vlrepg %%v19,24(%%r1,%[ap])\n\t"
  269. "vfmadb %%v16,%%v18,%%v0,%%v16\n\t"
  270. "vfmadb %%v17,%%v19,%%v1,%%v17\n\t"
  271. "agfi %%r1,32\n\t"
  272. "brctg %[n],0b\n\t"
  273. "vfadb %%v16,%%v16,%%v17\n\t"
  274. "vpdi %%v17,%%v16,%%v16,4\n\t"
  275. #if !defined(XCONJ)
  276. "vlrepg %%v18,0(%[alpha])\n\t"
  277. "vleg %%v19,8(%[alpha]),0\n\t"
  278. "wflcdb %%v19,%%v19\n\t"
  279. "vleg %%v19,8(%[alpha]),1\n\t"
  280. #else
  281. "vleg %%v18,0(%[alpha]),1\n\t"
  282. "vflcdb %%v18,%%v18\n\t"
  283. "vleg %%v18,0(%[alpha]),0\n\t"
  284. "vlrepg %%v19,8(%[alpha])\n\t"
  285. #endif
  286. "vl %%v0,0(%[y])\n\t"
  287. "vfmadb %%v0,%%v16,%%v18,%%v0\n\t"
  288. "vfmadb %%v0,%%v17,%%v19,%%v0\n\t"
  289. "vst %%v0,0(%[y])\n\t"
  290. : "+m"(*(FLOAT (*)[2]) y),[n] "+&r"(n)
  291. : [y] "a"(y), "m"(*(const FLOAT (*)[n * 2]) ap),[ap] "a"(ap),
  292. "m"(*(const FLOAT (*)[n * 2]) x),[x] "a"(x),
  293. "m"(*(const FLOAT (*)[2]) alpha),[alpha] "a"(alpha)
  294. : "cc", "r1", "v0", "v1", "v16", "v17", "v18", "v19");
  295. }
  296. static void copy_x(BLASLONG n, FLOAT *src, FLOAT *dest, BLASLONG inc_src) {
  297. BLASLONG i;
  298. for (i = 0; i < n; i++) {
  299. *dest = *src;
  300. *(dest + 1) = *(src + 1);
  301. dest += 2;
  302. src += inc_src;
  303. }
  304. }
  305. int CNAME(BLASLONG m, BLASLONG n, BLASLONG dummy1, FLOAT alpha_r, FLOAT alpha_i,
  306. FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG inc_x, FLOAT *y,
  307. BLASLONG inc_y, FLOAT *buffer) {
  308. BLASLONG i;
  309. BLASLONG j;
  310. FLOAT *a_ptr;
  311. FLOAT *x_ptr;
  312. FLOAT *y_ptr;
  313. FLOAT *ap[8];
  314. BLASLONG n1;
  315. BLASLONG m1;
  316. BLASLONG m2;
  317. BLASLONG m3;
  318. BLASLONG n2;
  319. BLASLONG lda4;
  320. FLOAT ybuffer[8], *xbuffer;
  321. FLOAT alpha[2];
  322. if (m < 1)
  323. return (0);
  324. if (n < 1)
  325. return (0);
  326. inc_x <<= 1;
  327. inc_y <<= 1;
  328. lda <<= 1;
  329. lda4 = lda << 2;
  330. xbuffer = buffer;
  331. n1 = n >> 2;
  332. n2 = n & 3;
  333. m3 = m & 3;
  334. m1 = m - m3;
  335. m2 = (m & (NBMAX - 1)) - m3;
  336. alpha[0] = alpha_r;
  337. alpha[1] = alpha_i;
  338. BLASLONG NB = NBMAX;
  339. while (NB == NBMAX) {
  340. m1 -= NB;
  341. if (m1 < 0) {
  342. if (m2 == 0)
  343. break;
  344. NB = m2;
  345. }
  346. y_ptr = y;
  347. a_ptr = a;
  348. x_ptr = x;
  349. ap[0] = a_ptr;
  350. ap[1] = a_ptr + lda;
  351. ap[2] = ap[1] + lda;
  352. ap[3] = ap[2] + lda;
  353. if (inc_x != 2)
  354. copy_x(NB, x_ptr, xbuffer, inc_x);
  355. else
  356. xbuffer = x_ptr;
  357. if (inc_y == 2) {
  358. for (i = 0; i < n1; i++) {
  359. zgemv_kernel_4x4(NB, ap, xbuffer, y_ptr, alpha);
  360. ap[0] += lda4;
  361. ap[1] += lda4;
  362. ap[2] += lda4;
  363. ap[3] += lda4;
  364. a_ptr += lda4;
  365. y_ptr += 8;
  366. }
  367. if (n2 & 2) {
  368. zgemv_kernel_4x2(NB, ap, xbuffer, y_ptr, alpha);
  369. a_ptr += lda * 2;
  370. y_ptr += 4;
  371. }
  372. if (n2 & 1) {
  373. zgemv_kernel_4x1(NB, a_ptr, xbuffer, y_ptr, alpha);
  374. /* a_ptr += lda;
  375. y_ptr += 2; */
  376. }
  377. } else {
  378. for (i = 0; i < n1; i++) {
  379. memset(ybuffer, 0, sizeof(ybuffer));
  380. zgemv_kernel_4x4(NB, ap, xbuffer, ybuffer, alpha);
  381. ap[0] += lda4;
  382. ap[1] += lda4;
  383. ap[2] += lda4;
  384. ap[3] += lda4;
  385. a_ptr += lda4;
  386. y_ptr[0] += ybuffer[0];
  387. y_ptr[1] += ybuffer[1];
  388. y_ptr += inc_y;
  389. y_ptr[0] += ybuffer[2];
  390. y_ptr[1] += ybuffer[3];
  391. y_ptr += inc_y;
  392. y_ptr[0] += ybuffer[4];
  393. y_ptr[1] += ybuffer[5];
  394. y_ptr += inc_y;
  395. y_ptr[0] += ybuffer[6];
  396. y_ptr[1] += ybuffer[7];
  397. y_ptr += inc_y;
  398. }
  399. for (i = 0; i < n2; i++) {
  400. memset(ybuffer, 0, sizeof(ybuffer));
  401. zgemv_kernel_4x1(NB, a_ptr, xbuffer, ybuffer, alpha);
  402. a_ptr += lda;
  403. y_ptr[0] += ybuffer[0];
  404. y_ptr[1] += ybuffer[1];
  405. y_ptr += inc_y;
  406. }
  407. }
  408. a += 2 * NB;
  409. x += NB * inc_x;
  410. }
  411. if (m3 == 0)
  412. return (0);
  413. x_ptr = x;
  414. j = 0;
  415. a_ptr = a;
  416. y_ptr = y;
  417. if (m3 == 3) {
  418. FLOAT temp_r;
  419. FLOAT temp_i;
  420. FLOAT x0 = x_ptr[0];
  421. FLOAT x1 = x_ptr[1];
  422. x_ptr += inc_x;
  423. FLOAT x2 = x_ptr[0];
  424. FLOAT x3 = x_ptr[1];
  425. x_ptr += inc_x;
  426. FLOAT x4 = x_ptr[0];
  427. FLOAT x5 = x_ptr[1];
  428. while (j < n) {
  429. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  430. temp_r = a_ptr[0] * x0 - a_ptr[1] * x1;
  431. temp_i = a_ptr[0] * x1 + a_ptr[1] * x0;
  432. temp_r += a_ptr[2] * x2 - a_ptr[3] * x3;
  433. temp_i += a_ptr[2] * x3 + a_ptr[3] * x2;
  434. temp_r += a_ptr[4] * x4 - a_ptr[5] * x5;
  435. temp_i += a_ptr[4] * x5 + a_ptr[5] * x4;
  436. #else
  437. temp_r = a_ptr[0] * x0 + a_ptr[1] * x1;
  438. temp_i = a_ptr[0] * x1 - a_ptr[1] * x0;
  439. temp_r += a_ptr[2] * x2 + a_ptr[3] * x3;
  440. temp_i += a_ptr[2] * x3 - a_ptr[3] * x2;
  441. temp_r += a_ptr[4] * x4 + a_ptr[5] * x5;
  442. temp_i += a_ptr[4] * x5 - a_ptr[5] * x4;
  443. #endif
  444. #if !defined(XCONJ)
  445. y_ptr[0] += alpha_r * temp_r - alpha_i * temp_i;
  446. y_ptr[1] += alpha_r * temp_i + alpha_i * temp_r;
  447. #else
  448. y_ptr[0] += alpha_r * temp_r + alpha_i * temp_i;
  449. y_ptr[1] -= alpha_r * temp_i - alpha_i * temp_r;
  450. #endif
  451. a_ptr += lda;
  452. y_ptr += inc_y;
  453. j++;
  454. }
  455. return (0);
  456. }
  457. if (m3 == 2) {
  458. FLOAT temp_r;
  459. FLOAT temp_i;
  460. FLOAT temp_r1;
  461. FLOAT temp_i1;
  462. FLOAT x0 = x_ptr[0];
  463. FLOAT x1 = x_ptr[1];
  464. x_ptr += inc_x;
  465. FLOAT x2 = x_ptr[0];
  466. FLOAT x3 = x_ptr[1];
  467. FLOAT ar = alpha[0];
  468. FLOAT ai = alpha[1];
  469. while (j < (n & -2)) {
  470. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  471. temp_r = a_ptr[0] * x0 - a_ptr[1] * x1;
  472. temp_i = a_ptr[0] * x1 + a_ptr[1] * x0;
  473. temp_r += a_ptr[2] * x2 - a_ptr[3] * x3;
  474. temp_i += a_ptr[2] * x3 + a_ptr[3] * x2;
  475. a_ptr += lda;
  476. temp_r1 = a_ptr[0] * x0 - a_ptr[1] * x1;
  477. temp_i1 = a_ptr[0] * x1 + a_ptr[1] * x0;
  478. temp_r1 += a_ptr[2] * x2 - a_ptr[3] * x3;
  479. temp_i1 += a_ptr[2] * x3 + a_ptr[3] * x2;
  480. #else
  481. temp_r = a_ptr[0] * x0 + a_ptr[1] * x1;
  482. temp_i = a_ptr[0] * x1 - a_ptr[1] * x0;
  483. temp_r += a_ptr[2] * x2 + a_ptr[3] * x3;
  484. temp_i += a_ptr[2] * x3 - a_ptr[3] * x2;
  485. a_ptr += lda;
  486. temp_r1 = a_ptr[0] * x0 + a_ptr[1] * x1;
  487. temp_i1 = a_ptr[0] * x1 - a_ptr[1] * x0;
  488. temp_r1 += a_ptr[2] * x2 + a_ptr[3] * x3;
  489. temp_i1 += a_ptr[2] * x3 - a_ptr[3] * x2;
  490. #endif
  491. #if !defined(XCONJ)
  492. y_ptr[0] += ar * temp_r - ai * temp_i;
  493. y_ptr[1] += ar * temp_i + ai * temp_r;
  494. y_ptr += inc_y;
  495. y_ptr[0] += ar * temp_r1 - ai * temp_i1;
  496. y_ptr[1] += ar * temp_i1 + ai * temp_r1;
  497. #else
  498. y_ptr[0] += ar * temp_r + ai * temp_i;
  499. y_ptr[1] -= ar * temp_i - ai * temp_r;
  500. y_ptr += inc_y;
  501. y_ptr[0] += ar * temp_r1 + ai * temp_i1;
  502. y_ptr[1] -= ar * temp_i1 - ai * temp_r1;
  503. #endif
  504. a_ptr += lda;
  505. y_ptr += inc_y;
  506. j += 2;
  507. }
  508. while (j < n) {
  509. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  510. temp_r = a_ptr[0] * x0 - a_ptr[1] * x1;
  511. temp_i = a_ptr[0] * x1 + a_ptr[1] * x0;
  512. temp_r += a_ptr[2] * x2 - a_ptr[3] * x3;
  513. temp_i += a_ptr[2] * x3 + a_ptr[3] * x2;
  514. #else
  515. temp_r = a_ptr[0] * x0 + a_ptr[1] * x1;
  516. temp_i = a_ptr[0] * x1 - a_ptr[1] * x0;
  517. temp_r += a_ptr[2] * x2 + a_ptr[3] * x3;
  518. temp_i += a_ptr[2] * x3 - a_ptr[3] * x2;
  519. #endif
  520. #if !defined(XCONJ)
  521. y_ptr[0] += ar * temp_r - ai * temp_i;
  522. y_ptr[1] += ar * temp_i + ai * temp_r;
  523. #else
  524. y_ptr[0] += ar * temp_r + ai * temp_i;
  525. y_ptr[1] -= ar * temp_i - ai * temp_r;
  526. #endif
  527. a_ptr += lda;
  528. y_ptr += inc_y;
  529. j++;
  530. }
  531. return (0);
  532. }
  533. if (m3 == 1) {
  534. FLOAT temp_r;
  535. FLOAT temp_i;
  536. FLOAT temp_r1;
  537. FLOAT temp_i1;
  538. FLOAT x0 = x_ptr[0];
  539. FLOAT x1 = x_ptr[1];
  540. FLOAT ar = alpha[0];
  541. FLOAT ai = alpha[1];
  542. while (j < (n & -2)) {
  543. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  544. temp_r = a_ptr[0] * x0 - a_ptr[1] * x1;
  545. temp_i = a_ptr[0] * x1 + a_ptr[1] * x0;
  546. a_ptr += lda;
  547. temp_r1 = a_ptr[0] * x0 - a_ptr[1] * x1;
  548. temp_i1 = a_ptr[0] * x1 + a_ptr[1] * x0;
  549. #else
  550. temp_r = a_ptr[0] * x0 + a_ptr[1] * x1;
  551. temp_i = a_ptr[0] * x1 - a_ptr[1] * x0;
  552. a_ptr += lda;
  553. temp_r1 = a_ptr[0] * x0 + a_ptr[1] * x1;
  554. temp_i1 = a_ptr[0] * x1 - a_ptr[1] * x0;
  555. #endif
  556. #if !defined(XCONJ)
  557. y_ptr[0] += ar * temp_r - ai * temp_i;
  558. y_ptr[1] += ar * temp_i + ai * temp_r;
  559. y_ptr += inc_y;
  560. y_ptr[0] += ar * temp_r1 - ai * temp_i1;
  561. y_ptr[1] += ar * temp_i1 + ai * temp_r1;
  562. #else
  563. y_ptr[0] += ar * temp_r + ai * temp_i;
  564. y_ptr[1] -= ar * temp_i - ai * temp_r;
  565. y_ptr += inc_y;
  566. y_ptr[0] += ar * temp_r1 + ai * temp_i1;
  567. y_ptr[1] -= ar * temp_i1 - ai * temp_r1;
  568. #endif
  569. a_ptr += lda;
  570. y_ptr += inc_y;
  571. j += 2;
  572. }
  573. while (j < n) {
  574. #if ( !defined(CONJ) && !defined(XCONJ) ) || ( defined(CONJ) && defined(XCONJ) )
  575. temp_r = a_ptr[0] * x0 - a_ptr[1] * x1;
  576. temp_i = a_ptr[0] * x1 + a_ptr[1] * x0;
  577. #else
  578. temp_r = a_ptr[0] * x0 + a_ptr[1] * x1;
  579. temp_i = a_ptr[0] * x1 - a_ptr[1] * x0;
  580. #endif
  581. #if !defined(XCONJ)
  582. y_ptr[0] += ar * temp_r - ai * temp_i;
  583. y_ptr[1] += ar * temp_i + ai * temp_r;
  584. #else
  585. y_ptr[0] += ar * temp_r + ai * temp_i;
  586. y_ptr[1] -= ar * temp_i - ai * temp_r;
  587. #endif
  588. a_ptr += lda;
  589. y_ptr += inc_y;
  590. j++;
  591. }
  592. return (0);
  593. }
  594. return (0);
  595. }