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.

trsm_utcopy_sve.c 4.4 kB

3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*********************************************************************/
  2. /* Copyright 2009, 2010 The University of Texas at Austin. */
  3. /* Copyright 2023 The OpenBLAS Project */
  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. #include "arm_sve.h"
  42. #ifndef UNIT
  43. #define INV(a) (ONE / (a))
  44. #else
  45. #define INV(a) (ONE)
  46. #endif
  47. int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG offset, FLOAT *b){
  48. BLASLONG i, ii, jj;
  49. FLOAT *ao;
  50. jj = offset;
  51. #ifdef DOUBLE
  52. int64_t js = 0;
  53. svbool_t pn = svwhilelt_b64((uint64_t)js, (uint64_t)n);
  54. int n_active = svcntp_b64(svptrue_b64(), pn);
  55. #else
  56. int32_t N = n;
  57. int32_t js = 0;
  58. svbool_t pn = svwhilelt_b32((uint32_t)js, (uint32_t)N);
  59. int n_active = svcntp_b32(svptrue_b32(), pn);
  60. #endif
  61. do {
  62. ao = a;
  63. i = 0;
  64. ii = 0;
  65. do {
  66. if (ii == jj) {
  67. for (int j = 0; j < n_active; j++) {
  68. for (int k = 0; k < j; k++) {
  69. *(b + j * n_active + k) = *(ao + j * lda + k);
  70. }
  71. *(b + j * n_active + j) = INV(*(ao + j * lda + j));
  72. }
  73. ao += lda * n_active;
  74. b += n_active * n_active;
  75. i += n_active;
  76. ii += n_active;
  77. } else {
  78. if (ii > jj) {
  79. #ifdef DOUBLE
  80. svfloat64_t aj_vec = svld1(pn, ao);
  81. #else
  82. svfloat32_t aj_vec = svld1(pn, ao);
  83. #endif
  84. svst1(pn, b, aj_vec);
  85. }
  86. ao += lda;
  87. b += n_active;
  88. i ++;
  89. ii ++;
  90. }
  91. } while (i < m);
  92. a += n_active;
  93. jj += n_active;
  94. js += n_active;
  95. #ifdef DOUBLE
  96. pn = svwhilelt_b64((uint64_t)js, (uint64_t)n);
  97. n_active = svcntp_b64(svptrue_b64(), pn);
  98. } while (svptest_any(svptrue_b64(), pn));
  99. #else
  100. pn = svwhilelt_b32((uint32_t)js, (uint32_t)N);
  101. n_active = svcntp_b32(svptrue_b32(), pn);
  102. } while (svptest_any(svptrue_b32(), pn));
  103. #endif
  104. return 0;
  105. }