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.

caxpy_microk_power10.c 7.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /***************************************************************************
  2. Copyright (c) 2020, 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. #define HAVE_KERNEL_8 1
  28. static void caxpy_kernel_8 (long n, float *x, float *y,
  29. float alpha_r, float alpha_i)
  30. {
  31. #if !defined(CONJ)
  32. static const float mvec[4] = { -1.0, 1.0, -1.0, 1.0 };
  33. #else
  34. static const float mvec[4] = { 1.0, -1.0, 1.0, -1.0 };
  35. #endif
  36. const float *mvecp = mvec;
  37. /* We have to load reverse mask for big endian. */
  38. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  39. __vector unsigned char mask={ 4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11};
  40. #else
  41. __vector unsigned char mask = { 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4};
  42. #endif
  43. long ytmp;
  44. __asm__
  45. (
  46. "xscvdpspn 32, %7 \n\t"
  47. "xscvdpspn 33, %8 \n\t"
  48. "xxspltw 32, 32, 0 \n\t"
  49. "xxspltw 33, 33, 0 \n\t"
  50. "lxvd2x 36, 0, %9 \n\t" // mvec
  51. #if !defined(CONJ)
  52. "xvmulsp 33, 33, 36 \n\t" // alpha_i * mvec
  53. #else
  54. "xvmulsp 32, 32, 36 \n\t" // alpha_r * mvec
  55. #endif
  56. "mr %4, %3 \n\t"
  57. "dcbt 0, %2 \n\t"
  58. "dcbt 0, %3 \n\t"
  59. "lxvp 40, 0(%2) \n\t" // x0
  60. "lxvp 42, 32(%2) \n\t" // x2
  61. "lxvp 48, 0(%3) \n\t" // y0
  62. "lxvp 50, 32(%3) \n\t" // y2
  63. "xxperm 52, 40, %x10 \n\t" // exchange real and imag part
  64. "xxperm 53, 41, %x10 \n\t" // exchange real and imag part
  65. "xxperm 54, 42, %x10 \n\t" // exchange real and imag part
  66. "xxperm 55, 43, %x10 \n\t" // exchange real and imag part
  67. "lxvp 44, 64(%2) \n\t" // x4
  68. "lxvp 46, 96(%2) \n\t" // x6
  69. "lxvp 34, 64(%3) \n\t" // y4
  70. "lxvp 38, 96(%3) \n\t" // y6
  71. "xxperm 56, 44, %x10 \n\t" // exchange real and imag part
  72. "xxperm 57, 45, %x10 \n\t" // exchange real and imag part
  73. "xxperm 58, 46, %x10 \n\t" // exchange real and imag part
  74. "xxperm 59, 47, %x10 \n\t" // exchange real and imag part
  75. "addi %2, %2, 128 \n\t"
  76. "addi %3, %3, 128 \n\t"
  77. "addic. %1, %1, -16 \n\t"
  78. "ble two%= \n\t"
  79. ".align 5 \n"
  80. "one%=: \n\t"
  81. "xvmaddasp 48, 40, 32 \n\t" // alpha_r * x0_r , alpha_r * x0_i
  82. "xvmaddasp 49, 41, 32 \n\t"
  83. "lxvp 40, 0(%2) \n\t" // x0
  84. "xvmaddasp 50, 42, 32 \n\t"
  85. "xvmaddasp 51, 43, 32 \n\t"
  86. "lxvp 42, 32(%2) \n\t" // x2
  87. "xvmaddasp 34, 44, 32 \n\t"
  88. "xvmaddasp 35, 45, 32 \n\t"
  89. "lxvp 44, 64(%2) \n\t" // x4
  90. "xvmaddasp 38, 46, 32 \n\t"
  91. "xvmaddasp 39, 47, 32 \n\t"
  92. "lxvp 46, 96(%2) \n\t" // x6
  93. "xvmaddasp 48, 52, 33 \n\t" // alpha_i * x0_i , alpha_i * x0_r
  94. "addi %2, %2, 128 \n\t"
  95. "xvmaddasp 49, 53, 33 \n\t"
  96. "xvmaddasp 50, 54, 33 \n\t"
  97. "xvmaddasp 51, 55, 33 \n\t"
  98. "xvmaddasp 34, 56, 33 \n\t"
  99. "xvmaddasp 35, 57, 33 \n\t"
  100. "xvmaddasp 38, 58, 33 \n\t"
  101. "xvmaddasp 39, 59, 33 \n\t"
  102. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  103. "stxv 48, 0(%4) \n\t"
  104. "stxv 49, 16(%4) \n\t"
  105. "stxv 50, 32(%4) \n\t"
  106. "stxv 51, 48(%4) \n\t"
  107. "stxv 34, 64(%4) \n\t"
  108. "stxv 35, 80(%4) \n\t"
  109. "stxv 38, 96(%4) \n\t"
  110. "stxv 39, 112(%4) \n\t"
  111. #else
  112. "stxv 49, 0(%4) \n\t"
  113. "stxv 48, 16(%4) \n\t"
  114. "stxv 51, 32(%4) \n\t"
  115. "stxv 50, 48(%4) \n\t"
  116. "stxv 35, 64(%4) \n\t"
  117. "stxv 34, 80(%4) \n\t"
  118. "stxv 39, 96(%4) \n\t"
  119. "stxv 38, 112(%4) \n\t"
  120. #endif
  121. "addi %4, %4, 128 \n\t"
  122. "xxperm 52, 40, %x10 \n\t" // exchange real and imag part
  123. "xxperm 53, 41, %x10 \n\t" // exchange real and imag part
  124. "lxvp 48, 0(%3) \n\t" // y0
  125. "xxperm 54, 42, %x10 \n\t" // exchange real and imag part
  126. "xxperm 55, 43, %x10 \n\t" // exchange real and imag part
  127. "lxvp 50, 32(%3) \n\t" // y2
  128. "xxperm 56, 44, %x10 \n\t" // exchange real and imag part
  129. "xxperm 57, 45, %x10 \n\t" // exchange real and imag part
  130. "lxvp 34, 64(%3) \n\t" // y4
  131. "xxperm 58, 46, %x10 \n\t" // exchange real and imag part
  132. "xxperm 59, 47, %x10 \n\t" // exchange real and imag part
  133. "lxvp 38, 96(%3) \n\t" // y6
  134. "addi %3, %3, 128 \n\t"
  135. "addic. %1, %1, -16 \n\t"
  136. "bgt one%= \n"
  137. "two%=: \n\t"
  138. "xvmaddasp 48, 40, 32 \n\t" // alpha_r * x0_r , alpha_r * x0_i
  139. "xvmaddasp 49, 41, 32 \n\t"
  140. "xvmaddasp 50, 42, 32 \n\t"
  141. "xvmaddasp 51, 43, 32 \n\t"
  142. "xvmaddasp 34, 44, 32 \n\t"
  143. "xvmaddasp 35, 45, 32 \n\t"
  144. "xvmaddasp 38, 46, 32 \n\t"
  145. "xvmaddasp 39, 47, 32 \n\t"
  146. "xvmaddasp 48, 52, 33 \n\t" // alpha_i * x0_i , alpha_i * x0_r
  147. "xvmaddasp 49, 53, 33 \n\t"
  148. "xvmaddasp 50, 54, 33 \n\t"
  149. "xvmaddasp 51, 55, 33 \n\t"
  150. "xvmaddasp 34, 56, 33 \n\t"
  151. "xvmaddasp 35, 57, 33 \n\t"
  152. "xvmaddasp 38, 58, 33 \n\t"
  153. "xvmaddasp 39, 59, 33 \n\t"
  154. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  155. "stxv 48, 0(%4) \n\t"
  156. "stxv 49, 16(%4) \n\t"
  157. "stxv 50, 32(%4) \n\t"
  158. "stxv 51, 48(%4) \n\t"
  159. "stxv 34, 64(%4) \n\t"
  160. "stxv 35, 80(%4) \n\t"
  161. "stxv 38, 96(%4) \n\t"
  162. "stxv 39, 112(%4) \n\t"
  163. #else
  164. "stxv 49, 0(%4) \n\t"
  165. "stxv 48, 16(%4) \n\t"
  166. "stxv 51, 32(%4) \n\t"
  167. "stxv 50, 48(%4) \n\t"
  168. "stxv 35, 64(%4) \n\t"
  169. "stxv 34, 80(%4) \n\t"
  170. "stxv 39, 96(%4) \n\t"
  171. "stxv 38, 112(%4) \n\t"
  172. #endif
  173. "#n=%1 x=%5=%2 y=%0=%3 alpha=(%7,%8) mvecp=%6=%9 ytmp=%4\n"
  174. :
  175. "+m" (*y),
  176. "+r" (n), // 1
  177. "+b" (x), // 2
  178. "+b" (y), // 3
  179. "=b" (ytmp) // 4
  180. :
  181. "m" (*x),
  182. "m" (*mvecp),
  183. "d" (alpha_r), // 7
  184. "d" (alpha_i), // 8
  185. "4" (mvecp), // 9
  186. "wa" (mask)
  187. :
  188. "cr0",
  189. "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
  190. "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
  191. "vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55",
  192. "vs56","vs57","vs58","vs59"
  193. );
  194. }