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.

sdot_microk_power10.c 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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_16 1
  28. static float sdot_kernel_16 (long n, float *x, float *y)
  29. {
  30. float dot;
  31. __asm__
  32. (
  33. "dcbt 0, %2 \n\t"
  34. "dcbt 0, %3 \n\t"
  35. "xxlxor 32, 32, 32 \n\t"
  36. "xxlxor 33, 33, 33 \n\t"
  37. "xxlxor 34, 34, 34 \n\t"
  38. "xxlxor 35, 35, 35 \n\t"
  39. "xxlxor 36, 36, 36 \n\t"
  40. "xxlxor 37, 37, 37 \n\t"
  41. "xxlxor 38, 38, 38 \n\t"
  42. "xxlxor 39, 39, 39 \n\t"
  43. "lxvp 40, 0(%2) \n\t"
  44. "lxvp 42, 32(%2) \n\t"
  45. "lxvp 44, 64(%2) \n\t"
  46. "lxvp 46, 96(%2) \n\t"
  47. "lxvp 48, 0(%3) \n\t"
  48. "lxvp 50, 32(%3) \n\t"
  49. "lxvp 52, 64(%3) \n\t"
  50. "lxvp 54, 96(%3) \n\t"
  51. "addi %2, %2, 128 \n\t"
  52. "addi %3, %3, 128 \n\t"
  53. "addic. %1, %1, -32 \n\t"
  54. "ble two%= \n\t"
  55. ".align 5 \n"
  56. "one%=: \n\t"
  57. "xvmaddasp 32, 40, 48 \n\t"
  58. "xvmaddasp 33, 41, 49 \n\t"
  59. "lxvp 40, 0(%2) \n\t"
  60. "lxvp 48, 0(%3) \n\t"
  61. "xvmaddasp 34, 42, 50 \n\t"
  62. "xvmaddasp 35, 43, 51 \n\t"
  63. "lxvp 42, 32(%2) \n\t"
  64. "lxvp 50, 32(%3) \n\t"
  65. "xvmaddasp 36, 44, 52 \n\t"
  66. "xvmaddasp 37, 45, 53 \n\t"
  67. "lxvp 44, 64(%2) \n\t"
  68. "lxvp 52, 64(%3) \n\t"
  69. "xvmaddasp 38, 46, 54 \n\t"
  70. "xvmaddasp 39, 47, 55 \n\t"
  71. "lxvp 46, 96(%2) \n\t"
  72. "lxvp 54, 96(%3) \n\t"
  73. "addi %2, %2, 128 \n\t"
  74. "addi %3, %3, 128 \n\t"
  75. "addic. %1, %1, -32 \n\t"
  76. "bgt one%= \n"
  77. "two%=: \n\t"
  78. "xvmaddasp 32, 40, 48 \n\t"
  79. "xvmaddasp 33, 41, 49 \n\t"
  80. "xvmaddasp 34, 42, 50 \n\t"
  81. "xvmaddasp 35, 43, 51 \n\t"
  82. "xvmaddasp 36, 44, 52 \n\t"
  83. "xvmaddasp 37, 45, 53 \n\t"
  84. "xvmaddasp 38, 46, 54 \n\t"
  85. "xvmaddasp 39, 47, 55 \n\t"
  86. "xvaddsp 32, 32, 33 \n\t"
  87. "xvaddsp 34, 34, 35 \n\t"
  88. "xvaddsp 36, 36, 37 \n\t"
  89. "xvaddsp 38, 38, 39 \n\t"
  90. "xvaddsp 32, 32, 34 \n\t"
  91. "xvaddsp 36, 36, 38 \n\t"
  92. "xvaddsp 32, 32, 36 \n\t"
  93. "xxsldwi 33, 32, 32, 2 \n\t"
  94. "xvaddsp 32, 32, 33 \n\t"
  95. "xxsldwi 33, 32, 32, 1 \n\t"
  96. "xvaddsp 32, 32, 33 \n\t"
  97. "xscvspdp %x0, 32 \n"
  98. "#dot=%0 n=%1 x=%4=%2 y=%5=%3\n"
  99. :
  100. "=f" (dot), // 0
  101. "+r" (n), // 1
  102. "+b" (x), // 2
  103. "+b" (y) // 3
  104. :
  105. "m" (*x),
  106. "m" (*y)
  107. :
  108. "cr0",
  109. "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
  110. "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47",
  111. "vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55"
  112. );
  113. return dot;
  114. }