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.

zdot_microk_power8.c 7.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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/21 Werner Saar (wernsaar@googlemail.com)
  29. * BLASTEST : OK
  30. * CTEST : OK
  31. * TEST : OK
  32. * LAPACK-TEST : OK
  33. **************************************************************************************/
  34. #define HAVE_KERNEL_8 1
  35. static void zdot_kernel_8 (long n, double *x, double *y, double *dot)
  36. {
  37. __asm__
  38. (
  39. "dcbt 0, %2 \n\t"
  40. "dcbt 0, %3 \n\t"
  41. "xxlxor 32, 32, 32 \n\t"
  42. "xxlxor 33, 33, 33 \n\t"
  43. "xxlxor 34, 34, 34 \n\t"
  44. "xxlxor 35, 35, 35 \n\t"
  45. "xxlxor 36, 36, 36 \n\t"
  46. "xxlxor 37, 37, 37 \n\t"
  47. "xxlxor 38, 38, 38 \n\t"
  48. "xxlxor 39, 39, 39 \n\t"
  49. "lxvd2x 40, 0, %2 \n\t" // x0_r, x0_i
  50. "lxvd2x 48, 0, %3 \n\t" // y0_r, y0_i
  51. "lxvd2x 41, %7, %2 \n\t" // x1_r, x1_i
  52. "lxvd2x 49, %7, %3 \n\t" // y1_r, y1_i
  53. "lxvd2x 42, %8, %2 \n\t" // x2_r, x2_i
  54. "lxvd2x 50, %8, %3 \n\t" // y2_r, y2_i
  55. "lxvd2x 43, %9, %2 \n\t" // x3_r, x3_i
  56. "lxvd2x 51, %9, %3 \n\t" // y3_r, y3_i
  57. XXSWAPD_S(0,48) // y0_i, y0_r
  58. XXSWAPD_S(1,49) // y1_i, y1_r
  59. XXSWAPD_S(2,50) // y2_i, y2_r
  60. XXSWAPD_S(3,51) // y3_i, y3_r
  61. "addi %2, %2, 64 \n\t"
  62. "addi %3, %3, 64 \n\t"
  63. "lxvd2x 44, 0, %2 \n\t" // x0_r, x0_i
  64. "lxvd2x 4, 0, %3 \n\t" // y0_r, y0_i
  65. "lxvd2x 45, %7, %2 \n\t" // x1_r, x1_i
  66. "lxvd2x 5, %7, %3 \n\t" // y1_r, y1_i
  67. "lxvd2x 46, %8, %2 \n\t" // x2_r, x2_i
  68. "lxvd2x 6, %8, %3 \n\t" // y2_r, y2_i
  69. "lxvd2x 47, %9, %2 \n\t" // x3_r, x3_i
  70. "lxvd2x 7, %9, %3 \n\t" // y3_r, y3_i
  71. XXSWAPD_S(8,4) // y0_i, y0_r
  72. XXSWAPD_S(9,5) // y1_i, y1_r
  73. XXSWAPD_S(10,6) // y2_i, y2_r
  74. XXSWAPD_S(11,7) // y3_i, y3_r
  75. "addi %2, %2, 64 \n\t"
  76. "addi %3, %3, 64 \n\t"
  77. "addic. %1, %1, -8 \n\t"
  78. "ble two%= \n\t"
  79. ".align 5 \n"
  80. "one%=: \n\t"
  81. "xvmaddadp 32, 40, 48 \n\t" // x0_r * y0_r , x0_i * y0_i
  82. "lxvd2x 48, 0, %3 \n\t" // y0_r, y0_i
  83. "xvmaddadp 34, 41, 49 \n\t" // x1_r * y1_r , x1_i * y1_i
  84. "lxvd2x 49, %7, %3 \n\t" // y1_r, y1_i
  85. "xvmaddadp 36, 42, 50 \n\t" // x2_r * y2_r , x2_i * y2_i
  86. "lxvd2x 50, %8, %3 \n\t" // y2_r, y2_i
  87. "xvmaddadp 38, 43, 51 \n\t" // x3_r * y3_r , x3_i * y3_i
  88. "lxvd2x 51, %9, %3 \n\t" // y3_r, y3_i
  89. "xvmaddadp 33, 40, 0 \n\t" // x0_r * y0_i , x0_i * y0_r
  90. "lxvd2x 40, 0, %2 \n\t" // x0_r, x0_i
  91. "xvmaddadp 35, 41, 1 \n\t" // x1_r * y1_i , x1_i * y1_r
  92. "lxvd2x 41, %7, %2 \n\t" // x1_r, x1_i
  93. "xvmaddadp 37, 42, 2 \n\t" // x2_r * y2_i , x2_i * y2_r
  94. "lxvd2x 42, %8, %2 \n\t" // x2_r, x2_i
  95. "xvmaddadp 39, 43, 3 \n\t" // x3_r * y3_i , x3_i * y3_r
  96. "lxvd2x 43, %9, %2 \n\t" // x3_r, x3_i
  97. XXSWAPD_S(0,48) // y0_i, y0_r
  98. XXSWAPD_S(1,49) // y1_i, y1_r
  99. "addi %2, %2, 64 \n\t"
  100. "addi %3, %3, 64 \n\t"
  101. XXSWAPD_S(2,50) // y2_i, y2_r
  102. XXSWAPD_S(3,51) // y3_i, y3_r
  103. "xvmaddadp 32, 44, 4 \n\t" // x0_r * y0_r , x0_i * y0_i
  104. "lxvd2x 4, 0, %3 \n\t" // y0_r, y0_i
  105. "xvmaddadp 34, 45, 5 \n\t" // x1_r * y1_r , x1_i * y1_i
  106. "lxvd2x 5, %7, %3 \n\t" // y1_r, y1_i
  107. "xvmaddadp 36, 46, 6 \n\t" // x2_r * y2_r , x2_i * y2_i
  108. "lxvd2x 6, %8, %3 \n\t" // y2_r, y2_i
  109. "xvmaddadp 38, 47, 7 \n\t" // x3_r * y3_r , x3_i * y3_i
  110. "lxvd2x 7, %9, %3 \n\t" // y3_r, y3_i
  111. "xvmaddadp 33, 44, 8 \n\t" // x0_r * y0_i , x0_i * y0_r
  112. "lxvd2x 44, 0, %2 \n\t" // x0_r, x0_i
  113. "xvmaddadp 35, 45, 9 \n\t" // x1_r * y1_i , x1_i * y1_r
  114. "lxvd2x 45, %7, %2 \n\t" // x1_r, x1_i
  115. "xvmaddadp 37, 46, 10 \n\t" // x2_r * y2_i , x2_i * y2_r
  116. "lxvd2x 46, %8, %2 \n\t" // x2_r, x2_i
  117. "xvmaddadp 39, 47, 11 \n\t" // x3_r * y3_i , x3_i * y3_r
  118. "lxvd2x 47, %9, %2 \n\t" // x3_r, x3_i
  119. XXSWAPD_S(8,4) // y0_i, y0_r
  120. XXSWAPD_S(9,5) // y1_i, y1_r
  121. "addi %2, %2, 64 \n\t"
  122. "addi %3, %3, 64 \n\t"
  123. XXSWAPD_S(10,6) // y2_i, y2_r
  124. XXSWAPD_S(11,7) // y3_i, y3_r
  125. "addic. %1, %1, -8 \n\t"
  126. "bgt one%= \n"
  127. "two%=: \n\t"
  128. "xvmaddadp 32, 40, 48 \n\t" // x0_r * y0_r , x0_i * y0_i
  129. "xvmaddadp 34, 41, 49 \n\t" // x1_r * y1_r , x1_i * y1_i
  130. "xvmaddadp 36, 42, 50 \n\t" // x2_r * y2_r , x2_i * y2_i
  131. "xvmaddadp 38, 43, 51 \n\t" // x3_r * y3_r , x3_i * y3_i
  132. "xvmaddadp 33, 40, 0 \n\t" // x0_r * y0_i , x0_i * y0_r
  133. "xvmaddadp 35, 41, 1 \n\t" // x1_r * y1_i , x1_i * y1_r
  134. "xvmaddadp 37, 42, 2 \n\t" // x2_r * y2_i , x2_i * y2_r
  135. "xvmaddadp 39, 43, 3 \n\t" // x3_r * y3_i , x3_i * y3_r
  136. "xvmaddadp 32, 44, 4 \n\t" // x0_r * y0_r , x0_i * y0_i
  137. "xvmaddadp 34, 45, 5 \n\t" // x1_r * y1_r , x1_i * y1_i
  138. "xvmaddadp 36, 46, 6 \n\t" // x2_r * y2_r , x2_i * y2_i
  139. "xvmaddadp 38, 47, 7 \n\t" // x3_r * y3_r , x3_i * y3_i
  140. "xvmaddadp 33, 44, 8 \n\t" // x0_r * y0_i , x0_i * y0_r
  141. "xvmaddadp 35, 45, 9 \n\t" // x1_r * y1_i , x1_i * y1_r
  142. "xvmaddadp 37, 46, 10 \n\t" // x2_r * y2_i , x2_i * y2_r
  143. "xvmaddadp 39, 47, 11 \n\t" // x3_r * y3_i , x3_i * y3_r
  144. "xvadddp 32, 32, 34 \n\t"
  145. "xvadddp 36, 36, 38 \n\t"
  146. "xvadddp 33, 33, 35 \n\t"
  147. "xvadddp 37, 37, 39 \n\t"
  148. "xvadddp 32, 32, 36 \n\t"
  149. "xvadddp 33, 33, 37 \n\t"
  150. "stxvd2x 32, 0, %6 \n\t"
  151. "stxvd2x 33, %7, %6 \n"
  152. "#n=%1 x=%4=%2 y=%5=%3 dot=%0=%6 o16=%7 o32=%8 o48=%9"
  153. :
  154. "=m" (*dot),
  155. "+r" (n), // 1
  156. "+b" (x), // 2
  157. "+b" (y) // 3
  158. :
  159. "m" (*x),
  160. "m" (*y),
  161. "b" (dot), // 6
  162. "b" (16), // 7
  163. "b" (32), // 8
  164. "b" (48) // 9
  165. :
  166. "cr0",
  167. "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
  168. "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
  169. "vs48","vs49","vs50","vs51","vs0","vs1","vs2","vs3",
  170. "vs4","vs5","vs6","vs7","vs8","vs9","vs10","vs11"
  171. );
  172. }