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.

symm_ucopy_sve.c 5.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*********************************************************************/
  2. /* Copyright 2009, 2010 The University of Texas at Austin. */
  3. /* All rights reserved. */
  4. /* */
  5. /* Redistribution and use in source and binary forms, with or */
  6. /* without modification, are permitted provided that the following */
  7. /* conditions are met: */
  8. /* */
  9. /* 1. Redistributions of source code must retain the above */
  10. /* copyright notice, this list of conditions and the following */
  11. /* disclaimer. */
  12. /* */
  13. /* 2. Redistributions in binary form must reproduce the above */
  14. /* copyright notice, this list of conditions and the following */
  15. /* disclaimer in the documentation and/or other materials */
  16. /* provided with the distribution. */
  17. /* */
  18. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  19. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  20. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  21. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  22. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  23. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  24. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  25. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  26. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  27. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  28. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  29. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  30. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  31. /* POSSIBILITY OF SUCH DAMAGE. */
  32. /* */
  33. /* The views and conclusions contained in the software and */
  34. /* documentation are those of the authors and should not be */
  35. /* interpreted as representing official policies, either expressed */
  36. /* or implied, of The University of Texas at Austin. */
  37. /*********************************************************************/
  38. #include <stdio.h>
  39. #include "common.h"
  40. #include <arm_sve.h>
  41. int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG posX, BLASLONG posY, FLOAT *b){
  42. BLASLONG i, offset;
  43. #if defined(DOUBLE)
  44. uint64_t sve_size = svcntd();
  45. svint64_t posY_vec = svdup_s64(posY);
  46. svint64_t posX_vec = svdup_s64(posX);
  47. svint64_t lda_vec = svdup_s64(lda);
  48. svint64_t one_vec = svdup_s64(1LL);
  49. int64_t j = 0;
  50. svbool_t pg = svwhilelt_b64(j, n);
  51. int64_t active = svcntp_b64(svptrue_b64(), pg);
  52. svint64_t index_neg = svindex_s64(0LL, -1LL);
  53. svint64_t index = svindex_s64(0LL, 1LL);
  54. do {
  55. offset = posX - posY;
  56. svint64_t vec_off = svdup_s64(offset);
  57. svbool_t cmp = svcmpgt(pg, vec_off, index_neg);
  58. svint64_t temp = svadd_z(pg, posX_vec, index);
  59. svint64_t temp1 = svmla_z(pg, temp, posY_vec, lda_vec);
  60. svint64_t temp2 = svmla_z(pg, posY_vec, temp, lda);
  61. svint64_t gat_ind = svsel(cmp, temp2, temp1);
  62. i = m;
  63. while (i>0) {
  64. svfloat64_t data_vec = svld1_gather_index(pg, a, gat_ind);
  65. gat_ind = svadd_m(cmp, gat_ind, one_vec);
  66. gat_ind = svadd_m(svnot_z(pg, cmp) , gat_ind, lda_vec);
  67. svst1(pg, b, data_vec);
  68. b += active;
  69. offset --;
  70. vec_off = svsub_z(pg, vec_off, one_vec);
  71. cmp = svcmpgt(pg, vec_off, index_neg);
  72. i--;
  73. }
  74. posX += sve_size;
  75. posX_vec = svdup_s64(posX);
  76. j += sve_size;
  77. pg = svwhilelt_b64(j, n);
  78. active = svcntp_b64(svptrue_b64(), pg);
  79. } while (svptest_any(svptrue_b64(), pg));
  80. #else
  81. uint32_t sve_size = svcntw();
  82. svint32_t posY_vec = svdup_s32(posY);
  83. svint32_t posX_vec = svdup_s32(posX);
  84. svint32_t lda_vec = svdup_s32(lda);
  85. svint32_t one_vec = svdup_s32(1);
  86. int32_t N = n;
  87. int32_t j = 0;
  88. svbool_t pg = svwhilelt_b32(j, N);
  89. int32_t active = svcntp_b32(svptrue_b32(), pg);
  90. svint32_t index_neg = svindex_s32(0, -1);
  91. svint32_t index = svindex_s32(0, 1);
  92. do {
  93. offset = posX - posY;
  94. svint32_t vec_off = svdup_s32(offset);
  95. svbool_t cmp = svcmpgt(pg, vec_off, index_neg);
  96. svint32_t temp = svadd_z(pg, posX_vec, index);
  97. svint32_t temp1 = svmla_z(pg, temp, posY_vec, lda_vec);
  98. svint32_t temp2 = svmla_z(pg, posY_vec, temp, lda);
  99. svint32_t gat_ind = svsel(cmp, temp2, temp1);
  100. i = m;
  101. while (i>0) {
  102. svfloat32_t data_vec = svld1_gather_index(pg, a, gat_ind);
  103. gat_ind = svadd_m(cmp, gat_ind, one_vec);
  104. gat_ind = svadd_m(svnot_z(pg, cmp) , gat_ind, lda_vec);
  105. svst1(pg, b, data_vec);
  106. b += active;
  107. offset --;
  108. vec_off = svsub_z(pg, vec_off, one_vec);
  109. cmp = svcmpgt(pg, vec_off, index_neg);
  110. i--;
  111. }
  112. posX += sve_size;
  113. posX_vec = svdup_s32(posX);
  114. j += sve_size;
  115. pg = svwhilelt_b32(j, N);
  116. active = svcntp_b32(svptrue_b32(), pg);
  117. } while (svptest_any(svptrue_b32(), pg));
  118. #endif
  119. return 0;
  120. }