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_n_microk_power8.c 8.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /***************************************************************************
  2. Copyright (c) 2013-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. /**************************************************************************************
  28. * 2016/03/30 Werner Saar (wernsaar@googlemail.com)
  29. * BLASTEST : OK
  30. * CTEST : OK
  31. * TEST : OK
  32. * LAPACK-TEST : OK
  33. **************************************************************************************/
  34. #define HAVE_KERNEL_4x4 1
  35. static void dgemv_kernel_4x4(BLASLONG n, FLOAT **ap, FLOAT *xo, FLOAT *y, FLOAT *alpha) __attribute__ ((noinline));
  36. static void dgemv_kernel_4x4(BLASLONG n, FLOAT **ap, FLOAT *xo, FLOAT *y, FLOAT *alpha)
  37. {
  38. BLASLONG i=n;
  39. BLASLONG o8 = 8;
  40. BLASLONG o16 = 16;
  41. BLASLONG o24 = 24;
  42. BLASLONG pre = 384;
  43. FLOAT *a0,*a1,*a2,*a3;
  44. FLOAT *y1=y+1;
  45. FLOAT x[4] __attribute__ ((aligned (16)));;
  46. a0 = ap[0]+1;
  47. a1 = ap[1]+1;
  48. a2 = ap[2]+1;
  49. a3 = ap[3]+1;
  50. x[0]=xo[0] * *alpha;
  51. x[1]=xo[1] * *alpha;
  52. x[2]=xo[2] * *alpha;
  53. x[3]=xo[3] * *alpha;
  54. __asm__ __volatile__
  55. (
  56. "lxvdsx 32, 0 , %1 \n\t" // x0
  57. "lxvdsx 33,%3 , %1 \n\t" // x1
  58. "lxvdsx 34,%4 , %1 \n\t" // x2
  59. "lxvdsx 35,%5 , %1 \n\t" // x3
  60. "addi %2 , %2 , -8 \n\t"
  61. "addi %6 , %6 , -8 \n\t"
  62. "addi %7 , %7 , -8 \n\t"
  63. "addi %8 , %8 , -8 \n\t"
  64. "addi %9 , %9 , -8 \n\t"
  65. "lxvd2x 48, 0, %6 \n\t" // a0[0], a0[1]
  66. "lxvd2x 49,%4, %6 \n\t" // a0[2], a0[3]
  67. "lxvd2x 50, 0, %7 \n\t" // a1[0], a1[1]
  68. "lxvd2x 51,%4, %7 \n\t" // a1[2], a1[3]
  69. "lxvd2x 52, 0, %8 \n\t" // a2[0], a2[1]
  70. "lxvd2x 53,%4, %8 \n\t" // a2[2], a2[3]
  71. "lxvd2x 54, 0, %9 \n\t" // a3[0], a3[1]
  72. "lxvd2x 55,%4, %9 \n\t" // a3[2], a3[3]
  73. "addi %6, %6, 32 \n\t"
  74. "addi %7, %7, 32 \n\t"
  75. "addi %8, %8, 32 \n\t"
  76. "addi %9, %9, 32 \n\t"
  77. "addic. %0 , %0 , -4 \n\t"
  78. "ble 2f \n\t"
  79. ".align 5 \n\t"
  80. "1: \n\t"
  81. "dcbt %2, %10 \n\t"
  82. "lxvd2x 40, 0, %2 \n\t" // y0, y1
  83. "lxvd2x 41,%4, %2 \n\t" // y2, y3
  84. "dcbt %6, %10 \n\t"
  85. "dcbt %7, %10 \n\t"
  86. "dcbt %8, %10 \n\t"
  87. "dcbt %9, %10 \n\t"
  88. "xvmaddadp 40, 48, 32 \n\t"
  89. "xvmaddadp 41, 49, 32 \n\t"
  90. "lxvd2x 48, 0, %6 \n\t" // a0[0], a0[1]
  91. "lxvd2x 49,%4, %6 \n\t" // a0[2], a0[3]
  92. "xvmaddadp 40, 50, 33 \n\t"
  93. "addi %6, %6, 32 \n\t"
  94. "xvmaddadp 41, 51, 33 \n\t"
  95. "lxvd2x 50, 0, %7 \n\t" // a1[0], a1[1]
  96. "lxvd2x 51,%4, %7 \n\t" // a1[2], a1[3]
  97. "xvmaddadp 40, 52, 34 \n\t"
  98. "addi %7, %7, 32 \n\t"
  99. "xvmaddadp 41, 53, 34 \n\t"
  100. "lxvd2x 52, 0, %8 \n\t" // a2[0], a2[1]
  101. "lxvd2x 53,%4, %8 \n\t" // a2[2], a2[3]
  102. "xvmaddadp 40, 54, 35 \n\t"
  103. "addi %8, %8, 32 \n\t"
  104. "xvmaddadp 41, 55, 35 \n\t"
  105. "stxvd2x 40, 0, %2 \n\t" // y0, y1
  106. "stxvd2x 41,%4, %2 \n\t" // y2, y3
  107. "lxvd2x 54, 0, %9 \n\t" // a3[0], a3[1]
  108. "lxvd2x 55,%4, %9 \n\t" // a3[2], a3[3]
  109. "addi %9, %9, 32 \n\t"
  110. "addi %2, %2, 32 \n\t"
  111. "addic. %0 , %0 , -4 \n\t"
  112. "ble 2f \n\t"
  113. "lxvd2x 40, 0, %2 \n\t" // y0, y1
  114. "lxvd2x 41,%4, %2 \n\t" // y2, y3
  115. "xvmaddadp 40, 48, 32 \n\t"
  116. "xvmaddadp 41, 49, 32 \n\t"
  117. "lxvd2x 48, 0, %6 \n\t" // a0[0], a0[1]
  118. "lxvd2x 49,%4, %6 \n\t" // a0[2], a0[3]
  119. "xvmaddadp 40, 50, 33 \n\t"
  120. "addi %6, %6, 32 \n\t"
  121. "xvmaddadp 41, 51, 33 \n\t"
  122. "lxvd2x 50, 0, %7 \n\t" // a1[0], a1[1]
  123. "lxvd2x 51,%4, %7 \n\t" // a1[2], a1[3]
  124. "xvmaddadp 40, 52, 34 \n\t"
  125. "addi %7, %7, 32 \n\t"
  126. "xvmaddadp 41, 53, 34 \n\t"
  127. "lxvd2x 52, 0, %8 \n\t" // a2[0], a2[1]
  128. "lxvd2x 53,%4, %8 \n\t" // a2[2], a2[3]
  129. "xvmaddadp 40, 54, 35 \n\t"
  130. "addi %8, %8, 32 \n\t"
  131. "xvmaddadp 41, 55, 35 \n\t"
  132. "stxvd2x 40, 0, %2 \n\t" // y0, y1
  133. "stxvd2x 41,%4, %2 \n\t" // y2, y3
  134. "lxvd2x 54, 0, %9 \n\t" // a3[0], a3[1]
  135. "lxvd2x 55,%4, %9 \n\t" // a3[2], a3[3]
  136. "addi %9, %9, 32 \n\t"
  137. "addi %2, %2, 32 \n\t"
  138. "addic. %0 , %0 , -4 \n\t"
  139. "ble 2f \n\t"
  140. "lxvd2x 40, 0, %2 \n\t" // y0, y1
  141. "lxvd2x 41,%4, %2 \n\t" // y2, y3
  142. "xvmaddadp 40, 48, 32 \n\t"
  143. "xvmaddadp 41, 49, 32 \n\t"
  144. "lxvd2x 48, 0, %6 \n\t" // a0[0], a0[1]
  145. "lxvd2x 49,%4, %6 \n\t" // a0[2], a0[3]
  146. "xvmaddadp 40, 50, 33 \n\t"
  147. "addi %6, %6, 32 \n\t"
  148. "xvmaddadp 41, 51, 33 \n\t"
  149. "lxvd2x 50, 0, %7 \n\t" // a1[0], a1[1]
  150. "lxvd2x 51,%4, %7 \n\t" // a1[2], a1[3]
  151. "xvmaddadp 40, 52, 34 \n\t"
  152. "addi %7, %7, 32 \n\t"
  153. "xvmaddadp 41, 53, 34 \n\t"
  154. "lxvd2x 52, 0, %8 \n\t" // a2[0], a2[1]
  155. "lxvd2x 53,%4, %8 \n\t" // a2[2], a2[3]
  156. "xvmaddadp 40, 54, 35 \n\t"
  157. "addi %8, %8, 32 \n\t"
  158. "xvmaddadp 41, 55, 35 \n\t"
  159. "stxvd2x 40, 0, %2 \n\t" // y0, y1
  160. "stxvd2x 41,%4, %2 \n\t" // y2, y3
  161. "lxvd2x 54, 0, %9 \n\t" // a3[0], a3[1]
  162. "lxvd2x 55,%4, %9 \n\t" // a3[2], a3[3]
  163. "addi %9, %9, 32 \n\t"
  164. "addi %2, %2, 32 \n\t"
  165. "addic. %0 , %0 , -4 \n\t"
  166. "ble 2f \n\t"
  167. "lxvd2x 40, 0, %2 \n\t" // y0, y1
  168. "lxvd2x 41,%4, %2 \n\t" // y2, y3
  169. "xvmaddadp 40, 48, 32 \n\t"
  170. "xvmaddadp 41, 49, 32 \n\t"
  171. "lxvd2x 48, 0, %6 \n\t" // a0[0], a0[1]
  172. "lxvd2x 49,%4, %6 \n\t" // a0[2], a0[3]
  173. "xvmaddadp 40, 50, 33 \n\t"
  174. "addi %6, %6, 32 \n\t"
  175. "xvmaddadp 41, 51, 33 \n\t"
  176. "lxvd2x 50, 0, %7 \n\t" // a1[0], a1[1]
  177. "lxvd2x 51,%4, %7 \n\t" // a1[2], a1[3]
  178. "xvmaddadp 40, 52, 34 \n\t"
  179. "addi %7, %7, 32 \n\t"
  180. "xvmaddadp 41, 53, 34 \n\t"
  181. "lxvd2x 52, 0, %8 \n\t" // a2[0], a2[1]
  182. "lxvd2x 53,%4, %8 \n\t" // a2[2], a2[3]
  183. "xvmaddadp 40, 54, 35 \n\t"
  184. "addi %8, %8, 32 \n\t"
  185. "xvmaddadp 41, 55, 35 \n\t"
  186. "stxvd2x 40, 0, %2 \n\t" // y0, y1
  187. "stxvd2x 41,%4, %2 \n\t" // y2, y3
  188. "lxvd2x 54, 0, %9 \n\t" // a3[0], a3[1]
  189. "lxvd2x 55,%4, %9 \n\t" // a3[2], a3[3]
  190. "addi %9, %9, 32 \n\t"
  191. "addi %2, %2, 32 \n\t"
  192. "addic. %0 , %0 , -4 \n\t"
  193. "bgt 1b \n\t"
  194. "2: \n\t"
  195. "lxvd2x 40, 0, %2 \n\t" // y0, y1
  196. "lxvd2x 41,%4, %2 \n\t" // y2, y3
  197. "xvmaddadp 40, 48, 32 \n\t"
  198. "xvmaddadp 41, 49, 32 \n\t"
  199. "xvmaddadp 40, 50, 33 \n\t"
  200. "xvmaddadp 41, 51, 33 \n\t"
  201. "xvmaddadp 40, 52, 34 \n\t"
  202. "xvmaddadp 41, 53, 34 \n\t"
  203. "xvmaddadp 40, 54, 35 \n\t"
  204. "xvmaddadp 41, 55, 35 \n\t"
  205. "stxvd2x 40, 0, %2 \n\t" // y0, y1
  206. "stxvd2x 41,%4, %2 \n\t" // y2, y3
  207. :
  208. :
  209. "r" (i), // 0
  210. "r" (x), // 1
  211. "r" (y1), // 2
  212. "r" (o8), // 3
  213. "r" (o16), // 4
  214. "r" (o24), // 5
  215. "r" (a0), // 6
  216. "r" (a1), // 7
  217. "r" (a2), // 8
  218. "r" (a3), // 9
  219. "r" (pre) // 10
  220. : "cr0", "%0", "%2" , "%6", "%7", "%8", "%9", "memory"
  221. );
  222. }