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.

caxpy_microk_steamroller-2.c 7.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /***************************************************************************
  2. Copyright (c) 2014, 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 caxpy_kernel_8( BLASLONG n, FLOAT *x, FLOAT *y , FLOAT *alpha) __attribute__ ((noinline));
  29. static void caxpy_kernel_8( BLASLONG n, FLOAT *x, FLOAT *y, FLOAT *alpha)
  30. {
  31. #if !defined(CONJ)
  32. FLOAT mvec[4] = { -1.0, 1.0, -1.0, 1.0 };
  33. #else
  34. FLOAT mvec[4] = { 1.0, -1.0, 1.0, -1.0 };
  35. #endif
  36. BLASLONG register i = 0;
  37. if ( n <= 2048 )
  38. {
  39. __asm__ __volatile__
  40. (
  41. "vzeroupper \n\t"
  42. "vbroadcastss (%4), %%xmm0 \n\t" // real part of alpha
  43. "vbroadcastss 4(%4), %%xmm1 \n\t" // imag part of alpha
  44. #if !defined(CONJ)
  45. "vmulps (%5), %%xmm1 , %%xmm1 \n\t"
  46. #else
  47. "vmulps (%5), %%xmm0 , %%xmm0 \n\t"
  48. #endif
  49. ".align 16 \n\t"
  50. "1: \n\t"
  51. "vmovups (%2,%0,4), %%xmm5 \n\t" // 2 complex values from x
  52. ".align 2 \n\t"
  53. "vmovups 16(%2,%0,4), %%xmm7 \n\t" // 2 complex values from x
  54. "vmovups 32(%2,%0,4), %%xmm9 \n\t" // 2 complex values from x
  55. "vmovups 48(%2,%0,4), %%xmm11 \n\t" // 2 complex values from x
  56. "vmovups 64(%2,%0,4), %%xmm12 \n\t" // 2 complex values from x
  57. "vmovups 80(%2,%0,4), %%xmm13 \n\t" // 2 complex values from x
  58. "vmovups 96(%2,%0,4), %%xmm14 \n\t" // 2 complex values from x
  59. "vmovups 112(%2,%0,4), %%xmm15 \n\t" // 2 complex values from x
  60. "vpermilps $0xb1 , %%xmm5 , %%xmm4 \n\t" // exchange real and imag part
  61. "vpermilps $0xb1 , %%xmm7 , %%xmm6 \n\t" // exchange real and imag part
  62. "vpermilps $0xb1 , %%xmm9 , %%xmm8 \n\t" // exchange real and imag part
  63. "vpermilps $0xb1 , %%xmm11, %%xmm10 \n\t" // exchange real and imag part
  64. "vfmadd213ps (%3,%0,4), %%xmm0 , %%xmm5 \n\t"
  65. ".align 2 \n\t"
  66. "vfmadd213ps 16(%3,%0,4), %%xmm0 , %%xmm7 \n\t"
  67. "vfmadd213ps 32(%3,%0,4), %%xmm0 , %%xmm9 \n\t"
  68. "vfmadd213ps 48(%3,%0,4), %%xmm0 , %%xmm11 \n\t"
  69. "vfmadd231ps %%xmm1 , %%xmm4 , %%xmm5 \n\t"
  70. "vfmadd231ps %%xmm1 , %%xmm6 , %%xmm7 \n\t"
  71. "vfmadd231ps %%xmm1 , %%xmm8 , %%xmm9 \n\t"
  72. "vfmadd231ps %%xmm1 , %%xmm10, %%xmm11 \n\t"
  73. "vpermilps $0xb1 , %%xmm12, %%xmm4 \n\t" // exchange real and imag part
  74. "vpermilps $0xb1 , %%xmm13, %%xmm6 \n\t" // exchange real and imag part
  75. "vpermilps $0xb1 , %%xmm14, %%xmm8 \n\t" // exchange real and imag part
  76. "vpermilps $0xb1 , %%xmm15, %%xmm10 \n\t" // exchange real and imag part
  77. "vfmadd213ps 64(%3,%0,4), %%xmm0 , %%xmm12 \n\t"
  78. "vfmadd213ps 80(%3,%0,4), %%xmm0 , %%xmm13 \n\t"
  79. "vfmadd213ps 96(%3,%0,4), %%xmm0 , %%xmm14 \n\t"
  80. "vfmadd213ps 112(%3,%0,4), %%xmm0 , %%xmm15 \n\t"
  81. "vfmadd231ps %%xmm1 , %%xmm4 , %%xmm12 \n\t"
  82. "vfmadd231ps %%xmm1 , %%xmm6 , %%xmm13 \n\t"
  83. "vfmadd231ps %%xmm1 , %%xmm8 , %%xmm14 \n\t"
  84. "vfmadd231ps %%xmm1 , %%xmm10, %%xmm15 \n\t"
  85. "vmovups %%xmm5 , (%3,%0,4) \n\t"
  86. ".align 2 \n\t"
  87. "vmovups %%xmm7 , 16(%3,%0,4) \n\t"
  88. "vmovups %%xmm9 , 32(%3,%0,4) \n\t"
  89. "vmovups %%xmm11, 48(%3,%0,4) \n\t"
  90. "vmovups %%xmm12, 64(%3,%0,4) \n\t"
  91. "vmovups %%xmm13, 80(%3,%0,4) \n\t"
  92. "vmovups %%xmm14, 96(%3,%0,4) \n\t"
  93. "vmovups %%xmm15,112(%3,%0,4) \n\t"
  94. "addq $32, %0 \n\t"
  95. "subq $16, %1 \n\t"
  96. "jnz 1b \n\t"
  97. "vzeroupper \n\t"
  98. :
  99. "+r" (i), // 0
  100. "+r" (n) // 1
  101. :
  102. "r" (x), // 2
  103. "r" (y), // 3
  104. "r" (alpha), // 4
  105. "r" (mvec) // 5
  106. : "cc",
  107. "%xmm0", "%xmm1", "%xmm2", "%xmm3",
  108. "%xmm4", "%xmm5", "%xmm6", "%xmm7",
  109. "%xmm8", "%xmm9", "%xmm10", "%xmm11",
  110. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  111. "memory"
  112. );
  113. return;
  114. }
  115. __asm__ __volatile__
  116. (
  117. "vzeroupper \n\t"
  118. "vbroadcastss (%4), %%xmm0 \n\t" // real part of alpha
  119. "vbroadcastss 4(%4), %%xmm1 \n\t" // imag part of alpha
  120. #if !defined(CONJ)
  121. "vmulps (%5), %%xmm1 , %%xmm1 \n\t"
  122. #else
  123. "vmulps (%5), %%xmm0 , %%xmm0 \n\t"
  124. #endif
  125. ".align 16 \n\t"
  126. "1: \n\t"
  127. "prefetcht0 512(%2,%0,4) \n\t"
  128. "vmovups (%2,%0,4), %%xmm5 \n\t" // 2 complex values from x
  129. ".align 2 \n\t"
  130. "vmovups 16(%2,%0,4), %%xmm7 \n\t" // 2 complex values from x
  131. "vmovups 32(%2,%0,4), %%xmm9 \n\t" // 2 complex values from x
  132. "vmovups 48(%2,%0,4), %%xmm11 \n\t" // 2 complex values from x
  133. "vpermilps $0xb1 , %%xmm5 , %%xmm4 \n\t" // exchange real and imag part
  134. "vpermilps $0xb1 , %%xmm7 , %%xmm6 \n\t" // exchange real and imag part
  135. "vpermilps $0xb1 , %%xmm9 , %%xmm8 \n\t" // exchange real and imag part
  136. "vpermilps $0xb1 , %%xmm11, %%xmm10 \n\t" // exchange real and imag part
  137. "prefetcht0 512(%3,%0,4) \n\t"
  138. "vfmadd213ps (%3,%0,4), %%xmm0 , %%xmm5 \n\t"
  139. ".align 2 \n\t"
  140. "vfmadd213ps 16(%3,%0,4), %%xmm0 , %%xmm7 \n\t"
  141. "vfmadd213ps 32(%3,%0,4), %%xmm0 , %%xmm9 \n\t"
  142. "vfmadd213ps 48(%3,%0,4), %%xmm0 , %%xmm11 \n\t"
  143. "vfmadd231ps %%xmm1 , %%xmm4 , %%xmm5 \n\t"
  144. "vfmadd231ps %%xmm1 , %%xmm6 , %%xmm7 \n\t"
  145. "vfmadd231ps %%xmm1 , %%xmm8 , %%xmm9 \n\t"
  146. "vfmadd231ps %%xmm1 , %%xmm10, %%xmm11 \n\t"
  147. "vmovups %%xmm5 , (%3,%0,4) \n\t"
  148. ".align 2 \n\t"
  149. "vmovups %%xmm7 , 16(%3,%0,4) \n\t"
  150. "vmovups %%xmm9 , 32(%3,%0,4) \n\t"
  151. "vmovups %%xmm11, 48(%3,%0,4) \n\t"
  152. "addq $16, %0 \n\t"
  153. "subq $8, %1 \n\t"
  154. "jnz 1b \n\t"
  155. "vzeroupper \n\t"
  156. :
  157. "+r" (i), // 0
  158. "+r" (n) // 1
  159. :
  160. "r" (x), // 2
  161. "r" (y), // 3
  162. "r" (alpha), // 4
  163. "r" (mvec) // 5
  164. : "cc",
  165. "%xmm0", "%xmm1", "%xmm2", "%xmm3",
  166. "%xmm4", "%xmm5", "%xmm6", "%xmm7",
  167. "%xmm8", "%xmm9", "%xmm10", "%xmm11",
  168. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  169. "memory"
  170. );
  171. }