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