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.

cgemv_n_msa.c 26 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /*******************************************************************************
  2. Copyright (c) 2016, 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. #include "macros_msa.h"
  29. #undef OP0
  30. #undef OP1
  31. #undef OP2
  32. #undef OP3
  33. #undef OP4
  34. #if !defined(XCONJ)
  35. #define OP3 -=
  36. #define OP4 +=
  37. #else
  38. #define OP3 +=
  39. #define OP4 -=
  40. #endif
  41. #if !defined(CONJ)
  42. #if !defined(XCONJ)
  43. #define OP0 -=
  44. #define OP1 +=
  45. #define OP2 +=
  46. #else
  47. #define OP0 +=
  48. #define OP1 +=
  49. #define OP2 -=
  50. #endif
  51. #else
  52. #if !defined(XCONJ)
  53. #define OP0 +=
  54. #define OP1 -=
  55. #define OP2 -=
  56. #else
  57. #define OP0 -=
  58. #define OP1 -=
  59. #define OP2 +=
  60. #endif
  61. #endif
  62. #define CGEMV_N_8x4() \
  63. LD_SP4(pa0 + k, 4, t0, t1, t2, t3); \
  64. LD_SP4(pa1 + k, 4, t4, t5, t6, t7); \
  65. LD_SP4(pa2 + k, 4, t8, t9, t10, t11); \
  66. LD_SP4(pa3 + k, 4, t12, t13, t14, t15); \
  67. \
  68. PCKEVOD_W2_SP(t1, t0, src0r, src0i); \
  69. PCKEVOD_W2_SP(t3, t2, src1r, src1i); \
  70. PCKEVOD_W2_SP(t5, t4, src2r, src2i); \
  71. PCKEVOD_W2_SP(t7, t6, src3r, src3i); \
  72. PCKEVOD_W2_SP(t9, t8, src4r, src4i); \
  73. PCKEVOD_W2_SP(t11, t10, src5r, src5i); \
  74. PCKEVOD_W2_SP(t13, t12, src6r, src6i); \
  75. PCKEVOD_W2_SP(t15, t14, src7r, src7i); \
  76. \
  77. y0r += tp0r * src0r; \
  78. y1r += tp0r * src1r; \
  79. y0r += tp1r * src2r; \
  80. y1r += tp1r * src3r; \
  81. y0r += tp2r * src4r; \
  82. y1r += tp2r * src5r; \
  83. y0r += tp3r * src6r; \
  84. y1r += tp3r * src7r; \
  85. \
  86. y0r OP0 tp0i * src0i; \
  87. y1r OP0 tp0i * src1i; \
  88. y0r OP0 tp1i * src2i; \
  89. y1r OP0 tp1i * src3i; \
  90. y0r OP0 tp2i * src4i; \
  91. y1r OP0 tp2i * src5i; \
  92. y0r OP0 tp3i * src6i; \
  93. y1r OP0 tp3i * src7i; \
  94. \
  95. y0i OP1 tp0r * src0i; \
  96. y1i OP1 tp0r * src1i; \
  97. y0i OP1 tp1r * src2i; \
  98. y1i OP1 tp1r * src3i; \
  99. y0i OP1 tp2r * src4i; \
  100. y1i OP1 tp2r * src5i; \
  101. y0i OP1 tp3r * src6i; \
  102. y1i OP1 tp3r * src7i; \
  103. \
  104. y0i OP2 tp0i * src0r; \
  105. y1i OP2 tp0i * src1r; \
  106. y0i OP2 tp1i * src2r; \
  107. y1i OP2 tp1i * src3r; \
  108. y0i OP2 tp2i * src4r; \
  109. y1i OP2 tp2i * src5r; \
  110. y0i OP2 tp3i * src6r; \
  111. y1i OP2 tp3i * src7r; \
  112. #define CGEMV_N_4x4() \
  113. LD_SP2(pa0 + k, 4, t0, t1); \
  114. LD_SP2(pa1 + k, 4, t4, t5); \
  115. LD_SP2(pa2 + k, 4, t8, t9); \
  116. LD_SP2(pa3 + k, 4, t12, t13); \
  117. \
  118. PCKEVOD_W2_SP(t1, t0, src0r, src0i); \
  119. PCKEVOD_W2_SP(t5, t4, src2r, src2i); \
  120. PCKEVOD_W2_SP(t9, t8, src4r, src4i); \
  121. PCKEVOD_W2_SP(t13, t12, src6r, src6i); \
  122. \
  123. y0r += tp0r * src0r; \
  124. y0r += tp1r * src2r; \
  125. y0r += tp2r * src4r; \
  126. y0r += tp3r * src6r; \
  127. \
  128. y0r OP0 tp0i * src0i; \
  129. y0r OP0 tp1i * src2i; \
  130. y0r OP0 tp2i * src4i; \
  131. y0r OP0 tp3i * src6i; \
  132. \
  133. y0i OP1 tp0r * src0i; \
  134. y0i OP1 tp1r * src2i; \
  135. y0i OP1 tp2r * src4i; \
  136. y0i OP1 tp3r * src6i; \
  137. \
  138. y0i OP2 tp0i * src0r; \
  139. y0i OP2 tp1i * src2r; \
  140. y0i OP2 tp2i * src4r; \
  141. y0i OP2 tp3i * src6r; \
  142. #define CGEMV_N_1x4() \
  143. res0 = y[0 * inc_y2]; \
  144. res1 = y[0 * inc_y2 + 1]; \
  145. \
  146. res0 += temp0_r * pa0[k]; \
  147. res0 OP0 temp0_i * pa0[k + 1]; \
  148. res0 += temp1_r * pa1[k]; \
  149. res0 OP0 temp1_i * pa1[k + 1]; \
  150. res0 += temp2_r * pa2[k]; \
  151. res0 OP0 temp2_i * pa2[k + 1]; \
  152. res0 += temp3_r * pa3[k]; \
  153. res0 OP0 temp3_i * pa3[k + 1]; \
  154. \
  155. res1 OP1 temp0_r * pa0[k + 1]; \
  156. res1 OP2 temp0_i * pa0[k]; \
  157. res1 OP1 temp1_r * pa1[k + 1]; \
  158. res1 OP2 temp1_i * pa1[k]; \
  159. res1 OP1 temp2_r * pa2[k + 1]; \
  160. res1 OP2 temp2_i * pa2[k]; \
  161. res1 OP1 temp3_r * pa3[k + 1]; \
  162. res1 OP2 temp3_i * pa3[k]; \
  163. \
  164. y[0 * inc_y2] = res0; \
  165. y[0 * inc_y2 + 1] = res1; \
  166. #define CGEMV_N_8x2() \
  167. LD_SP4(pa0 + k, 4, t0, t1, t2, t3); \
  168. LD_SP4(pa1 + k, 4, t4, t5, t6, t7); \
  169. \
  170. PCKEVOD_W2_SP(t1, t0, src0r, src0i); \
  171. PCKEVOD_W2_SP(t3, t2, src1r, src1i); \
  172. PCKEVOD_W2_SP(t5, t4, src2r, src2i); \
  173. PCKEVOD_W2_SP(t7, t6, src3r, src3i); \
  174. \
  175. y0r += tp0r * src0r; \
  176. y1r += tp0r * src1r; \
  177. y0r += tp1r * src2r; \
  178. y1r += tp1r * src3r; \
  179. \
  180. y0r OP0 tp0i * src0i; \
  181. y1r OP0 tp0i * src1i; \
  182. y0r OP0 tp1i * src2i; \
  183. y1r OP0 tp1i * src3i; \
  184. \
  185. y0i OP1 tp0r * src0i; \
  186. y1i OP1 tp0r * src1i; \
  187. y0i OP1 tp1r * src2i; \
  188. y1i OP1 tp1r * src3i; \
  189. \
  190. y0i OP2 tp0i * src0r; \
  191. y1i OP2 tp0i * src1r; \
  192. y0i OP2 tp1i * src2r; \
  193. y1i OP2 tp1i * src3r; \
  194. #define CGEMV_N_4x2() \
  195. LD_SP2(pa0 + k, 4, t0, t1); \
  196. LD_SP2(pa1 + k, 4, t4, t5); \
  197. \
  198. PCKEVOD_W2_SP(t1, t0, src0r, src0i); \
  199. PCKEVOD_W2_SP(t5, t4, src2r, src2i); \
  200. \
  201. y0r += tp0r * src0r; \
  202. y0r += tp1r * src2r; \
  203. \
  204. y0r OP0 tp0i * src0i; \
  205. y0r OP0 tp1i * src2i; \
  206. \
  207. y0i OP1 tp0r * src0i; \
  208. y0i OP1 tp1r * src2i; \
  209. \
  210. y0i OP2 tp0i * src0r; \
  211. y0i OP2 tp1i * src2r; \
  212. #define CGEMV_N_1x2() \
  213. res0 = y[0 * inc_y2]; \
  214. res1 = y[0 * inc_y2 + 1]; \
  215. \
  216. res0 += temp0_r * pa0[k]; \
  217. res0 OP0 temp0_i * pa0[k + 1]; \
  218. res0 += temp1_r * pa1[k]; \
  219. res0 OP0 temp1_i * pa1[k + 1]; \
  220. \
  221. res1 OP1 temp0_r * pa0[k + 1]; \
  222. res1 OP2 temp0_i * pa0[k]; \
  223. res1 OP1 temp1_r * pa1[k + 1]; \
  224. res1 OP2 temp1_i * pa1[k]; \
  225. \
  226. y[0 * inc_y2] = res0; \
  227. y[0 * inc_y2 + 1] = res1; \
  228. #define CGEMV_N_1x1() \
  229. res0 = y[0 * inc_y2]; \
  230. res1 = y[0 * inc_y2 + 1]; \
  231. \
  232. res0 += temp_r * pa0[k]; \
  233. res0 OP0 temp_i * pa0[k + 1]; \
  234. \
  235. res1 OP1 temp_r * pa0[k + 1]; \
  236. res1 OP2 temp_i * pa0[k]; \
  237. \
  238. y[0 * inc_y2] = res0; \
  239. y[0 * inc_y2 + 1] = res1; \
  240. #define CLOAD_X4_SCALE_VECTOR() \
  241. LD_SP2(x, 4, x0, x1); \
  242. \
  243. PCKEVOD_W2_SP(x1, x0, x0r, x0i); \
  244. \
  245. tp4r = alphar * x0r; \
  246. tp4r OP3 alphai * x0i; \
  247. tp4i = alphar * x0i; \
  248. tp4i OP4 alphai * x0r; \
  249. \
  250. SPLATI_W4_SP(tp4r, tp0r, tp1r, tp2r, tp3r); \
  251. SPLATI_W4_SP(tp4i, tp0i, tp1i, tp2i, tp3i); \
  252. #define CLOAD_X4_SCALE_GP() \
  253. x0r = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *) (x + 0 * inc_x2))); \
  254. x0r = (v4f32) __msa_insert_w((v4i32) x0r, 1, *((int *) (x + 1 * inc_x2))); \
  255. x0r = (v4f32) __msa_insert_w((v4i32) x0r, 2, *((int *) (x + 2 * inc_x2))); \
  256. x0r = (v4f32) __msa_insert_w((v4i32) x0r, 3, *((int *) (x + 3 * inc_x2))); \
  257. x0i = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *) (x + 0 * inc_x2 + 1))); \
  258. x0i = (v4f32) __msa_insert_w((v4i32) x0i, 1, *((int *) (x + 1 * inc_x2 + 1))); \
  259. x0i = (v4f32) __msa_insert_w((v4i32) x0i, 2, *((int *) (x + 2 * inc_x2 + 1))); \
  260. x0i = (v4f32) __msa_insert_w((v4i32) x0i, 3, *((int *) (x + 3 * inc_x2 + 1))); \
  261. \
  262. tp4r = alphar * x0r; \
  263. tp4r OP3 alphai * x0i; \
  264. tp4i = alphar * x0i; \
  265. tp4i OP4 alphai * x0r; \
  266. \
  267. SPLATI_W4_SP(tp4r, tp0r, tp1r, tp2r, tp3r); \
  268. SPLATI_W4_SP(tp4i, tp0i, tp1i, tp2i, tp3i); \
  269. #define CLOAD_X2_SCALE_GP() \
  270. temp0_r = alpha_r * x[0 * inc_x2]; \
  271. temp0_r OP3 alpha_i * x[0 * inc_x2 + 1]; \
  272. temp0_i = alpha_r * x[0 * inc_x2 + 1]; \
  273. temp0_i OP4 alpha_i * x[0 * inc_x2]; \
  274. \
  275. temp1_r = alpha_r * x[1 * inc_x2]; \
  276. temp1_r OP3 alpha_i * x[1 * inc_x2 + 1]; \
  277. temp1_i = alpha_r * x[1 * inc_x2 + 1]; \
  278. temp1_i OP4 alpha_i * x[1 * inc_x2]; \
  279. \
  280. tp0r = (v4f32) COPY_FLOAT_TO_VECTOR(temp0_r); \
  281. tp0i = (v4f32) COPY_FLOAT_TO_VECTOR(temp0_i); \
  282. tp1r = (v4f32) COPY_FLOAT_TO_VECTOR(temp1_r); \
  283. tp1i = (v4f32) COPY_FLOAT_TO_VECTOR(temp1_i); \
  284. #define CLOAD_X1_SCALE_GP() \
  285. temp_r = alpha_r * x[0 * inc_x2]; \
  286. temp_r OP3 alpha_i * x[0 * inc_x2 + 1]; \
  287. temp_i = alpha_r * x[0 * inc_x2 + 1]; \
  288. temp_i OP4 alpha_i * x[0 * inc_x2]; \
  289. #define CLOAD_Y8_VECTOR() \
  290. LD_SP4(y, 4, y0, y1, y2, y3); \
  291. PCKEVOD_W2_SP(y1, y0, y0r, y0i); \
  292. PCKEVOD_W2_SP(y3, y2, y1r, y1i); \
  293. #define CLOAD_Y4_VECTOR() \
  294. LD_SP2(y, 4, y0, y1); \
  295. PCKEVOD_W2_SP(y1, y0, y0r, y0i); \
  296. #define CSTORE_Y8_VECTOR() \
  297. ILVRL_W2_SP(y0i, y0r, y0, y1); \
  298. ILVRL_W2_SP(y1i, y1r, y2, y3); \
  299. ST_SP4(y0, y1, y2, y3, y, 4); \
  300. #define CSTORE_Y4_VECTOR() \
  301. ILVRL_W2_SP(y0i, y0r, y0, y1); \
  302. ST_SP2(y0, y1, y, 4); \
  303. #define CLOAD_Y8_GP() \
  304. y0r = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *)(y + 0 * inc_y2))); \
  305. y0r = (v4f32) __msa_insert_w((v4i32) y0r, 1, *((int *)(y + 1 * inc_y2))); \
  306. y0r = (v4f32) __msa_insert_w((v4i32) y0r, 2, *((int *)(y + 2 * inc_y2))); \
  307. y0r = (v4f32) __msa_insert_w((v4i32) y0r, 3, *((int *)(y + 3 * inc_y2))); \
  308. y1r = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *)(y + 4 * inc_y2))); \
  309. y1r = (v4f32) __msa_insert_w((v4i32) y1r, 1, *((int *)(y + 5 * inc_y2))); \
  310. y1r = (v4f32) __msa_insert_w((v4i32) y1r, 2, *((int *)(y + 6 * inc_y2))); \
  311. y1r = (v4f32) __msa_insert_w((v4i32) y1r, 3, *((int *)(y + 7 * inc_y2))); \
  312. y0i = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *)(y + 0 * inc_y2 + 1))); \
  313. y0i = (v4f32) __msa_insert_w((v4i32) y0i, 1, *((int *)(y + 1 * inc_y2 + 1))); \
  314. y0i = (v4f32) __msa_insert_w((v4i32) y0i, 2, *((int *)(y + 2 * inc_y2 + 1))); \
  315. y0i = (v4f32) __msa_insert_w((v4i32) y0i, 3, *((int *)(y + 3 * inc_y2 + 1))); \
  316. y1i = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *)(y + 4 * inc_y2 + 1))); \
  317. y1i = (v4f32) __msa_insert_w((v4i32) y1i, 1, *((int *)(y + 5 * inc_y2 + 1))); \
  318. y1i = (v4f32) __msa_insert_w((v4i32) y1i, 2, *((int *)(y + 6 * inc_y2 + 1))); \
  319. y1i = (v4f32) __msa_insert_w((v4i32) y1i, 3, *((int *)(y + 7 * inc_y2 + 1))); \
  320. #define CLOAD_Y4_GP() \
  321. y0r = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *)(y + 0 * inc_y2))); \
  322. y0r = (v4f32) __msa_insert_w((v4i32) y0r, 1, *((int *)(y + 1 * inc_y2))); \
  323. y0r = (v4f32) __msa_insert_w((v4i32) y0r, 2, *((int *)(y + 2 * inc_y2))); \
  324. y0r = (v4f32) __msa_insert_w((v4i32) y0r, 3, *((int *)(y + 3 * inc_y2))); \
  325. y0i = (v4f32) __msa_insert_w((v4i32) tp0r, 0, *((int *)(y + 0 * inc_y2 + 1))); \
  326. y0i = (v4f32) __msa_insert_w((v4i32) y0i, 1, *((int *)(y + 1 * inc_y2 + 1))); \
  327. y0i = (v4f32) __msa_insert_w((v4i32) y0i, 2, *((int *)(y + 2 * inc_y2 + 1))); \
  328. y0i = (v4f32) __msa_insert_w((v4i32) y0i, 3, *((int *)(y + 3 * inc_y2 + 1))); \
  329. #define CSTORE_Y8_GP() \
  330. *((int *)(y + 0 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 0); \
  331. *((int *)(y + 1 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 1); \
  332. *((int *)(y + 2 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 2); \
  333. *((int *)(y + 3 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 3); \
  334. *((int *)(y + 4 * inc_y2)) = __msa_copy_s_w((v4i32) y1r, 0); \
  335. *((int *)(y + 5 * inc_y2)) = __msa_copy_s_w((v4i32) y1r, 1); \
  336. *((int *)(y + 6 * inc_y2)) = __msa_copy_s_w((v4i32) y1r, 2); \
  337. *((int *)(y + 7 * inc_y2)) = __msa_copy_s_w((v4i32) y1r, 3); \
  338. *((int *)(y + 0 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 0); \
  339. *((int *)(y + 1 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 1); \
  340. *((int *)(y + 2 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 2); \
  341. *((int *)(y + 3 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 3); \
  342. *((int *)(y + 4 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y1i, 0); \
  343. *((int *)(y + 5 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y1i, 1); \
  344. *((int *)(y + 6 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y1i, 2); \
  345. *((int *)(y + 7 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y1i, 3); \
  346. #define CSTORE_Y4_GP() \
  347. *((int *)(y + 0 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 0); \
  348. *((int *)(y + 1 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 1); \
  349. *((int *)(y + 2 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 2); \
  350. *((int *)(y + 3 * inc_y2)) = __msa_copy_s_w((v4i32) y0r, 3); \
  351. *((int *)(y + 0 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 0); \
  352. *((int *)(y + 1 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 1); \
  353. *((int *)(y + 2 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 2); \
  354. *((int *)(y + 3 * inc_y2 + 1)) = __msa_copy_s_w((v4i32) y0i, 3); \
  355. #define CGEMV_N_MSA() \
  356. for (j = (n >> 2); j--;) \
  357. { \
  358. CLOAD_X4_SCALE(); \
  359. \
  360. k = 0; \
  361. y = y_org; \
  362. \
  363. for (i = (m >> 3); i--;) \
  364. { \
  365. CLOAD_Y8() \
  366. CGEMV_N_8x4(); \
  367. CSTORE_Y8(); \
  368. \
  369. k += 2 * 8; \
  370. y += inc_y2 * 8; \
  371. } \
  372. \
  373. if (m & 4) \
  374. { \
  375. CLOAD_Y4(); \
  376. CGEMV_N_4x4(); \
  377. CSTORE_Y4(); \
  378. \
  379. k += 2 * 4; \
  380. y += inc_y2 * 4; \
  381. } \
  382. \
  383. if (m & 3) \
  384. { \
  385. temp0_r = tp4r[0]; \
  386. temp1_r = tp4r[1]; \
  387. temp2_r = tp4r[2]; \
  388. temp3_r = tp4r[3]; \
  389. \
  390. temp0_i = tp4i[0]; \
  391. temp1_i = tp4i[1]; \
  392. temp2_i = tp4i[2]; \
  393. temp3_i = tp4i[3]; \
  394. \
  395. for (i = (m & 3); i--;) \
  396. { \
  397. CGEMV_N_1x4(); \
  398. \
  399. k += 2; \
  400. y += inc_y2; \
  401. } \
  402. } \
  403. \
  404. pa0 += 4 * lda2; \
  405. pa1 += 4 * lda2; \
  406. pa2 += 4 * lda2; \
  407. pa3 += 4 * lda2; \
  408. \
  409. x += 4 * inc_x2; \
  410. } \
  411. \
  412. if (n & 2) \
  413. { \
  414. CLOAD_X2_SCALE(); \
  415. \
  416. k = 0; \
  417. y = y_org; \
  418. \
  419. for (i = (m >> 3); i--;) \
  420. { \
  421. CLOAD_Y8(); \
  422. CGEMV_N_8x2(); \
  423. CSTORE_Y8(); \
  424. \
  425. k += 2 * 8; \
  426. y += inc_y2 * 8; \
  427. } \
  428. \
  429. if (m & 4) \
  430. { \
  431. CLOAD_Y4(); \
  432. CGEMV_N_4x2(); \
  433. CSTORE_Y4(); \
  434. \
  435. k += 2 * 4; \
  436. y += inc_y2 * 4; \
  437. } \
  438. \
  439. for (i = (m & 3); i--;) \
  440. { \
  441. CGEMV_N_1x2(); \
  442. \
  443. k += 2; \
  444. y += inc_y2; \
  445. } \
  446. \
  447. pa0 += 2 * lda2; \
  448. pa1 += 2 * lda2; \
  449. \
  450. x += 2 * inc_x2; \
  451. } \
  452. \
  453. if (n & 1) \
  454. { \
  455. CLOAD_X1_SCALE(); \
  456. \
  457. k = 0; \
  458. y = y_org; \
  459. \
  460. for (i = m; i--;) \
  461. { \
  462. CGEMV_N_1x1(); \
  463. \
  464. k += 2; \
  465. y += inc_y2; \
  466. } \
  467. \
  468. pa0 += lda2; \
  469. x += inc_x2; \
  470. } \
  471. int CNAME(BLASLONG m, BLASLONG n, BLASLONG dummy1, FLOAT alpha_r, FLOAT alpha_i,
  472. FLOAT *A, BLASLONG lda2, FLOAT *x, BLASLONG inc_x2, FLOAT *y,
  473. BLASLONG inc_y2, FLOAT *buffer)
  474. {
  475. BLASLONG i, j, k;
  476. FLOAT *y_org = y;
  477. FLOAT *pa0, *pa1, *pa2, *pa3;
  478. FLOAT temp_r, temp_i, res0, res1, temp0_r;
  479. FLOAT temp0_i, temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i;
  480. v4f32 alphar, alphai;
  481. v4f32 x0, x1, y0, y1, y2, y3, x0r, x0i, y0r, y1r, y0i, y1i;
  482. v4f32 t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
  483. v4f32 src0r, src1r, src2r, src3r, src4r, src5r, src6r, src7r;
  484. v4f32 src0i, src1i, src2i, src3i, src4i, src5i, src6i, src7i;
  485. v4f32 tp0r, tp1r, tp2r, tp3r, tp4r, tp0i, tp1i, tp2i, tp3i, tp4i;
  486. lda2 = 2 * lda2;
  487. inc_x2 = 2 * inc_x2;
  488. inc_y2 = 2 * inc_y2;
  489. pa0 = A;
  490. pa1 = A + lda2;
  491. pa2 = A + 2 * lda2;
  492. pa3 = A + 3 * lda2;
  493. alphar = COPY_FLOAT_TO_VECTOR(alpha_r);
  494. alphai = COPY_FLOAT_TO_VECTOR(alpha_i);
  495. if ((2 == inc_x2) && (2 == inc_y2))
  496. {
  497. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_VECTOR
  498. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  499. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  500. #define CLOAD_Y8 CLOAD_Y8_VECTOR
  501. #define CLOAD_Y4 CLOAD_Y4_VECTOR
  502. #define CSTORE_Y8 CSTORE_Y8_VECTOR
  503. #define CSTORE_Y4 CSTORE_Y4_VECTOR
  504. CGEMV_N_MSA();
  505. #undef CLOAD_X4_SCALE
  506. #undef CLOAD_X2_SCALE
  507. #undef CLOAD_X1_SCALE
  508. #undef CLOAD_Y8
  509. #undef CLOAD_Y4
  510. #undef CSTORE_Y8
  511. #undef CSTORE_Y4
  512. }
  513. else if (2 == inc_x2)
  514. {
  515. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_VECTOR
  516. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  517. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  518. #define CLOAD_Y8 CLOAD_Y8_GP
  519. #define CLOAD_Y4 CLOAD_Y4_GP
  520. #define CSTORE_Y8 CSTORE_Y8_GP
  521. #define CSTORE_Y4 CSTORE_Y4_GP
  522. CGEMV_N_MSA();
  523. #undef CLOAD_X4_SCALE
  524. #undef CLOAD_X2_SCALE
  525. #undef CLOAD_X1_SCALE
  526. #undef CLOAD_Y8
  527. #undef CLOAD_Y4
  528. #undef CSTORE_Y8
  529. #undef CSTORE_Y4
  530. }
  531. else if (2 == inc_y2)
  532. {
  533. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_GP
  534. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  535. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  536. #define CLOAD_Y8 CLOAD_Y8_VECTOR
  537. #define CLOAD_Y4 CLOAD_Y4_VECTOR
  538. #define CSTORE_Y8 CSTORE_Y8_VECTOR
  539. #define CSTORE_Y4 CSTORE_Y4_VECTOR
  540. CGEMV_N_MSA();
  541. #undef CLOAD_X4_SCALE
  542. #undef CLOAD_X2_SCALE
  543. #undef CLOAD_X1_SCALE
  544. #undef CLOAD_Y8
  545. #undef CLOAD_Y4
  546. #undef CSTORE_Y8
  547. #undef CSTORE_Y4
  548. }
  549. else
  550. {
  551. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_GP
  552. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  553. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  554. #define CLOAD_Y8 CLOAD_Y8_GP
  555. #define CLOAD_Y4 CLOAD_Y4_GP
  556. #define CSTORE_Y8 CSTORE_Y8_GP
  557. #define CSTORE_Y4 CSTORE_Y4_GP
  558. CGEMV_N_MSA();
  559. #undef CLOAD_X4_SCALE
  560. #undef CLOAD_X2_SCALE
  561. #undef CLOAD_X1_SCALE
  562. #undef CLOAD_Y8
  563. #undef CLOAD_Y4
  564. #undef CSTORE_Y8
  565. #undef CSTORE_Y4
  566. }
  567. return(0);
  568. }
  569. #undef OP0
  570. #undef OP1
  571. #undef OP2
  572. #undef OP3
  573. #undef OP4