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.

sasum_microk_power8.c 5.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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/28 Werner Saar (wernsaar@googlemail.com)
  29. * BLASTEST : OK
  30. * CTEST : OK
  31. * TEST : OK
  32. * LAPACK-TEST : OK
  33. **************************************************************************************/
  34. #define HAVE_KERNEL_32 1
  35. static float sasum_kernel_32 (long n, float *x)
  36. {
  37. float sum;
  38. __vector float t0;
  39. __vector float t1;
  40. __vector float t2;
  41. __vector float t3;
  42. __asm__
  43. (
  44. "dcbt 0, %2 \n\t"
  45. "xxlxor 32, 32, 32 \n\t"
  46. "xxlxor 33, 33, 33 \n\t"
  47. "xxlxor 34, 34, 34 \n\t"
  48. "xxlxor 35, 35, 35 \n\t"
  49. "xxlxor 36, 36, 36 \n\t"
  50. "xxlxor 37, 37, 37 \n\t"
  51. "xxlxor 38, 38, 38 \n\t"
  52. "xxlxor 39, 39, 39 \n\t"
  53. "lxvd2x 40, 0, %2 \n\t"
  54. "lxvd2x 41, %8, %2 \n\t"
  55. "lxvd2x 42, %9, %2 \n\t"
  56. "lxvd2x 43, %10, %2 \n\t"
  57. "lxvd2x 44, %11, %2 \n\t"
  58. "lxvd2x 45, %12, %2 \n\t"
  59. "lxvd2x 46, %13, %2 \n\t"
  60. "lxvd2x 47, %14, %2 \n\t"
  61. "addi %2, %2, 128 \n\t"
  62. "addic. %1, %1, -32 \n\t"
  63. "ble two%= \n\t"
  64. ".align 5 \n"
  65. "one%=: \n\t"
  66. "xvabssp 48, 40 \n\t"
  67. "xvabssp 49, 41 \n\t"
  68. "xvabssp 50, 42 \n\t"
  69. "xvabssp 51, 43 \n\t"
  70. "lxvd2x 40, 0, %2 \n\t"
  71. "lxvd2x 41, %8, %2 \n\t"
  72. "xvabssp %x3, 44 \n\t"
  73. "xvabssp %x4, 45 \n\t"
  74. "lxvd2x 42, %9, %2 \n\t"
  75. "lxvd2x 43, %10, %2 \n\t"
  76. "xvabssp %x5, 46 \n\t"
  77. "xvabssp %x6, 47 \n\t"
  78. "lxvd2x 44, %11, %2 \n\t"
  79. "lxvd2x 45, %12, %2 \n\t"
  80. "xvaddsp 32, 32, 48 \n\t"
  81. "xvaddsp 33, 33, 49 \n\t"
  82. "lxvd2x 46, %13, %2 \n\t"
  83. "lxvd2x 47, %14, %2 \n\t"
  84. "xvaddsp 34, 34, 50 \n\t"
  85. "xvaddsp 35, 35, 51 \n\t"
  86. "addi %2, %2, 128 \n\t"
  87. "xvaddsp 36, 36, %x3 \n\t"
  88. "xvaddsp 37, 37, %x4 \n\t"
  89. "addic. %1, %1, -32 \n\t"
  90. "xvaddsp 38, 38, %x5 \n\t"
  91. "xvaddsp 39, 39, %x6 \n\t"
  92. "bgt one%= \n"
  93. "two%=: \n\t"
  94. "xvabssp 48, 40 \n\t"
  95. "xvabssp 49, 41 \n\t"
  96. "xvabssp 50, 42 \n\t"
  97. "xvabssp 51, 43 \n\t"
  98. "xvabssp %x3, 44 \n\t"
  99. "xvabssp %x4, 45 \n\t"
  100. "xvabssp %x5, 46 \n\t"
  101. "xvabssp %x6, 47 \n\t"
  102. "xvaddsp 32, 32, 48 \n\t"
  103. "xvaddsp 33, 33, 49 \n\t"
  104. "xvaddsp 34, 34, 50 \n\t"
  105. "xvaddsp 35, 35, 51 \n\t"
  106. "xvaddsp 36, 36, %x3 \n\t"
  107. "xvaddsp 37, 37, %x4 \n\t"
  108. "xvaddsp 38, 38, %x5 \n\t"
  109. "xvaddsp 39, 39, %x6 \n\t"
  110. "xvaddsp 32, 32, 33 \n\t"
  111. "xvaddsp 34, 34, 35 \n\t"
  112. "xvaddsp 36, 36, 37 \n\t"
  113. "xvaddsp 38, 38, 39 \n\t"
  114. "xvaddsp 32, 32, 34 \n\t"
  115. "xvaddsp 36, 36, 38 \n\t"
  116. "xvaddsp 32, 32, 36 \n\t"
  117. "xxsldwi 33, 32, 32, 2 \n\t"
  118. "xvaddsp 32, 32, 33 \n\t"
  119. "xxsldwi 33, 32, 32, 1 \n\t"
  120. "xvaddsp 32, 32, 33 \n\t"
  121. "xscvspdp %x0, 32 \n"
  122. "#n=%1 x=%3=%2 sum=%0 o16=%8 o32=%9 o48=%10 o64=%11 o80=%12 o96=%13 o112=%14\n"
  123. "#t0=%x3 t1=%x4 t2=%x5 t3=%x6"
  124. :
  125. "=f" (sum), // 0
  126. "+r" (n), // 1
  127. "+b" (x), // 2
  128. "=wa" (t0), // 3
  129. "=wa" (t1), // 4
  130. "=wa" (t2), // 5
  131. "=wa" (t3) // 6
  132. :
  133. "m" (*x),
  134. "b" (16), // 8
  135. "b" (32), // 9
  136. "b" (48), // 10
  137. "b" (64), // 11
  138. "b" (80), // 12
  139. "b" (96), // 13
  140. "b" (112) // 14
  141. :
  142. "cr0",
  143. "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
  144. "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
  145. "vs48","vs49","vs50","vs51"
  146. );
  147. return sum;
  148. }