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 28 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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. k_pref = pref_offset; \
  362. y = y_org; \
  363. \
  364. for (i = (m >> 3); i--;) \
  365. { \
  366. PREFETCH(pa0 + k_pref + 16 + 0); \
  367. PREFETCH(pa0 + k_pref + 16 + 8); \
  368. PREFETCH(pa1 + k_pref + 16 + 0); \
  369. PREFETCH(pa1 + k_pref + 16 + 8); \
  370. PREFETCH(pa2 + k_pref + 16 + 0); \
  371. PREFETCH(pa2 + k_pref + 16 + 8); \
  372. PREFETCH(pa3 + k_pref + 16 + 0); \
  373. PREFETCH(pa3 + k_pref + 16 + 8); \
  374. \
  375. CLOAD_Y8() \
  376. CGEMV_N_8x4(); \
  377. CSTORE_Y8(); \
  378. \
  379. k += 2 * 8; \
  380. k_pref += 2 * 8; \
  381. y += inc_y2 * 8; \
  382. } \
  383. \
  384. if (m & 4) \
  385. { \
  386. CLOAD_Y4(); \
  387. CGEMV_N_4x4(); \
  388. CSTORE_Y4(); \
  389. \
  390. k += 2 * 4; \
  391. y += inc_y2 * 4; \
  392. } \
  393. \
  394. if (m & 3) \
  395. { \
  396. temp0_r = tp4r[0]; \
  397. temp1_r = tp4r[1]; \
  398. temp2_r = tp4r[2]; \
  399. temp3_r = tp4r[3]; \
  400. \
  401. temp0_i = tp4i[0]; \
  402. temp1_i = tp4i[1]; \
  403. temp2_i = tp4i[2]; \
  404. temp3_i = tp4i[3]; \
  405. \
  406. for (i = (m & 3); i--;) \
  407. { \
  408. CGEMV_N_1x4(); \
  409. \
  410. k += 2; \
  411. y += inc_y2; \
  412. } \
  413. } \
  414. \
  415. pa0 += 4 * lda2; \
  416. pa1 += 4 * lda2; \
  417. pa2 += 4 * lda2; \
  418. pa3 += 4 * lda2; \
  419. \
  420. x += 4 * inc_x2; \
  421. } \
  422. \
  423. if (n & 2) \
  424. { \
  425. CLOAD_X2_SCALE(); \
  426. \
  427. k = 0; \
  428. y = y_org; \
  429. \
  430. for (i = (m >> 3); i--;) \
  431. { \
  432. CLOAD_Y8(); \
  433. CGEMV_N_8x2(); \
  434. CSTORE_Y8(); \
  435. \
  436. k += 2 * 8; \
  437. y += inc_y2 * 8; \
  438. } \
  439. \
  440. if (m & 4) \
  441. { \
  442. CLOAD_Y4(); \
  443. CGEMV_N_4x2(); \
  444. CSTORE_Y4(); \
  445. \
  446. k += 2 * 4; \
  447. y += inc_y2 * 4; \
  448. } \
  449. \
  450. for (i = (m & 3); i--;) \
  451. { \
  452. CGEMV_N_1x2(); \
  453. \
  454. k += 2; \
  455. y += inc_y2; \
  456. } \
  457. \
  458. pa0 += 2 * lda2; \
  459. pa1 += 2 * lda2; \
  460. \
  461. x += 2 * inc_x2; \
  462. } \
  463. \
  464. if (n & 1) \
  465. { \
  466. CLOAD_X1_SCALE(); \
  467. \
  468. k = 0; \
  469. y = y_org; \
  470. \
  471. for (i = m; i--;) \
  472. { \
  473. CGEMV_N_1x1(); \
  474. \
  475. k += 2; \
  476. y += inc_y2; \
  477. } \
  478. \
  479. pa0 += lda2; \
  480. x += inc_x2; \
  481. } \
  482. int CNAME(BLASLONG m, BLASLONG n, BLASLONG dummy1, FLOAT alpha_r, FLOAT alpha_i,
  483. FLOAT *A, BLASLONG lda2, FLOAT *x, BLASLONG inc_x2, FLOAT *y,
  484. BLASLONG inc_y2, FLOAT *buffer)
  485. {
  486. BLASLONG i, j, k, k_pref, pref_offset;
  487. FLOAT *y_org = y;
  488. FLOAT *pa0, *pa1, *pa2, *pa3;
  489. FLOAT temp_r, temp_i, res0, res1, temp0_r;
  490. FLOAT temp0_i, temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i;
  491. v4f32 alphar, alphai;
  492. v4f32 x0, x1, y0, y1, y2, y3, x0r, x0i, y0r, y1r, y0i, y1i;
  493. v4f32 t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15;
  494. v4f32 src0r, src1r, src2r, src3r, src4r, src5r, src6r, src7r;
  495. v4f32 src0i, src1i, src2i, src3i, src4i, src5i, src6i, src7i;
  496. v4f32 tp0r, tp1r, tp2r, tp3r, tp4r, tp0i, tp1i, tp2i, tp3i, tp4i;
  497. lda2 = 2 * lda2;
  498. inc_x2 = 2 * inc_x2;
  499. inc_y2 = 2 * inc_y2;
  500. pref_offset = (uintptr_t)A & (L1_DATA_LINESIZE - 1);
  501. pref_offset = L1_DATA_LINESIZE - pref_offset;
  502. pref_offset = pref_offset / sizeof(FLOAT);
  503. pa0 = A;
  504. pa1 = A + lda2;
  505. pa2 = A + 2 * lda2;
  506. pa3 = A + 3 * lda2;
  507. alphar = COPY_FLOAT_TO_VECTOR(alpha_r);
  508. alphai = COPY_FLOAT_TO_VECTOR(alpha_i);
  509. if ((2 == inc_x2) && (2 == inc_y2))
  510. {
  511. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_VECTOR
  512. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  513. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  514. #define CLOAD_Y8 CLOAD_Y8_VECTOR
  515. #define CLOAD_Y4 CLOAD_Y4_VECTOR
  516. #define CSTORE_Y8 CSTORE_Y8_VECTOR
  517. #define CSTORE_Y4 CSTORE_Y4_VECTOR
  518. CGEMV_N_MSA();
  519. #undef CLOAD_X4_SCALE
  520. #undef CLOAD_X2_SCALE
  521. #undef CLOAD_X1_SCALE
  522. #undef CLOAD_Y8
  523. #undef CLOAD_Y4
  524. #undef CSTORE_Y8
  525. #undef CSTORE_Y4
  526. }
  527. else if (2 == inc_x2)
  528. {
  529. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_VECTOR
  530. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  531. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  532. #define CLOAD_Y8 CLOAD_Y8_GP
  533. #define CLOAD_Y4 CLOAD_Y4_GP
  534. #define CSTORE_Y8 CSTORE_Y8_GP
  535. #define CSTORE_Y4 CSTORE_Y4_GP
  536. CGEMV_N_MSA();
  537. #undef CLOAD_X4_SCALE
  538. #undef CLOAD_X2_SCALE
  539. #undef CLOAD_X1_SCALE
  540. #undef CLOAD_Y8
  541. #undef CLOAD_Y4
  542. #undef CSTORE_Y8
  543. #undef CSTORE_Y4
  544. }
  545. else if (2 == inc_y2)
  546. {
  547. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_GP
  548. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  549. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  550. #define CLOAD_Y8 CLOAD_Y8_VECTOR
  551. #define CLOAD_Y4 CLOAD_Y4_VECTOR
  552. #define CSTORE_Y8 CSTORE_Y8_VECTOR
  553. #define CSTORE_Y4 CSTORE_Y4_VECTOR
  554. CGEMV_N_MSA();
  555. #undef CLOAD_X4_SCALE
  556. #undef CLOAD_X2_SCALE
  557. #undef CLOAD_X1_SCALE
  558. #undef CLOAD_Y8
  559. #undef CLOAD_Y4
  560. #undef CSTORE_Y8
  561. #undef CSTORE_Y4
  562. }
  563. else
  564. {
  565. #define CLOAD_X4_SCALE CLOAD_X4_SCALE_GP
  566. #define CLOAD_X2_SCALE CLOAD_X2_SCALE_GP
  567. #define CLOAD_X1_SCALE CLOAD_X1_SCALE_GP
  568. #define CLOAD_Y8 CLOAD_Y8_GP
  569. #define CLOAD_Y4 CLOAD_Y4_GP
  570. #define CSTORE_Y8 CSTORE_Y8_GP
  571. #define CSTORE_Y4 CSTORE_Y4_GP
  572. CGEMV_N_MSA();
  573. #undef CLOAD_X4_SCALE
  574. #undef CLOAD_X2_SCALE
  575. #undef CLOAD_X1_SCALE
  576. #undef CLOAD_Y8
  577. #undef CLOAD_Y4
  578. #undef CSTORE_Y8
  579. #undef CSTORE_Y4
  580. }
  581. return(0);
  582. }
  583. #undef OP0
  584. #undef OP1
  585. #undef OP2
  586. #undef OP3
  587. #undef OP4