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.

cdot_microk_power10.c 7.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 cdot_kernel_8 (long n, float *x, float *y, float *dot)
  29. {
  30. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  31. __vector unsigned char mask = {4,5,6,7, 0,1,2,3, 12,13,14,15, 8,9,10,11};
  32. #else
  33. __vector unsigned char mask = { 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4};
  34. #endif
  35. __asm__
  36. (
  37. "dcbt 0, %2 \n\t"
  38. "dcbt 0, %3 \n\t"
  39. "xxlxor 32, 32, 32 \n\t"
  40. "xxlxor 33, 33, 33 \n\t"
  41. "xxlxor 34, 34, 34 \n\t"
  42. "xxlxor 35, 35, 35 \n\t"
  43. "xxlxor 36, 36, 36 \n\t"
  44. "xxlxor 37, 37, 37 \n\t"
  45. "xxlxor 38, 38, 38 \n\t"
  46. "xxlxor 39, 39, 39 \n\t"
  47. "lxvp 40, 0(%2) \n\t"
  48. "lxvp 42, 32(%2) \n\t"
  49. "lxvp 44, 64(%2) \n\t"
  50. "lxvp 46, 96(%2) \n\t"
  51. "lxvp 48, 0(%3) \n\t"
  52. "lxvp 50, 32(%3) \n\t"
  53. "lxvp 52, 64(%3) \n\t"
  54. "lxvp 54, 96(%3) \n\t"
  55. "xxperm 56, 48, %x7 \n\t"
  56. "xxperm 57, 49, %x7 \n\t"
  57. "xxperm 58, 50, %x7 \n\t"
  58. "xxperm 59, 51, %x7 \n\t"
  59. "xxperm 60, 52, %x7 \n\t"
  60. "xxperm 61, 53, %x7 \n\t"
  61. "xxperm 62, 54, %x7 \n\t"
  62. "xxperm 63, 55, %x7 \n\t"
  63. "addi %2, %2, 128 \n\t"
  64. "addi %3, %3, 128 \n\t"
  65. "addic. %1, %1, -16 \n\t"
  66. "ble two%= \n\t"
  67. ".align 5 \n"
  68. "one%=: \n\t"
  69. "xvmaddasp 32, 40, 48 \n\t" // x0_r * y0_r , x0_i * y0_i
  70. "xvmaddasp 34, 41, 49 \n\t" // x1_r * y1_r , x1_i * y1_i
  71. "lxvp 48, 0(%3) \n\t"
  72. "xvmaddasp 36, 42, 50 \n\t" // x2_r * y2_r , x2_i * y2_i
  73. "xvmaddasp 38, 43, 51 \n\t" // x3_r * y3_r , x3_i * y3_i
  74. "lxvp 50, 32(%3) \n\t"
  75. "xvmaddasp 33, 40, 56 \n\t" // x0_r * y0_i , x0_i * y0_r
  76. "xvmaddasp 35, 41, 57 \n\t" // x1_r * y1_i , x1_i * y1_r
  77. "lxvp 40, 0(%2) \n\t"
  78. "xvmaddasp 37, 42, 58 \n\t" // x2_r * y2_i , x2_i * y2_r
  79. "xvmaddasp 39, 43, 59 \n\t" // x3_r * y3_i , x3_i * y3_r
  80. "lxvp 42, 32(%2) \n\t"
  81. "xxperm 56, 48, %x7 \n\t"
  82. "xxperm 57, 49, %x7 \n\t"
  83. "xxperm 58, 50, %x7 \n\t"
  84. "xxperm 59, 51, %x7 \n\t"
  85. "xvmaddasp 32, 44, 52 \n\t" // x0_r * y0_r , x0_i * y0_i
  86. "xvmaddasp 34, 45, 53 \n\t" // x1_r * y1_r , x1_i * y1_i
  87. "lxvp 52, 64(%3) \n\t"
  88. "xvmaddasp 36, 46, 54 \n\t" // x2_r * y2_r , x2_i * y2_i
  89. "xvmaddasp 38, 47, 55 \n\t" // x3_r * y3_r , x3_i * y3_i
  90. "lxvp 54, 96(%3) \n\t"
  91. "xvmaddasp 33, 44, 60 \n\t" // x0_r * y0_i , x0_i * y0_r
  92. "xvmaddasp 35, 45, 61 \n\t" // x1_r * y1_i , x1_i * y1_r
  93. "lxvp 44, 64(%2) \n\t"
  94. "xvmaddasp 37, 46, 62 \n\t" // x2_r * y2_i , x2_i * y2_r
  95. "xvmaddasp 39, 47, 63 \n\t" // x3_r * y3_i , x3_i * y3_r
  96. "lxvp 46, 96(%2) \n\t"
  97. "xxperm 60, 52, %x7 \n\t"
  98. "xxperm 61, 53, %x7 \n\t"
  99. "xxperm 62, 54, %x7 \n\t"
  100. "xxperm 63, 55, %x7 \n\t"
  101. "addi %2, %2, 128 \n\t"
  102. "addi %3, %3, 128 \n\t"
  103. "addic. %1, %1, -16 \n\t"
  104. "bgt one%= \n"
  105. "two%=: \n\t"
  106. "xvmaddasp 32, 40, 48 \n\t" // x0_r * y0_r , x0_i * y0_i
  107. "xvmaddasp 34, 41, 49 \n\t" // x1_r * y1_r , x1_i * y1_i
  108. "xvmaddasp 36, 42, 50 \n\t" // x2_r * y2_r , x2_i * y2_i
  109. "xvmaddasp 38, 43, 51 \n\t" // x3_r * y3_r , x3_i * y3_i
  110. "xvmaddasp 33, 40, 56 \n\t" // x0_r * y0_i , x0_i * y0_r
  111. "xvmaddasp 35, 41, 57 \n\t" // x1_r * y1_i , x1_i * y1_r
  112. "xvmaddasp 37, 42, 58 \n\t" // x2_r * y2_i , x2_i * y2_r
  113. "xvmaddasp 39, 43, 59 \n\t" // x3_r * y3_i , x3_i * y3_r
  114. "xvmaddasp 32, 44, 52 \n\t" // x0_r * y0_r , x0_i * y0_i
  115. "xvmaddasp 34, 45, 53 \n\t" // x1_r * y1_r , x1_i * y1_i
  116. "xvmaddasp 36, 46, 54 \n\t" // x2_r * y2_r , x2_i * y2_i
  117. "xvmaddasp 38, 47, 55 \n\t" // x3_r * y3_r , x3_i * y3_i
  118. "xvmaddasp 33, 44, 60 \n\t" // x0_r * y0_i , x0_i * y0_r
  119. "xvmaddasp 35, 45, 61 \n\t" // x1_r * y1_i , x1_i * y1_r
  120. "xvmaddasp 37, 46, 62 \n\t" // x2_r * y2_i , x2_i * y2_r
  121. "xvmaddasp 39, 47, 63 \n\t" // x3_r * y3_i , x3_i * y3_r
  122. "xvaddsp 32, 32, 34 \n\t"
  123. "xvaddsp 36, 36, 38 \n\t"
  124. "xvaddsp 33, 33, 35 \n\t"
  125. "xvaddsp 37, 37, 39 \n\t"
  126. "xvaddsp 35, 32, 36 \n\t"
  127. "xvaddsp 34, 33, 37 \n\t"
  128. "xxswapd 32, 35 \n\t"
  129. "xxswapd 33, 34 \n\t"
  130. "xvaddsp 35, 35, 32 \n\t"
  131. "xvaddsp 34, 34, 33 \n\t"
  132. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  133. "xxpermdi 34, 35, 34, 0 \n\t"
  134. #else
  135. "xxpermdi 34, 34, 35, 2 \n\t"
  136. #endif
  137. "stxv 34, 0(%6) \n\t"
  138. "#n=%1 x=%4=%2 y=%5=%3 dot=%0=%6"
  139. :
  140. "=m" (*dot),
  141. "+r" (n), // 1
  142. "+b" (x), // 2
  143. "+b" (y) // 3
  144. :
  145. "m" (*x),
  146. "m" (*y),
  147. "b" (dot), // 6
  148. "wa" (mask)
  149. :
  150. "cr0",
  151. "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
  152. "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
  153. "vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55",
  154. "vs56","vs57","vs58","vs59","vs60","vs61","vs62","vs63"
  155. );
  156. }