|
| 1 | +/*************************************************************************** |
| 2 | +Copyright (c) 2021, 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_16 1 |
| 29 | + |
| 30 | +static void srot_kernel_16 (long n, float *x, float *y, float c, float s) |
| 31 | +{ |
| 32 | + __asm__ |
| 33 | + ( |
| 34 | + "xscvdpspn 36, %x5 \n\t" // load c to all words |
| 35 | + "xxspltw 36, 36, 0 \n\t" |
| 36 | + |
| 37 | + "xscvdpspn 37, %x6 \n\t" // load s to all words |
| 38 | + "xxspltw 37, 37, 0 \n\t" |
| 39 | + "lxvp 32, 0(%3) \n\t" // load x |
| 40 | + "lxvp 34, 32(%3) \n\t" |
| 41 | + "lxvp 48, 0(%4) \n\t" // load y |
| 42 | + "lxvp 50, 32(%4) \n\t" |
| 43 | + |
| 44 | + "addic. %2, %2, -16 \n\t" |
| 45 | + "ble two%= \n\t" |
| 46 | + |
| 47 | + ".align 5 \n" |
| 48 | + "one%=: \n\t" |
| 49 | + |
| 50 | + "xvmulsp 40, 32, 36 \n\t" // c * x |
| 51 | + "xvmulsp 41, 33, 36 \n\t" |
| 52 | + "xvmulsp 42, 34, 36 \n\t" |
| 53 | + "xvmulsp 43, 35, 36 \n\t" |
| 54 | + |
| 55 | + "xvmulsp 44, 32, 37 \n\t" // s * x |
| 56 | + "xvmulsp 45, 33, 37 \n\t" |
| 57 | + "xvmulsp 46, 34, 37 \n\t" |
| 58 | + "xvmulsp 47, 35, 37 \n\t" |
| 59 | + |
| 60 | + "lxvp 32, 64(%3) \n\t" // load x |
| 61 | + "lxvp 34, 96(%3) \n\t" |
| 62 | + "xvmulsp 52, 48, 36 \n\t" // c * y |
| 63 | + "xvmulsp 53, 49, 36 \n\t" |
| 64 | + "xvmulsp 54, 50, 36 \n\t" |
| 65 | + "xvmulsp 55, 51, 36 \n\t" |
| 66 | + |
| 67 | + "xvmulsp 38, 48, 37 \n\t" // s * y |
| 68 | + "xvmulsp 39, 49, 37 \n\t" |
| 69 | + "xvmulsp 56, 50, 37 \n\t" |
| 70 | + "xvmulsp 57, 51, 37 \n\t" |
| 71 | + |
| 72 | + "lxvp 48, 64(%4) \n\t" // load y |
| 73 | + "lxvp 50, 96(%4) \n\t" |
| 74 | + |
| 75 | + "xvaddsp 40, 40, 38 \n\t" // c * x + s * y |
| 76 | + "xvaddsp 41, 41, 39 \n\t" // c * x + s * y |
| 77 | + "xvaddsp 42, 42, 56 \n\t" // c * x + s * y |
| 78 | + "xvaddsp 43, 43, 57 \n\t" // c * x + s * y |
| 79 | + |
| 80 | + "stxvp 40, 0(%3) \n\t" // store x |
| 81 | + "stxvp 42, 32(%3) \n\t" |
| 82 | + |
| 83 | + "xvsubsp 52, 52, 44 \n\t" // c * y - s * x |
| 84 | + "xvsubsp 53, 53, 45 \n\t" // c * y - s * x |
| 85 | + "xvsubsp 54, 54, 46 \n\t" // c * y - s * x |
| 86 | + "xvsubsp 55, 55, 47 \n\t" // c * y - s * x |
| 87 | + |
| 88 | + "stxvp 52, 0(%4) \n\t" // store y |
| 89 | + "stxvp 54, 32(%4) \n\t" |
| 90 | + |
| 91 | + "addi %3, %3, 64 \n\t" |
| 92 | + "addi %4, %4, 64 \n\t" |
| 93 | + |
| 94 | + "addic. %2, %2, -16 \n\t" |
| 95 | + "bgt one%= \n" |
| 96 | + |
| 97 | + "two%=: \n\t" |
| 98 | + |
| 99 | + "xvmulsp 40, 32, 36 \n\t" // c * x |
| 100 | + "xvmulsp 41, 33, 36 \n\t" |
| 101 | + "xvmulsp 42, 34, 36 \n\t" |
| 102 | + "xvmulsp 43, 35, 36 \n\t" |
| 103 | + |
| 104 | + "xvmulsp 52, 48, 36 \n\t" // c * y |
| 105 | + "xvmulsp 53, 49, 36 \n\t" |
| 106 | + "xvmulsp 54, 50, 36 \n\t" |
| 107 | + "xvmulsp 55, 51, 36 \n\t" |
| 108 | + |
| 109 | + "xvmulsp 44, 32, 37 \n\t" // s * x |
| 110 | + "xvmulsp 45, 33, 37 \n\t" |
| 111 | + "xvmulsp 46, 34, 37 \n\t" |
| 112 | + "xvmulsp 47, 35, 37 \n\t" |
| 113 | + |
| 114 | + "xvmulsp 38, 48, 37 \n\t" // s * y |
| 115 | + "xvmulsp 39, 49, 37 \n\t" |
| 116 | + "xvmulsp 56, 50, 37 \n\t" |
| 117 | + "xvmulsp 57, 51, 37 \n\t" |
| 118 | + |
| 119 | + "xvaddsp 40, 40, 38 \n\t" // c * x + s * y |
| 120 | + "xvaddsp 41, 41, 39 \n\t" // c * x + s * y |
| 121 | + "xvaddsp 42, 42, 56 \n\t" // c * x + s * y |
| 122 | + "xvaddsp 43, 43, 57 \n\t" // c * x + s * y |
| 123 | + |
| 124 | + "stxvp 40, 0(%3) \n\t" // store x |
| 125 | + "stxvp 42, 32(%3) \n\t" |
| 126 | + "xvsubsp 52, 52, 44 \n\t" // c * y - s * x |
| 127 | + "xvsubsp 53, 53, 45 \n\t" // c * y - s * x |
| 128 | + "xvsubsp 54, 54, 46 \n\t" // c * y - s * x |
| 129 | + "xvsubsp 55, 55, 47 \n\t" // c * y - s * x |
| 130 | + |
| 131 | + "stxvp 52, 0(%4) \n\t" // store y |
| 132 | + "stxvp 54, 32(%4) \n\t" |
| 133 | + |
| 134 | + "#n=%2 x=%0=%3 y=%1=%4 c=%5 s=%6\n" |
| 135 | + : |
| 136 | + "+m" (*x), |
| 137 | + "+m" (*y), |
| 138 | + "+r" (n), // 2 |
| 139 | + "+b" (x), // 3 |
| 140 | + "+b" (y) // 4 |
| 141 | + : |
| 142 | + "f" (c), // 5 |
| 143 | + "f" (s) // 6 |
| 144 | + : |
| 145 | + "cr0", |
| 146 | + "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39", |
| 147 | + "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47", |
| 148 | + "vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55", |
| 149 | + "vs56","vs57" |
| 150 | + ); |
| 151 | +} |
0 commit comments