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.

cscal_microk_power10.c 6.7 kB

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