|
| 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 | + |
| 28 | +#define HAVE_KERNEL_16x4 1 |
| 29 | +static void sgemv_kernel_16x4( BLASLONG n, float **ap, float *x, float *y) __attribute__ ((noinline)); |
| 30 | + |
| 31 | +static void sgemv_kernel_16x4( BLASLONG n, float **ap, float *x, float *y) |
| 32 | +{ |
| 33 | + |
| 34 | + BLASLONG register i = 0; |
| 35 | + |
| 36 | + __asm__ __volatile__ |
| 37 | + ( |
| 38 | + "vbroadcastss (%2), %%xmm12 \n\t" // x0 |
| 39 | + "vbroadcastss 4(%2), %%xmm13 \n\t" // x1 |
| 40 | + "vbroadcastss 8(%2), %%xmm14 \n\t" // x2 |
| 41 | + "vbroadcastss 12(%2), %%xmm15 \n\t" // x3 |
| 42 | + |
| 43 | + ".align 16 \n\t" |
| 44 | + ".L01LOOP%=: \n\t" |
| 45 | + "vmovups (%3,%0,4), %%xmm4 \n\t" // 4 * y |
| 46 | + "vmovups 16(%3,%0,4), %%xmm5 \n\t" // 4 * y |
| 47 | + "vmovups 32(%3,%0,4), %%xmm6 \n\t" // 4 * y |
| 48 | + "vmovups 48(%3,%0,4), %%xmm7 \n\t" // 4 * y |
| 49 | + |
| 50 | + "prefetcht0 192(%4,%0,4) \n\t" |
| 51 | + "vfmaddps %%xmm4, (%4,%0,4), %%xmm12, %%xmm4 \n\t" |
| 52 | + "vfmaddps %%xmm5, 16(%4,%0,4), %%xmm12, %%xmm5 \n\t" |
| 53 | + "vfmaddps %%xmm6, 32(%4,%0,4), %%xmm12, %%xmm6 \n\t" |
| 54 | + "vfmaddps %%xmm7, 48(%4,%0,4), %%xmm12, %%xmm7 \n\t" |
| 55 | + "prefetcht0 192(%5,%0,4) \n\t" |
| 56 | + "vfmaddps %%xmm4, (%5,%0,4), %%xmm13, %%xmm4 \n\t" |
| 57 | + "vfmaddps %%xmm5, 16(%5,%0,4), %%xmm13, %%xmm5 \n\t" |
| 58 | + "vfmaddps %%xmm6, 32(%5,%0,4), %%xmm13, %%xmm6 \n\t" |
| 59 | + "vfmaddps %%xmm7, 48(%5,%0,4), %%xmm13, %%xmm7 \n\t" |
| 60 | + "prefetcht0 192(%6,%0,4) \n\t" |
| 61 | + "vfmaddps %%xmm4, (%6,%0,4), %%xmm14, %%xmm4 \n\t" |
| 62 | + "vfmaddps %%xmm5, 16(%6,%0,4), %%xmm14, %%xmm5 \n\t" |
| 63 | + "vfmaddps %%xmm6, 32(%6,%0,4), %%xmm14, %%xmm6 \n\t" |
| 64 | + "vfmaddps %%xmm7, 48(%6,%0,4), %%xmm14, %%xmm7 \n\t" |
| 65 | + "prefetcht0 192(%7,%0,4) \n\t" |
| 66 | + "vfmaddps %%xmm4, (%7,%0,4), %%xmm15, %%xmm4 \n\t" |
| 67 | + "vfmaddps %%xmm5, 16(%7,%0,4), %%xmm15, %%xmm5 \n\t" |
| 68 | + "vfmaddps %%xmm6, 32(%7,%0,4), %%xmm15, %%xmm6 \n\t" |
| 69 | + "vfmaddps %%xmm7, 48(%7,%0,4), %%xmm15, %%xmm7 \n\t" |
| 70 | + |
| 71 | + "vmovups %%xmm4, (%3,%0,4) \n\t" // 4 * y |
| 72 | + "vmovups %%xmm5, 16(%3,%0,4) \n\t" // 4 * y |
| 73 | + "vmovups %%xmm6, 32(%3,%0,4) \n\t" // 4 * y |
| 74 | + "vmovups %%xmm7, 48(%3,%0,4) \n\t" // 4 * y |
| 75 | + |
| 76 | + "addq $16, %0 \n\t" |
| 77 | + "subq $16, %1 \n\t" |
| 78 | + "jnz .L01LOOP%= \n\t" |
| 79 | + |
| 80 | + : |
| 81 | + : |
| 82 | + "r" (i), // 0 |
| 83 | + "r" (n), // 1 |
| 84 | + "r" (x), // 2 |
| 85 | + "r" (y), // 3 |
| 86 | + "r" (ap[0]), // 4 |
| 87 | + "r" (ap[1]), // 5 |
| 88 | + "r" (ap[2]), // 6 |
| 89 | + "r" (ap[3]) // 7 |
| 90 | + : "cc", |
| 91 | + "%xmm4", "%xmm5", |
| 92 | + "%xmm6", "%xmm7", |
| 93 | + "%xmm12", "%xmm13", "%xmm14", "%xmm15", |
| 94 | + "memory" |
| 95 | + ); |
| 96 | + |
| 97 | +} |
| 98 | + |
| 99 | + |
0 commit comments