PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/ATLAS/src/blas/reference/level1/ATL_srefaxpy.c

https://github.com/hihihippp/Kaldi
C | 157 lines | 45 code | 8 blank | 104 comment | 8 complexity | df127197fae54954628de7c4d673ebcb MD5 | raw file
Possible License(s): Apache-2.0
  1. /* ---------------------------------------------------------------------
  2. *
  3. * -- Automatically Tuned Linear Algebra Software (ATLAS)
  4. * (C) Copyright 2000 All Rights Reserved
  5. *
  6. * -- ATLAS routine -- Version 3.9.24 -- December 25, 2000
  7. *
  8. * Author : Antoine P. Petitet
  9. * Originally developed at the University of Tennessee,
  10. * Innovative Computing Laboratory, Knoxville TN, 37996-1301, USA.
  11. *
  12. * ---------------------------------------------------------------------
  13. *
  14. * -- Copyright notice and Licensing terms:
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions
  18. * are met:
  19. *
  20. * 1. Redistributions of source code must retain the above copyright
  21. * notice, this list of conditions and the following disclaimer.
  22. * 2. Redistributions in binary form must reproduce the above copyright
  23. * notice, this list of conditions, and the following disclaimer in
  24. * the documentation and/or other materials provided with the distri-
  25. * bution.
  26. * 3. The name of the University, the ATLAS group, or the names of its
  27. * contributors may not be used to endorse or promote products deri-
  28. * ved from this software without specific written permission.
  29. *
  30. * -- Disclaimer:
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  34. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  35. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
  36. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
  37. * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  38. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  39. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEO-
  40. * RY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (IN-
  41. * CLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  42. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  43. *
  44. * ---------------------------------------------------------------------
  45. */
  46. /*
  47. * Include files
  48. */
  49. #include "atlas_refmisc.h"
  50. #include "atlas_reflevel1.h"
  51. void ATL_srefaxpy
  52. (
  53. const int N,
  54. const float ALPHA,
  55. const float * X,
  56. const int INCX,
  57. float * Y,
  58. const int INCY
  59. )
  60. {
  61. /*
  62. * Purpose
  63. * =======
  64. *
  65. * ATL_srefaxpy performs the following operation:
  66. *
  67. * y := y + alpha * x,
  68. *
  69. * where alpha is a scalar and x and y are two n-vectors.
  70. *
  71. * Arguments
  72. * =========
  73. *
  74. * N (input) const int
  75. * On entry, N specifies the length of the vector x. N must be
  76. * at least zero. Unchanged on exit.
  77. *
  78. * ALPHA (input) const float
  79. * On entry, ALPHA specifies the scalar alpha. When ALPHA is
  80. * supplied as zero, then the entries of the incremented array X
  81. * need not be set on input. Unchanged on exit.
  82. *
  83. * X (input) const float *
  84. * On entry, X points to the first entry to be accessed of an
  85. * incremented array of size equal to or greater than
  86. * ( 1 + ( n - 1 ) * abs( INCX ) ) * sizeof( float ),
  87. * that contains the vector x. Unchanged on exit.
  88. *
  89. * INCX (input) const int
  90. * On entry, INCX specifies the increment for the elements of X.
  91. * INCX must not be zero. Unchanged on exit.
  92. *
  93. * Y (input/output) float *
  94. * On entry, Y points to the first entry to be accessed of an
  95. * incremented array of size equal to or greater than
  96. * ( 1 + ( n - 1 ) * abs( INCY ) ) * sizeof( float ),
  97. * that contains the vector y. On exit, the entries of the in-
  98. * cremented array Y are updated with the scaled entries of the
  99. * incremented array X.
  100. *
  101. * INCY (input) const int
  102. * On entry, INCY specifies the increment for the elements of Y.
  103. * INCY must not be zero. Unchanged on exit.
  104. *
  105. * ---------------------------------------------------------------------
  106. */
  107. /*
  108. * .. Local Variables ..
  109. */
  110. register const float alpha = ALPHA;
  111. register float x0, x1, x2, x3, y0, y1, y2, y3;
  112. float * StX;
  113. register int i;
  114. int nu;
  115. const int incX2 = 2 * INCX, incY2 = 2 * INCY,
  116. incX3 = 3 * INCX, incY3 = 3 * INCY,
  117. incX4 = 4 * INCX, incY4 = 4 * INCY;
  118. /* ..
  119. * .. Executable Statements ..
  120. *
  121. */
  122. if( ( N > 0 ) && ( alpha != ATL_sZERO ) )
  123. {
  124. if( ( nu = ( N >> 2 ) << 2 ) != 0 )
  125. {
  126. StX = (float *)X + nu * INCX;
  127. do
  128. {
  129. x0 = (*X); y0 = (*Y); x1 = X[INCX ]; y1 = Y[INCY ];
  130. x2 = X[incX2]; y2 = Y[incY2]; x3 = X[incX3]; y3 = Y[incY3];
  131. *Y = y0 + alpha * x0; Y[INCY ] = y1 + alpha * x1;
  132. Y[incY2] = y2 + alpha * x2; Y[incY3] = y3 + alpha * x3;
  133. X += incX4;
  134. Y += incY4;
  135. } while( X != StX );
  136. }
  137. for( i = N - nu; i != 0; i-- )
  138. {
  139. x0 = (*X);
  140. y0 = (*Y);
  141. *Y = y0 + alpha * x0;
  142. X += INCX;
  143. Y += INCY;
  144. }
  145. }
  146. /*
  147. * End of ATL_srefaxpy
  148. */
  149. }