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.

drot_microk_power8.c 6.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /***************************************************************************
  2. Copyright (c) 2013-2016, 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. /**************************************************************************************
  28. * 2016/03/27 Werner Saar (wernsaar@googlemail.com)
  29. *
  30. * I don't use fused multiply-add ( precision problems with lapack )
  31. *
  32. * BLASTEST : OK
  33. * CTEST : OK
  34. * TEST : OK
  35. * LAPACK-TEST : OK
  36. **************************************************************************************/
  37. #define HAVE_KERNEL_16 1
  38. static void drot_kernel_16( BLASLONG n, FLOAT *x, FLOAT *y, FLOAT *c, FLOAT *s) __attribute__ ((noinline));
  39. static void drot_kernel_16( BLASLONG n, FLOAT *x, FLOAT *y, FLOAT *c, FLOAT *s)
  40. {
  41. BLASLONG i = n;
  42. BLASLONG o16 = 16;
  43. BLASLONG o32 = 32;
  44. BLASLONG o48 = 48;
  45. FLOAT *x1=x;
  46. FLOAT *y1=y;
  47. FLOAT *x2=x+1;
  48. FLOAT *y2=y+1;
  49. __asm__ __volatile__
  50. (
  51. "lxsdx 36 , %5, %3 \n\t" // load c
  52. "lxsdx 37 , %5, %4 \n\t" // load s
  53. "addi %8 , %8, -8 \n\t"
  54. "addi %9 , %9, -8 \n\t"
  55. "xxspltd 36 , 36, 0 \n\t"
  56. "xxspltd 37 , 37, 0 \n\t"
  57. "lxvd2x 32, 0, %1 \n\t" // load x
  58. "lxvd2x 33, %5, %1 \n\t"
  59. "lxvd2x 34, %6, %1 \n\t"
  60. "lxvd2x 35, %7, %1 \n\t"
  61. "lxvd2x 40, 0, %2 \n\t" // load y
  62. "lxvd2x 41, %5, %2 \n\t"
  63. "lxvd2x 42, %6, %2 \n\t"
  64. "lxvd2x 43, %7, %2 \n\t"
  65. "addi %1, %1, 64 \n\t"
  66. "addi %2, %2, 64 \n\t"
  67. "addic. %0 , %0 , -8 \n\t"
  68. "ble 2f \n\t"
  69. ".align 5 \n\t"
  70. "1: \n\t"
  71. "xvmuldp 48, 32, 36 \n\t" // c * x
  72. "xvmuldp 49, 33, 36 \n\t"
  73. "xvmuldp 50, 34, 36 \n\t"
  74. "xvmuldp 51, 35, 36 \n\t"
  75. "xvmuldp 56, 40, 36 \n\t" // c * y
  76. "xvmuldp 57, 41, 36 \n\t"
  77. "xvmuldp 58, 42, 36 \n\t"
  78. "xvmuldp 59, 43, 36 \n\t"
  79. "xvmuldp 52, 32, 37 \n\t" // s * x
  80. "xvmuldp 53, 33, 37 \n\t"
  81. "lxvd2x 32, 0, %1 \n\t" // load x
  82. "lxvd2x 33, %5, %1 \n\t"
  83. "xvmuldp 54, 34, 37 \n\t"
  84. "xvmuldp 55, 35, 37 \n\t"
  85. "lxvd2x 34, %6, %1 \n\t"
  86. "lxvd2x 35, %7, %1 \n\t"
  87. "xvmuldp 60, 40, 37 \n\t" // s * y
  88. "xvmuldp 61, 41, 37 \n\t"
  89. "lxvd2x 40, 0, %2 \n\t" // load y
  90. "lxvd2x 41, %5, %2 \n\t"
  91. "xvmuldp 62, 42, 37 \n\t"
  92. "xvmuldp 63, 43, 37 \n\t"
  93. "lxvd2x 42, %6, %2 \n\t"
  94. "lxvd2x 43, %7, %2 \n\t"
  95. "xvadddp 48, 48 , 60 \n\t" // c * x + s * y
  96. "xvadddp 49, 49 , 61 \n\t" // c * x + s * y
  97. "addi %1, %1, 64 \n\t"
  98. "addi %2, %2, 64 \n\t"
  99. "xvadddp 50, 50 , 62 \n\t" // c * x + s * y
  100. "xvadddp 51, 51 , 63 \n\t" // c * x + s * y
  101. "xvsubdp 56, 56 , 52 \n\t" // c * y - s * x
  102. "xvsubdp 57, 57 , 53 \n\t" // c * y - s * x
  103. "xvsubdp 58, 58 , 54 \n\t" // c * y - s * x
  104. "xvsubdp 59, 59 , 55 \n\t" // c * y - s * x
  105. "stxvd2x 48, 0, %8 \n\t" // store x
  106. "stxvd2x 49, %5, %8 \n\t"
  107. "stxvd2x 50, %6, %8 \n\t"
  108. "stxvd2x 51, %7, %8 \n\t"
  109. "stxvd2x 56, 0, %9 \n\t" // store y
  110. "stxvd2x 57, %5, %9 \n\t"
  111. "stxvd2x 58, %6, %9 \n\t"
  112. "stxvd2x 59, %7, %9 \n\t"
  113. "addi %8, %8, 64 \n\t"
  114. "addi %9, %9, 64 \n\t"
  115. "addic. %0 , %0 , -8 \n\t"
  116. "bgt 1b \n\t"
  117. "2: \n\t"
  118. "xvmuldp 48, 32, 36 \n\t" // c * x
  119. "xvmuldp 49, 33, 36 \n\t"
  120. "xvmuldp 50, 34, 36 \n\t"
  121. "xvmuldp 51, 35, 36 \n\t"
  122. "xvmuldp 56, 40, 36 \n\t" // c * y
  123. "xvmuldp 57, 41, 36 \n\t"
  124. "xvmuldp 58, 42, 36 \n\t"
  125. "xvmuldp 59, 43, 36 \n\t"
  126. "xvmuldp 52, 32, 37 \n\t" // s * x
  127. "xvmuldp 53, 33, 37 \n\t"
  128. "xvmuldp 54, 34, 37 \n\t"
  129. "xvmuldp 55, 35, 37 \n\t"
  130. "xvmuldp 60, 40, 37 \n\t" // s * y
  131. "xvmuldp 61, 41, 37 \n\t"
  132. "xvmuldp 62, 42, 37 \n\t"
  133. "xvmuldp 63, 43, 37 \n\t"
  134. "xvadddp 48, 48 , 60 \n\t" // c * x + s * y
  135. "xvadddp 49, 49 , 61 \n\t" // c * x + s * y
  136. "xvadddp 50, 50 , 62 \n\t" // c * x + s * y
  137. "xvadddp 51, 51 , 63 \n\t" // c * x + s * y
  138. "xvsubdp 56, 56 , 52 \n\t" // c * y - s * x
  139. "xvsubdp 57, 57 , 53 \n\t" // c * y - s * x
  140. "xvsubdp 58, 58 , 54 \n\t" // c * y - s * x
  141. "xvsubdp 59, 59 , 55 \n\t" // c * y - s * x
  142. "stxvd2x 48, 0, %8 \n\t" // store x
  143. "stxvd2x 49, %5, %8 \n\t"
  144. "stxvd2x 50, %6, %8 \n\t"
  145. "stxvd2x 51, %7, %8 \n\t"
  146. "stxvd2x 56, 0, %9 \n\t" // store y
  147. "stxvd2x 57, %5, %9 \n\t"
  148. "stxvd2x 58, %6, %9 \n\t"
  149. "stxvd2x 59, %7, %9 \n\t"
  150. :
  151. :
  152. "r" (i), // 0
  153. "r" (x1), // 1
  154. "r" (y1), // 2
  155. "r" (c), // 3
  156. "r" (s), // 4
  157. "r" (o16), // 5
  158. "r" (o32), // 6
  159. "r" (o48), // 7
  160. "r" (x2), // 8
  161. "r" (y2) // 9
  162. : "cr0", "%0", "%1" , "%2", "%8", "%9", "memory"
  163. );
  164. }