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.

dsymv_U_microk_haswell-2.c 5.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_4x4 1
  28. static void dsymv_kernel_4x4(BLASLONG n, FLOAT *a0, FLOAT *a1, FLOAT *a2, FLOAT *a3, FLOAT *x, FLOAT *y, FLOAT *temp1, FLOAT *temp2) __attribute__ ((noinline));
  29. static void dsymv_kernel_4x4(BLASLONG n, FLOAT *a0, FLOAT *a1, FLOAT *a2, FLOAT *a3, FLOAT *x, FLOAT *y, FLOAT *temp1, FLOAT *temp2)
  30. {
  31. BLASLONG register i = 0;
  32. __asm__ __volatile__
  33. (
  34. "vzeroupper \n\t"
  35. "vxorpd %%ymm0 , %%ymm0 , %%ymm0 \n\t" // temp2[0]
  36. "vxorpd %%ymm1 , %%ymm1 , %%ymm1 \n\t" // temp2[1]
  37. "vxorpd %%ymm2 , %%ymm2 , %%ymm2 \n\t" // temp2[2]
  38. "vxorpd %%ymm3 , %%ymm3 , %%ymm3 \n\t" // temp2[3]
  39. "vbroadcastsd (%8), %%ymm4 \n\t" // temp1[0]
  40. "vbroadcastsd 8(%8), %%ymm5 \n\t" // temp1[1]
  41. "vbroadcastsd 16(%8), %%ymm6 \n\t" // temp1[1]
  42. "vbroadcastsd 24(%8), %%ymm7 \n\t" // temp1[1]
  43. "xorq %0,%0 \n\t"
  44. ".p2align 4 \n\t"
  45. "1: \n\t"
  46. "vmovups (%3,%0,8), %%ymm9 \n\t" // 2 * y
  47. "vmovups (%2,%0,8), %%ymm8 \n\t" // 2 * x
  48. "vmovups (%4,%0,8), %%ymm12 \n\t" // 2 * a
  49. "vmovups (%5,%0,8), %%ymm13 \n\t" // 2 * a
  50. "vmovups (%6,%0,8), %%ymm14 \n\t" // 2 * a
  51. "vmovups (%7,%0,8), %%ymm15 \n\t" // 2 * a
  52. "vfmadd231pd %%ymm4, %%ymm12 , %%ymm9 \n\t" // y += temp1 * a
  53. "vfmadd231pd %%ymm8, %%ymm12 , %%ymm0 \n\t" // temp2 += x * a
  54. "vfmadd231pd %%ymm5, %%ymm13 , %%ymm9 \n\t" // y += temp1 * a
  55. "vfmadd231pd %%ymm8, %%ymm13 , %%ymm1 \n\t" // temp2 += x * a
  56. "vfmadd231pd %%ymm6, %%ymm14 , %%ymm9 \n\t" // y += temp1 * a
  57. "vfmadd231pd %%ymm8, %%ymm14 , %%ymm2 \n\t" // temp2 += x * a
  58. "vfmadd231pd %%ymm7, %%ymm15 , %%ymm9 \n\t" // y += temp1 * a
  59. "vfmadd231pd %%ymm8, %%ymm15 , %%ymm3 \n\t" // temp2 += x * a
  60. "addq $4 , %0 \n\t"
  61. "subq $4 , %1 \n\t"
  62. "vmovups %%ymm9 , -32(%3,%0,8) \n\t"
  63. "jnz 1b \n\t"
  64. "vmovsd (%9), %%xmm4 \n\t"
  65. "vmovsd 8(%9), %%xmm5 \n\t"
  66. "vmovsd 16(%9), %%xmm6 \n\t"
  67. "vmovsd 24(%9), %%xmm7 \n\t"
  68. "vextractf128 $0x01, %%ymm0 , %%xmm12 \n\t"
  69. "vextractf128 $0x01, %%ymm1 , %%xmm13 \n\t"
  70. "vextractf128 $0x01, %%ymm2 , %%xmm14 \n\t"
  71. "vextractf128 $0x01, %%ymm3 , %%xmm15 \n\t"
  72. "vaddpd %%xmm0, %%xmm12, %%xmm0 \n\t"
  73. "vaddpd %%xmm1, %%xmm13, %%xmm1 \n\t"
  74. "vaddpd %%xmm2, %%xmm14, %%xmm2 \n\t"
  75. "vaddpd %%xmm3, %%xmm15, %%xmm3 \n\t"
  76. "vhaddpd %%xmm0, %%xmm0, %%xmm0 \n\t"
  77. "vhaddpd %%xmm1, %%xmm1, %%xmm1 \n\t"
  78. "vhaddpd %%xmm2, %%xmm2, %%xmm2 \n\t"
  79. "vhaddpd %%xmm3, %%xmm3, %%xmm3 \n\t"
  80. "vaddsd %%xmm4, %%xmm0, %%xmm0 \n\t"
  81. "vaddsd %%xmm5, %%xmm1, %%xmm1 \n\t"
  82. "vaddsd %%xmm6, %%xmm2, %%xmm2 \n\t"
  83. "vaddsd %%xmm7, %%xmm3, %%xmm3 \n\t"
  84. "vmovsd %%xmm0 , (%9) \n\t" // save temp2
  85. "vmovsd %%xmm1 , 8(%9) \n\t" // save temp2
  86. "vmovsd %%xmm2 ,16(%9) \n\t" // save temp2
  87. "vmovsd %%xmm3 ,24(%9) \n\t" // save temp2
  88. "vzeroupper \n\t"
  89. :
  90. "+r" (i), // 0
  91. "+r" (n) // 1
  92. :
  93. "r" (x), // 2
  94. "r" (y), // 3
  95. "r" (a0), // 4
  96. "r" (a1), // 5
  97. "r" (a2), // 6
  98. "r" (a3), // 8
  99. "r" (temp1), // 8
  100. "r" (temp2) // 9
  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. }