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.

dscal_microk_sandy-2.c 6.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /***************************************************************************
  2. Copyright (c) 2014-2015, 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 dscal_kernel_8( BLASLONG n, FLOAT *alpha, FLOAT *x) __attribute__ ((noinline));
  29. static void dscal_kernel_8( BLASLONG n, FLOAT *alpha, FLOAT *x)
  30. {
  31. BLASLONG n1 = n >> 4 ;
  32. BLASLONG n2 = n & 8 ;
  33. __asm__ __volatile__
  34. (
  35. "vmovddup (%2), %%xmm0 \n\t" // alpha
  36. "addq $128, %1 \n\t"
  37. "cmpq $0, %0 \n\t"
  38. "je 4f \n\t"
  39. "vmulpd -128(%1), %%xmm0, %%xmm4 \n\t"
  40. "vmulpd -112(%1), %%xmm0, %%xmm5 \n\t"
  41. "vmulpd -96(%1), %%xmm0, %%xmm6 \n\t"
  42. "vmulpd -80(%1), %%xmm0, %%xmm7 \n\t"
  43. "vmulpd -64(%1), %%xmm0, %%xmm8 \n\t"
  44. "vmulpd -48(%1), %%xmm0, %%xmm9 \n\t"
  45. "vmulpd -32(%1), %%xmm0, %%xmm10 \n\t"
  46. "vmulpd -16(%1), %%xmm0, %%xmm11 \n\t"
  47. "subq $1 , %0 \n\t"
  48. "jz 2f \n\t"
  49. ".p2align 4 \n\t"
  50. "1: \n\t"
  51. "prefetcht0 640(%1) \n\t"
  52. "vmovups %%xmm4 ,-128(%1) \n\t"
  53. "vmovups %%xmm5 ,-112(%1) \n\t"
  54. "vmulpd 0(%1), %%xmm0, %%xmm4 \n\t"
  55. "vmovups %%xmm6 , -96(%1) \n\t"
  56. "vmulpd 16(%1), %%xmm0, %%xmm5 \n\t"
  57. "vmovups %%xmm7 , -80(%1) \n\t"
  58. "vmulpd 32(%1), %%xmm0, %%xmm6 \n\t"
  59. "prefetcht0 704(%1) \n\t"
  60. "vmovups %%xmm8 , -64(%1) \n\t"
  61. "vmulpd 48(%1), %%xmm0, %%xmm7 \n\t"
  62. "vmovups %%xmm9 , -48(%1) \n\t"
  63. "vmulpd 64(%1), %%xmm0, %%xmm8 \n\t"
  64. "vmovups %%xmm10 , -32(%1) \n\t"
  65. "vmulpd 80(%1), %%xmm0, %%xmm9 \n\t"
  66. "vmovups %%xmm11 , -16(%1) \n\t"
  67. "vmulpd 96(%1), %%xmm0, %%xmm10 \n\t"
  68. "vmulpd 112(%1), %%xmm0, %%xmm11 \n\t"
  69. "addq $128, %1 \n\t"
  70. "subq $1 , %0 \n\t"
  71. "jnz 1b \n\t"
  72. "2: \n\t"
  73. "vmovups %%xmm4 ,-128(%1) \n\t"
  74. "vmovups %%xmm5 ,-112(%1) \n\t"
  75. "vmovups %%xmm6 , -96(%1) \n\t"
  76. "vmovups %%xmm7 , -80(%1) \n\t"
  77. "vmovups %%xmm8 , -64(%1) \n\t"
  78. "vmovups %%xmm9 , -48(%1) \n\t"
  79. "vmovups %%xmm10 , -32(%1) \n\t"
  80. "vmovups %%xmm11 , -16(%1) \n\t"
  81. "addq $128, %1 \n\t"
  82. "4: \n\t"
  83. "cmpq $8 ,%3 \n\t"
  84. "jne 5f \n\t"
  85. "vmulpd -128(%1), %%xmm0, %%xmm4 \n\t"
  86. "vmulpd -112(%1), %%xmm0, %%xmm5 \n\t"
  87. "vmulpd -96(%1), %%xmm0, %%xmm6 \n\t"
  88. "vmulpd -80(%1), %%xmm0, %%xmm7 \n\t"
  89. "vmovups %%xmm4 ,-128(%1) \n\t"
  90. "vmovups %%xmm5 ,-112(%1) \n\t"
  91. "vmovups %%xmm6 , -96(%1) \n\t"
  92. "vmovups %%xmm7 , -80(%1) \n\t"
  93. "5: \n\t"
  94. "vzeroupper \n\t"
  95. :
  96. "+r" (n1), // 0
  97. "+r" (x) // 1
  98. :
  99. "r" (alpha), // 2
  100. "r" (n2) // 3
  101. : "cc",
  102. "%xmm0", "%xmm1", "%xmm2", "%xmm3",
  103. "%xmm4", "%xmm5", "%xmm6", "%xmm7",
  104. "%xmm8", "%xmm9", "%xmm10", "%xmm11",
  105. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  106. "memory"
  107. );
  108. }
  109. static void dscal_kernel_8_zero( BLASLONG n, FLOAT *alpha, FLOAT *x) __attribute__ ((noinline));
  110. static void dscal_kernel_8_zero( BLASLONG n, FLOAT *alpha, FLOAT *x)
  111. {
  112. BLASLONG n1 = n >> 4 ;
  113. BLASLONG n2 = n & 8 ;
  114. __asm__ __volatile__
  115. (
  116. "vxorpd %%xmm0, %%xmm0 , %%xmm0 \n\t"
  117. "addq $128, %1 \n\t"
  118. "cmpq $0, %0 \n\t"
  119. "je 2f \n\t"
  120. ".p2align 4 \n\t"
  121. "1: \n\t"
  122. "vmovups %%xmm0 ,-128(%1) \n\t"
  123. "vmovups %%xmm0 ,-112(%1) \n\t"
  124. "vmovups %%xmm0 , -96(%1) \n\t"
  125. "vmovups %%xmm0 , -80(%1) \n\t"
  126. "vmovups %%xmm0 , -64(%1) \n\t"
  127. "vmovups %%xmm0 , -48(%1) \n\t"
  128. "vmovups %%xmm0 , -32(%1) \n\t"
  129. "vmovups %%xmm0 , -16(%1) \n\t"
  130. "addq $128, %1 \n\t"
  131. "subq $1 , %0 \n\t"
  132. "jnz 1b \n\t"
  133. "2: \n\t"
  134. "cmpq $8 ,%3 \n\t"
  135. "jne 4f \n\t"
  136. "vmovups %%xmm0 ,-128(%1) \n\t"
  137. "vmovups %%xmm0 ,-112(%1) \n\t"
  138. "vmovups %%xmm0 , -96(%1) \n\t"
  139. "vmovups %%xmm0 , -80(%1) \n\t"
  140. "4: \n\t"
  141. "vzeroupper \n\t"
  142. :
  143. "+r" (n1), // 0
  144. "+r" (x) // 1
  145. :
  146. "r" (alpha), // 2
  147. "r" (n2) // 3
  148. : "cc",
  149. "%xmm0", "%xmm1", "%xmm2", "%xmm3",
  150. "%xmm4", "%xmm5", "%xmm6", "%xmm7",
  151. "%xmm8", "%xmm9", "%xmm10", "%xmm11",
  152. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  153. "memory"
  154. );
  155. }