You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

scal.c 3.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*********************************************************************/
  2. /* Copyright 2025 The OpenBLAS Project. */
  3. /* Copyright 2009, 2010 The University of Texas at Austin. */
  4. /* All rights reserved. */
  5. /* */
  6. /* Redistribution and use in source and binary forms, with or */
  7. /* without modification, are permitted provided that the following */
  8. /* conditions are met: */
  9. /* */
  10. /* 1. Redistributions of source code must retain the above */
  11. /* copyright notice, this list of conditions and the following */
  12. /* disclaimer. */
  13. /* */
  14. /* 2. Redistributions in binary form must reproduce the above */
  15. /* copyright notice, this list of conditions and the following */
  16. /* disclaimer in the documentation and/or other materials */
  17. /* provided with the distribution. */
  18. /* */
  19. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  20. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  21. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  22. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  23. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  24. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  25. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  26. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  27. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  28. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  29. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  30. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  31. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  32. /* POSSIBILITY OF SUCH DAMAGE. */
  33. /* */
  34. /* The views and conclusions contained in the software and */
  35. /* documentation are those of the authors and should not be */
  36. /* interpreted as representing official policies, either expressed */
  37. /* or implied, of The University of Texas at Austin. */
  38. /*********************************************************************/
  39. #include <stdio.h>
  40. #include "common.h"
  41. #ifdef FUNCTION_PROFILE
  42. #include "functable.h"
  43. #endif
  44. #ifndef CBLAS
  45. void NAME(blasint *N, FLOAT *ALPHA, FLOAT *x, blasint *INCX){
  46. blasint n = *N;
  47. blasint incx = *INCX;
  48. FLOAT alpha = *ALPHA;
  49. #else
  50. void CNAME(blasint n, FLOAT alpha, FLOAT *x, blasint incx){
  51. #endif
  52. #ifdef SMP
  53. int mode, nthreads;
  54. #endif
  55. #ifndef CBLAS
  56. PRINT_DEBUG_NAME;
  57. #else
  58. PRINT_DEBUG_CNAME;
  59. #endif
  60. if (incx <= 0 || n <= 0) return;
  61. #ifdef BGEMM
  62. float alpha_float;
  63. SBF16TOS_K(1, &alpha, 1, &alpha_float, 1);
  64. #else
  65. float alpha_float = alpha;
  66. #endif
  67. if (alpha_float == ONE) return;
  68. IDEBUG_START;
  69. FUNCTION_PROFILE_START();
  70. #ifdef SMP
  71. if (n <= 1048576 )
  72. nthreads = 1;
  73. else
  74. nthreads = num_cpu_avail(1);
  75. if (nthreads == 1) {
  76. #endif
  77. SCAL_K(n, 0, 0, alpha, x, incx, NULL, 0, NULL, 1);
  78. #ifdef SMP
  79. } else {
  80. #ifdef DOUBLE
  81. mode = BLAS_DOUBLE | BLAS_REAL;
  82. #else
  83. mode = BLAS_SINGLE | BLAS_REAL;
  84. #endif
  85. blas_level1_thread(mode, n, 0, 0,
  86. #ifndef CBLAS
  87. ALPHA,
  88. #else
  89. &alpha,
  90. #endif
  91. x, incx, NULL, 0, NULL, 1, (int (*)(void))SCAL_K, nthreads);
  92. }
  93. #endif
  94. FUNCTION_PROFILE_END(1, n, n);
  95. IDEBUG_END;
  96. return;
  97. }