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_uncopy_sve.c 4.5 kB

3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. svint64_t index = svindex_s64(0LL, lda);
  54. svbool_t pn = svwhilelt_b64((uint64_t)js, (uint64_t)n);
  55. int n_active = svcntp_b64(svptrue_b64(), pn);
  56. #else
  57. int32_t N = n;
  58. int32_t js = 0;
  59. svint32_t index = svindex_s32(0, lda);
  60. svbool_t pn = svwhilelt_b32((uint32_t)js, (uint32_t)N);
  61. int n_active = svcntp_b32(svptrue_b32(), pn);
  62. #endif
  63. do {
  64. ao = a;
  65. i = 0;
  66. ii = 0;
  67. do {
  68. if (ii == jj) {
  69. for (int j = 0; j < n_active; j++) {
  70. *(b + j * n_active + j) = INV(*(ao + j * lda + j));
  71. for (int k = j+1; k < n_active; k++) {
  72. *(b + j * n_active + k) = *(ao + k * lda + j);
  73. }
  74. }
  75. ao += n_active;
  76. b += n_active * n_active;
  77. i += n_active;
  78. ii += n_active;
  79. } else {
  80. if (ii < jj) {
  81. #ifdef DOUBLE
  82. svfloat64_t aj_vec = svld1_gather_index(pn, ao, index);
  83. #else
  84. svfloat32_t aj_vec = svld1_gather_index(pn, ao, index);
  85. #endif
  86. svst1(pn, b, aj_vec);
  87. }
  88. ao++;
  89. b += n_active;
  90. i++;
  91. ii++;
  92. }
  93. } while (i < m);
  94. a += n_active * lda;
  95. jj += n_active;
  96. js += n_active;
  97. #ifdef DOUBLE
  98. pn = svwhilelt_b64((uint64_t)js, (uint64_t)n);
  99. n_active = svcntp_b64(svptrue_b64(), pn);
  100. } while (svptest_any(svptrue_b64(), pn));
  101. #else
  102. pn = svwhilelt_b32((uint32_t)js, (uint32_t)N);
  103. n_active = svcntp_b32(svptrue_b32(), pn);
  104. } while (svptest_any(svptrue_b32(), pn));
  105. #endif
  106. return 0;
  107. }