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.

zaxpy_microk_power10.c 6.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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_4 1
  28. static void zaxpy_kernel_4 (long n, double *x, double *y,
  29. double alpha_r, double alpha_i)
  30. {
  31. #if !defined(CONJ)
  32. static const double mvec[2] = { 1.0, -1.0 };
  33. #else
  34. static const double mvec[2] = { -1.0, 1.0 };
  35. #endif
  36. const double *mvecp = mvec;
  37. __vector double t0;
  38. __vector double t1;
  39. __vector double t2;
  40. __vector double t3;
  41. __vector double t4;
  42. __vector double t5;
  43. __vector double t6;
  44. __vector double t7;
  45. long ytmp;
  46. __asm__
  47. (
  48. XXSPLTD_S(32,%x15,0) // alpha_r
  49. XXSPLTD_S(33,%x16,0) // alpha_i
  50. "lxvd2x 36, 0, %17 \n\t" // mvec
  51. #if !defined(CONJ)
  52. "xvmuldp 33, 33, 36 \n\t" // alpha_i * mvec
  53. #else
  54. "xvmuldp 32, 32, 36 \n\t" // alpha_r * mvec
  55. #endif
  56. "mr %12, %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. XXSWAPD_S(%x4,40) // exchange real and imag part
  64. XXSWAPD_S(%x5,41) // exchange real and imag part
  65. XXSWAPD_S(%x6,42) // exchange real and imag part
  66. XXSWAPD_S(%x7,43) // 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. XXSWAPD_S(%x8,44) // exchange real and imag part
  72. XXSWAPD_S(%x9,45) // exchange real and imag part
  73. XXSWAPD_S(%x10,46) // exchange real and imag part
  74. XXSWAPD_S(%x11,47) // exchange real and imag part
  75. "addi %2, %2, 128 \n\t"
  76. "addi %3, %3, 128 \n\t"
  77. "addic. %1, %1, -8 \n\t"
  78. "ble two%= \n\t"
  79. ".align 5 \n"
  80. "one%=: \n\t"
  81. "xvmaddadp 48, 40, 32 \n\t" // alpha_r * x0_r , alpha_r * x0_i
  82. "xvmaddadp 49, 41, 32 \n\t"
  83. "lxvp 40, 0(%2) \n\t" // x0
  84. "xvmaddadp 50, 42, 32 \n\t"
  85. "xvmaddadp 51, 43, 32 \n\t"
  86. "lxvp 42, 32(%2) \n\t" // x2
  87. "xvmaddadp 34, 44, 32 \n\t"
  88. "xvmaddadp 35, 45, 32 \n\t"
  89. "lxvp 44, 64(%2) \n\t" // x4
  90. "xvmaddadp 38, 46, 32 \n\t"
  91. "xvmaddadp 39, 47, 32 \n\t"
  92. "lxvp 46, 96(%2) \n\t" // x6
  93. "xvmaddadp 48, %x4, 33 \n\t" // alpha_i * x0_i , alpha_i * x0_r
  94. "addi %2, %2, 128 \n\t"
  95. "xvmaddadp 49, %x5, 33 \n\t"
  96. "xvmaddadp 50, %x6, 33 \n\t"
  97. "xvmaddadp 51, %x7, 33 \n\t"
  98. "xvmaddadp 34, %x8, 33 \n\t"
  99. "xvmaddadp 35, %x9, 33 \n\t"
  100. "xvmaddadp 38, %x10, 33 \n\t"
  101. "xvmaddadp 39, %x11, 33 \n\t"
  102. "stxvp 48, 0(%12) \n\t"
  103. "stxvp 50, 32(%12) \n\t"
  104. "stxvp 34, 64(%12) \n\t"
  105. "stxvp 38, 96(%12) \n\t"
  106. "addi %12, %12, 128 \n\t"
  107. XXSWAPD_S(%x4,40) // exchange real and imag part
  108. XXSWAPD_S(%x5,41) // exchange real and imag part
  109. "lxvp 48, 0(%3) \n\t" // y0
  110. XXSWAPD_S(%x6,42) // exchange real and imag part
  111. XXSWAPD_S(%x7,43) // exchange real and imag part
  112. "lxvp 50, 32(%3) \n\t" // y2
  113. XXSWAPD_S(%x8,44) // exchange real and imag part
  114. XXSWAPD_S(%x9,45) // exchange real and imag part
  115. "lxvp 34, 64(%3) \n\t" // y4
  116. XXSWAPD_S(%x10,46) // exchange real and imag part
  117. XXSWAPD_S(%x11,47) // exchange real and imag part
  118. "lxvp 38, 96(%3) \n\t" // y6
  119. "addi %3, %3, 128 \n\t"
  120. "addic. %1, %1, -8 \n\t"
  121. "bgt one%= \n"
  122. "two%=: \n\t"
  123. "xvmaddadp 48, 40, 32 \n\t" // alpha_r * x0_r , alpha_r * x0_i
  124. "xvmaddadp 49, 41, 32 \n\t"
  125. "xvmaddadp 50, 42, 32 \n\t"
  126. "xvmaddadp 51, 43, 32 \n\t"
  127. "xvmaddadp 34, 44, 32 \n\t"
  128. "xvmaddadp 35, 45, 32 \n\t"
  129. "xvmaddadp 38, 46, 32 \n\t"
  130. "xvmaddadp 39, 47, 32 \n\t"
  131. "xvmaddadp 48, %x4, 33 \n\t" // alpha_i * x0_i , alpha_i * x0_r
  132. "xvmaddadp 49, %x5, 33 \n\t"
  133. "xvmaddadp 50, %x6, 33 \n\t"
  134. "xvmaddadp 51, %x7, 33 \n\t"
  135. "xvmaddadp 34, %x8, 33 \n\t"
  136. "xvmaddadp 35, %x9, 33 \n\t"
  137. "xvmaddadp 38, %x10, 33 \n\t"
  138. "xvmaddadp 39, %x11, 33 \n\t"
  139. "stxvp 48, 0(%12) \n\t"
  140. "stxvp 50, 32(%12) \n\t"
  141. "stxvp 34, 64(%12) \n\t"
  142. "stxvp 38, 96(%12) \n\t"
  143. "#n=%1 x=%13=%2 y=%0=%3 alpha=(%15,%16) mvecp=%14=%17 ytmp=%12\n"
  144. "#t0=%x4 t1=%x5 t2=%x6 t3=%x7 t4=%x8 t5=%x9 t6=%x10 t7=%x11"
  145. :
  146. "+m" (*y),
  147. "+r" (n), // 1
  148. "+b" (x), // 2
  149. "+b" (y), // 3
  150. "=wa" (t0), // 4
  151. "=wa" (t1), // 5
  152. "=wa" (t2), // 6
  153. "=wa" (t3), // 7
  154. "=wa" (t4), // 8
  155. "=wa" (t5), // 9
  156. "=wa" (t6), // 10
  157. "=wa" (t7), // 11
  158. "=b" (ytmp) // 12
  159. :
  160. "m" (*x),
  161. "m" (*mvecp),
  162. "d" (alpha_r), // 15
  163. "d" (alpha_i), // 16
  164. "12" (mvecp) // 17
  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"
  170. );
  171. }