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_haswell-2.c 5.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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[8] = { -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 };
  33. #else
  34. FLOAT mvec[8] = { 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0 };
  35. #endif
  36. BLASLONG register i = 0;
  37. __asm__ __volatile__
  38. (
  39. "vzeroupper \n\t"
  40. "vbroadcastss (%4), %%ymm0 \n\t" // real part of alpha
  41. "vbroadcastss 4(%4), %%ymm1 \n\t" // imag part of alpha
  42. #if !defined(CONJ)
  43. "vmulps (%5), %%ymm1 , %%ymm1 \n\t"
  44. #else
  45. "vmulps (%5), %%ymm0 , %%ymm0 \n\t"
  46. #endif
  47. ".p2align 4 \n\t"
  48. "1: \n\t"
  49. "vmovups (%2,%0,4), %%ymm5 \n\t" // 4 complex values from x
  50. ".p2align 1 \n\t"
  51. "vmovups 32(%2,%0,4), %%ymm7 \n\t" // 4 complex values from x
  52. "vmovups 64(%2,%0,4), %%ymm9 \n\t" // 4 complex values from x
  53. "vmovups 96(%2,%0,4), %%ymm11 \n\t" // 4 complex values from x
  54. "vmovups 128(%2,%0,4), %%ymm12 \n\t" // 4 complex values from x
  55. "vmovups 160(%2,%0,4), %%ymm13 \n\t" // 4 complex values from x
  56. "vmovups 192(%2,%0,4), %%ymm14 \n\t" // 4 complex values from x
  57. "vmovups 224(%2,%0,4), %%ymm15 \n\t" // 4 complex values from x
  58. "vpermilps $0xb1 , %%ymm5 , %%ymm4 \n\t" // exchange real and imag part
  59. "vpermilps $0xb1 , %%ymm7 , %%ymm6 \n\t" // exchange real and imag part
  60. "vpermilps $0xb1 , %%ymm9 , %%ymm8 \n\t" // exchange real and imag part
  61. "vpermilps $0xb1 , %%ymm11, %%ymm10 \n\t" // exchange real and imag part
  62. "vfmadd213ps (%3,%0,4), %%ymm0 , %%ymm5 \n\t"
  63. ".p2align 1 \n\t"
  64. "vfmadd213ps 32(%3,%0,4), %%ymm0 , %%ymm7 \n\t"
  65. "vfmadd213ps 64(%3,%0,4), %%ymm0 , %%ymm9 \n\t"
  66. "vfmadd213ps 96(%3,%0,4), %%ymm0 , %%ymm11 \n\t"
  67. "vfmadd231ps %%ymm1 , %%ymm4 , %%ymm5 \n\t"
  68. "vfmadd231ps %%ymm1 , %%ymm6 , %%ymm7 \n\t"
  69. "vfmadd231ps %%ymm1 , %%ymm8 , %%ymm9 \n\t"
  70. "vfmadd231ps %%ymm1 , %%ymm10, %%ymm11 \n\t"
  71. "vpermilps $0xb1 , %%ymm12, %%ymm4 \n\t" // exchange real and imag part
  72. "vpermilps $0xb1 , %%ymm13, %%ymm6 \n\t" // exchange real and imag part
  73. "vpermilps $0xb1 , %%ymm14, %%ymm8 \n\t" // exchange real and imag part
  74. "vpermilps $0xb1 , %%ymm15, %%ymm10 \n\t" // exchange real and imag part
  75. "vfmadd213ps 128(%3,%0,4), %%ymm0 , %%ymm12 \n\t"
  76. "vfmadd213ps 160(%3,%0,4), %%ymm0 , %%ymm13 \n\t"
  77. "vfmadd213ps 192(%3,%0,4), %%ymm0 , %%ymm14 \n\t"
  78. "vfmadd213ps 224(%3,%0,4), %%ymm0 , %%ymm15 \n\t"
  79. "vfmadd231ps %%ymm1 , %%ymm4 , %%ymm12 \n\t"
  80. "vfmadd231ps %%ymm1 , %%ymm6 , %%ymm13 \n\t"
  81. "vfmadd231ps %%ymm1 , %%ymm8 , %%ymm14 \n\t"
  82. "vfmadd231ps %%ymm1 , %%ymm10, %%ymm15 \n\t"
  83. "vmovups %%ymm5 , (%3,%0,4) \n\t"
  84. ".p2align 1 \n\t"
  85. "vmovups %%ymm7 , 32(%3,%0,4) \n\t"
  86. "vmovups %%ymm9 , 64(%3,%0,4) \n\t"
  87. "vmovups %%ymm11, 96(%3,%0,4) \n\t"
  88. "vmovups %%ymm12,128(%3,%0,4) \n\t"
  89. "vmovups %%ymm13,160(%3,%0,4) \n\t"
  90. "vmovups %%ymm14,192(%3,%0,4) \n\t"
  91. "vmovups %%ymm15,224(%3,%0,4) \n\t"
  92. "addq $64, %0 \n\t"
  93. "subq $32, %1 \n\t"
  94. "jnz 1b \n\t"
  95. "vzeroupper \n\t"
  96. :
  97. "+r" (i), // 0
  98. "+r" (n) // 1
  99. :
  100. "r" (x), // 2
  101. "r" (y), // 3
  102. "r" (alpha), // 4
  103. "r" (mvec) // 5
  104. : "cc",
  105. "%xmm0", "%xmm1", "%xmm2", "%xmm3",
  106. "%xmm4", "%xmm5", "%xmm6", "%xmm7",
  107. "%xmm8", "%xmm9", "%xmm10", "%xmm11",
  108. "%xmm12", "%xmm13", "%xmm14", "%xmm15",
  109. "memory"
  110. );
  111. }