|
| 1 | +/*************************************************************************** |
| 2 | +Copyright (c) 2020, 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_8 1 |
| 29 | +static void caxpy_kernel_8 (long n, float *x, float *y, |
| 30 | + float alpha_r, float alpha_i) |
| 31 | +{ |
| 32 | +#if !defined(CONJ) |
| 33 | + static const float mvec[4] = { -1.0, 1.0, -1.0, 1.0 }; |
| 34 | +#else |
| 35 | + static const float mvec[4] = { 1.0, -1.0, 1.0, -1.0 }; |
| 36 | +#endif |
| 37 | + const float *mvecp = mvec; |
| 38 | + /* We have to load reverse mask for big endian. */ |
| 39 | + /* __vector unsigned char mask={ 4,5,6,7,0,1,2,3,12,13,14,15,8,9,10,11}; */ |
| 40 | + |
| 41 | + __vector unsigned char mask = { 11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4}; |
| 42 | + long ytmp; |
| 43 | + |
| 44 | + __asm__ |
| 45 | + ( |
| 46 | + "xscvdpspn 32, %7 \n\t" |
| 47 | + "xscvdpspn 33, %8 \n\t" |
| 48 | + "xxspltw 32, 32, 0 \n\t" |
| 49 | + "xxspltw 33, 33, 0 \n\t" |
| 50 | + "lxvd2x 36, 0, %9 \n\t" // mvec |
| 51 | + |
| 52 | +#if !defined(CONJ) |
| 53 | + "xvmulsp 33, 33, 36 \n\t" // alpha_i * mvec |
| 54 | +#else |
| 55 | + "xvmulsp 32, 32, 36 \n\t" // alpha_r * mvec |
| 56 | +#endif |
| 57 | + "mr %4, %3 \n\t" |
| 58 | + "dcbt 0, %2 \n\t" |
| 59 | + "dcbt 0, %3 \n\t" |
| 60 | + |
| 61 | + "lxvp 40, 0(%2) \n\t" // x0 |
| 62 | + "lxvp 42, 32(%2) \n\t" // x2 |
| 63 | + "lxvp 48, 0(%3) \n\t" // y0 |
| 64 | + "lxvp 50, 32(%3) \n\t" // y2 |
| 65 | + |
| 66 | + "xxperm 52, 40, %x10 \n\t" // exchange real and imag part |
| 67 | + "xxperm 53, 41, %x10 \n\t" // exchange real and imag part |
| 68 | + "xxperm 54, 42, %x10 \n\t" // exchange real and imag part |
| 69 | + "xxperm 55, 43, %x10 \n\t" // exchange real and imag part |
| 70 | + |
| 71 | + "lxvp 44, 64(%2) \n\t" // x4 |
| 72 | + "lxvp 46, 96(%2) \n\t" // x6 |
| 73 | + "lxvp 34, 64(%3) \n\t" // y4 |
| 74 | + "lxvp 38, 96(%3) \n\t" // y6 |
| 75 | + |
| 76 | + "xxperm 56, 44, %x10 \n\t" // exchange real and imag part |
| 77 | + "xxperm 57, 45, %x10 \n\t" // exchange real and imag part |
| 78 | + "xxperm 58, 46, %x10 \n\t" // exchange real and imag part |
| 79 | + "xxperm 59, 47, %x10 \n\t" // exchange real and imag part |
| 80 | + |
| 81 | + "addi %2, %2, 128 \n\t" |
| 82 | + "addi %3, %3, 128 \n\t" |
| 83 | + |
| 84 | + "addic. %1, %1, -16 \n\t" |
| 85 | + "ble two%= \n\t" |
| 86 | + |
| 87 | + ".align 5 \n" |
| 88 | + "one%=: \n\t" |
| 89 | + |
| 90 | + "xvmaddasp 48, 40, 32 \n\t" // alpha_r * x0_r , alpha_r * x0_i |
| 91 | + "xvmaddasp 49, 41, 32 \n\t" |
| 92 | + "lxvp 40, 0(%2) \n\t" // x0 |
| 93 | + "xvmaddasp 50, 42, 32 \n\t" |
| 94 | + "xvmaddasp 51, 43, 32 \n\t" |
| 95 | + "lxvp 42, 32(%2) \n\t" // x2 |
| 96 | + |
| 97 | + "xvmaddasp 34, 44, 32 \n\t" |
| 98 | + "xvmaddasp 35, 45, 32 \n\t" |
| 99 | + "lxvp 44, 64(%2) \n\t" // x4 |
| 100 | + "xvmaddasp 38, 46, 32 \n\t" |
| 101 | + "xvmaddasp 39, 47, 32 \n\t" |
| 102 | + "lxvp 46, 96(%2) \n\t" // x6 |
| 103 | + |
| 104 | + "xvmaddasp 48, 52, 33 \n\t" // alpha_i * x0_i , alpha_i * x0_r |
| 105 | + "addi %2, %2, 128 \n\t" |
| 106 | + "xvmaddasp 49, 53, 33 \n\t" |
| 107 | + "xvmaddasp 50, 54, 33 \n\t" |
| 108 | + "xvmaddasp 51, 55, 33 \n\t" |
| 109 | + |
| 110 | + "xvmaddasp 34, 56, 33 \n\t" |
| 111 | + "xvmaddasp 35, 57, 33 \n\t" |
| 112 | + "xvmaddasp 38, 58, 33 \n\t" |
| 113 | + "xvmaddasp 39, 59, 33 \n\t" |
| 114 | + |
| 115 | + "stxvp 48, 0(%4) \n\t" |
| 116 | + "stxvp 50, 32(%4) \n\t" |
| 117 | + "stxvp 34, 64(%4) \n\t" |
| 118 | + "stxvp 38, 96(%4) \n\t" |
| 119 | + |
| 120 | + "addi %4, %4, 128 \n\t" |
| 121 | + "xxperm 52, 40, %x10 \n\t" // exchange real and imag part |
| 122 | + "xxperm 53, 41, %x10 \n\t" // exchange real and imag part |
| 123 | + |
| 124 | + "lxvp 48, 0(%3) \n\t" // y0 |
| 125 | + "xxperm 54, 42, %x10 \n\t" // exchange real and imag part |
| 126 | + "xxperm 55, 43, %x10 \n\t" // exchange real and imag part |
| 127 | + "lxvp 50, 32(%3) \n\t" // y2 |
| 128 | + |
| 129 | + "xxperm 56, 44, %x10 \n\t" // exchange real and imag part |
| 130 | + "xxperm 57, 45, %x10 \n\t" // exchange real and imag part |
| 131 | + "lxvp 34, 64(%3) \n\t" // y4 |
| 132 | + "xxperm 58, 46, %x10 \n\t" // exchange real and imag part |
| 133 | + "xxperm 59, 47, %x10 \n\t" // exchange real and imag part |
| 134 | + "lxvp 38, 96(%3) \n\t" // y6 |
| 135 | + |
| 136 | + "addi %3, %3, 128 \n\t" |
| 137 | + |
| 138 | + "addic. %1, %1, -16 \n\t" |
| 139 | + "bgt one%= \n" |
| 140 | + |
| 141 | + "two%=: \n\t" |
| 142 | + "xvmaddasp 48, 40, 32 \n\t" // alpha_r * x0_r , alpha_r * x0_i |
| 143 | + "xvmaddasp 49, 41, 32 \n\t" |
| 144 | + "xvmaddasp 50, 42, 32 \n\t" |
| 145 | + "xvmaddasp 51, 43, 32 \n\t" |
| 146 | + |
| 147 | + "xvmaddasp 34, 44, 32 \n\t" |
| 148 | + "xvmaddasp 35, 45, 32 \n\t" |
| 149 | + "xvmaddasp 38, 46, 32 \n\t" |
| 150 | + "xvmaddasp 39, 47, 32 \n\t" |
| 151 | + |
| 152 | + "xvmaddasp 48, 52, 33 \n\t" // alpha_i * x0_i , alpha_i * x0_r |
| 153 | + "xvmaddasp 49, 53, 33 \n\t" |
| 154 | + "xvmaddasp 50, 54, 33 \n\t" |
| 155 | + "xvmaddasp 51, 55, 33 \n\t" |
| 156 | + |
| 157 | + "xvmaddasp 34, 56, 33 \n\t" |
| 158 | + "xvmaddasp 35, 57, 33 \n\t" |
| 159 | + "xvmaddasp 38, 58, 33 \n\t" |
| 160 | + "xvmaddasp 39, 59, 33 \n\t" |
| 161 | + |
| 162 | + "stxvp 48, 0(%4) \n\t" |
| 163 | + "stxvp 50, 32(%4) \n\t" |
| 164 | + "stxvp 34, 64(%4) \n\t" |
| 165 | + "stxvp 38, 96(%4) \n\t" |
| 166 | + |
| 167 | + "#n=%1 x=%5=%2 y=%0=%3 alpha=(%7,%8) mvecp=%6=%9 ytmp=%4\n" |
| 168 | + : |
| 169 | + "+m" (*y), |
| 170 | + "+r" (n), // 1 |
| 171 | + "+b" (x), // 2 |
| 172 | + "+b" (y), // 3 |
| 173 | + "=b" (ytmp) // 4 |
| 174 | + : |
| 175 | + "m" (*x), |
| 176 | + "m" (*mvecp), |
| 177 | + "d" (alpha_r), // 7 |
| 178 | + "d" (alpha_i), // 8 |
| 179 | + "4" (mvecp), // 9 |
| 180 | + "wa" (mask) |
| 181 | + : |
| 182 | + "cr0", |
| 183 | + "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39", |
| 184 | + "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47", |
| 185 | + "vs48","vs49","vs50","vs51","vs52","vs53","vs54","vs55", |
| 186 | + "vs56","vs57","vs58","vs59" |
| 187 | + ); |
| 188 | +} |
0 commit comments