/*************************************************************************** Copyright (c) 2013-2019, The OpenBLAS Project All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the OpenBLAS project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ #include "common.h" #include #include #if defined(DOUBLE) #define ABS fabs #else #define ABS fabsf #endif /** * Find minimum index * Warning: requirements n>0 and n % 64 == 0 * @param n * @param x pointer to the vector * @param minf (out) minimum absolute value .( only for output ) * @return index */ static BLASLONG siamin_kernel_64(BLASLONG n, FLOAT *x, FLOAT *minf) { BLASLONG index; BLASLONG i=0; register __vector unsigned int static_index0 = {0,1,2,3}; register __vector unsigned int temp0 = {4,4,4, 4}; //temporary vector register register __vector unsigned int temp1= temp0<<1; //{8,8,8,8} register __vector unsigned int static_index1=static_index0 +temp0;//{4,5,6,7}; register __vector unsigned int static_index2=static_index0 +temp1;//{8,9,10,11}; register __vector unsigned int static_index3=static_index1 +temp1; //{12,13,14,15}; temp0=vec_xor(temp0,temp0); temp1=temp1 <<1 ; //{16,16,16,16} register __vector unsigned int quadruple_indices=static_index0;//{0,1,2,3}; register __vector float * v_ptrx=(__vector float *)x; register __vector float quadruple_values=vec_abs(v_ptrx[0]); for(; ii2?i2:i1; }else if(a2i4?i4:i3; }else if(a4index?index:i1; *minf=a1; }else if(a3 0) { min = siamin_kernel_64(n1, x, &minf); i = n1; } while (i < n) { if (ABS(x[i]) < minf) { min = i; minf = ABS(x[i]); } i++; } return (min + 1); } else { BLASLONG n1 = n & -4; while (j < n1) { if (ABS(x[i]) < minf) { min = j; minf = ABS(x[i]); } if (ABS(x[i + inc_x]) < minf) { min = j + 1; minf = ABS(x[i + inc_x]); } if (ABS(x[i + 2 * inc_x]) < minf) { min = j + 2; minf = ABS(x[i + 2 * inc_x]); } if (ABS(x[i + 3 * inc_x]) < minf) { min = j + 3; minf = ABS(x[i + 3 * inc_x]); } i += inc_x * 4; j += 4; } while (j < n) { if (ABS(x[i]) < minf) { min = j; minf = ABS(x[i]); } i += inc_x; j++; } return (min + 1); } }