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.

srot_microk_power10.c 5.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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_16 1
  28. static void srot_kernel_16 (long n, float *x, float *y, float c, float s)
  29. {
  30. __asm__
  31. (
  32. "xscvdpspn 36, %x5 \n\t" // load c to all words
  33. "xxspltw 36, 36, 0 \n\t"
  34. "xscvdpspn 37, %x6 \n\t" // load s to all words
  35. "xxspltw 37, 37, 0 \n\t"
  36. "lxvp 32, 0(%3) \n\t" // load x
  37. "lxvp 34, 32(%3) \n\t"
  38. "lxvp 48, 0(%4) \n\t" // load y
  39. "lxvp 50, 32(%4) \n\t"
  40. "addic. %2, %2, -16 \n\t"
  41. "ble two%= \n\t"
  42. ".align 5 \n"
  43. "one%=: \n\t"
  44. "xvmulsp 40, 32, 36 \n\t" // c * x
  45. "xvmulsp 41, 33, 36 \n\t"
  46. "xvmulsp 42, 34, 36 \n\t"
  47. "xvmulsp 43, 35, 36 \n\t"
  48. "xvmulsp 44, 32, 37 \n\t" // s * x
  49. "xvmulsp 45, 33, 37 \n\t"
  50. "xvmulsp 46, 34, 37 \n\t"
  51. "xvmulsp 47, 35, 37 \n\t"
  52. "lxvp 32, 64(%3) \n\t" // load x
  53. "lxvp 34, 96(%3) \n\t"
  54. "xvmulsp 52, 48, 36 \n\t" // c * y
  55. "xvmulsp 53, 49, 36 \n\t"
  56. "xvmulsp 54, 50, 36 \n\t"
  57. "xvmulsp 55, 51, 36 \n\t"
  58. "xvmulsp 38, 48, 37 \n\t" // s * y
  59. "xvmulsp 39, 49, 37 \n\t"
  60. "xvmulsp 56, 50, 37 \n\t"
  61. "xvmulsp 57, 51, 37 \n\t"
  62. "lxvp 48, 64(%4) \n\t" // load y
  63. "lxvp 50, 96(%4) \n\t"
  64. "xvaddsp 40, 40, 38 \n\t" // c * x + s * y
  65. "xvaddsp 41, 41, 39 \n\t" // c * x + s * y
  66. "xvaddsp 42, 42, 56 \n\t" // c * x + s * y
  67. "xvaddsp 43, 43, 57 \n\t" // c * x + s * y
  68. "stxvp 40, 0(%3) \n\t" // store x
  69. "stxvp 42, 32(%3) \n\t"
  70. "xvsubsp 52, 52, 44 \n\t" // c * y - s * x
  71. "xvsubsp 53, 53, 45 \n\t" // c * y - s * x
  72. "xvsubsp 54, 54, 46 \n\t" // c * y - s * x
  73. "xvsubsp 55, 55, 47 \n\t" // c * y - s * x
  74. "stxvp 52, 0(%4) \n\t" // store y
  75. "stxvp 54, 32(%4) \n\t"
  76. "addi %3, %3, 64 \n\t"
  77. "addi %4, %4, 64 \n\t"
  78. "addic. %2, %2, -16 \n\t"
  79. "bgt one%= \n"
  80. "two%=: \n\t"
  81. "xvmulsp 40, 32, 36 \n\t" // c * x
  82. "xvmulsp 41, 33, 36 \n\t"
  83. "xvmulsp 42, 34, 36 \n\t"
  84. "xvmulsp 43, 35, 36 \n\t"
  85. "xvmulsp 52, 48, 36 \n\t" // c * y
  86. "xvmulsp 53, 49, 36 \n\t"
  87. "xvmulsp 54, 50, 36 \n\t"
  88. "xvmulsp 55, 51, 36 \n\t"
  89. "xvmulsp 44, 32, 37 \n\t" // s * x
  90. "xvmulsp 45, 33, 37 \n\t"
  91. "xvmulsp 46, 34, 37 \n\t"
  92. "xvmulsp 47, 35, 37 \n\t"
  93. "xvmulsp 38, 48, 37 \n\t" // s * y
  94. "xvmulsp 39, 49, 37 \n\t"
  95. "xvmulsp 56, 50, 37 \n\t"
  96. "xvmulsp 57, 51, 37 \n\t"
  97. "xvaddsp 40, 40, 38 \n\t" // c * x + s * y
  98. "xvaddsp 41, 41, 39 \n\t" // c * x + s * y
  99. "xvaddsp 42, 42, 56 \n\t" // c * x + s * y
  100. "xvaddsp 43, 43, 57 \n\t" // c * x + s * y
  101. "stxvp 40, 0(%3) \n\t" // store x
  102. "stxvp 42, 32(%3) \n\t"
  103. "xvsubsp 52, 52, 44 \n\t" // c * y - s * x
  104. "xvsubsp 53, 53, 45 \n\t" // c * y - s * x
  105. "xvsubsp 54, 54, 46 \n\t" // c * y - s * x
  106. "xvsubsp 55, 55, 47 \n\t" // c * y - s * x
  107. "stxvp 52, 0(%4) \n\t" // store y
  108. "stxvp 54, 32(%4) \n\t"
  109. "#n=%2 x=%0=%3 y=%1=%4 c=%5 s=%6\n"
  110. :
  111. "+m" (*x),
  112. "+m" (*y),
  113. "+r" (n), // 2
  114. "+b" (x), // 3
  115. "+b" (y) // 4
  116. :
  117. "f" (c), // 5
  118. "f" (s) // 6
  119. :
  120. "cr0",
  121. "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
  122. "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
  123. "vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55",
  124. "vs56","vs57"
  125. );
  126. }