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.

gemm_tcopy_6.c 7.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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. int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, FLOAT *b){
  41. BLASLONG i, j;
  42. FLOAT *a_offset, *a_offset1, *a_offset2, *a_offset3, *a_offset4;
  43. FLOAT *b_offset, *b_offset1, *b_offset2, *b_offset3;
  44. FLOAT ctemp1, ctemp2, ctemp3, ctemp4;
  45. FLOAT ctemp5, ctemp6, ctemp7, ctemp8;
  46. FLOAT ctemp9, ctemp10, ctemp11, ctemp12;
  47. FLOAT ctemp13, ctemp14, ctemp15, ctemp16;
  48. a_offset = a;
  49. b_offset = b;
  50. b_offset2 = b + m * (n & ~3);
  51. b_offset3 = b + m * (n & ~1);
  52. j = (m >> 2);
  53. if (j > 0){
  54. do{
  55. a_offset1 = a_offset;
  56. a_offset2 = a_offset1 + lda;
  57. a_offset3 = a_offset2 + lda;
  58. a_offset4 = a_offset3 + lda;
  59. a_offset += 4 * lda;
  60. b_offset1 = b_offset;
  61. b_offset += 16;
  62. i = (n >> 2);
  63. if (i > 0){
  64. do{
  65. ctemp1 = *(a_offset1 + 0);
  66. ctemp2 = *(a_offset1 + 1);
  67. ctemp3 = *(a_offset1 + 2);
  68. ctemp4 = *(a_offset1 + 3);
  69. ctemp5 = *(a_offset2 + 0);
  70. ctemp6 = *(a_offset2 + 1);
  71. ctemp7 = *(a_offset2 + 2);
  72. ctemp8 = *(a_offset2 + 3);
  73. ctemp9 = *(a_offset3 + 0);
  74. ctemp10 = *(a_offset3 + 1);
  75. ctemp11 = *(a_offset3 + 2);
  76. ctemp12 = *(a_offset3 + 3);
  77. ctemp13 = *(a_offset4 + 0);
  78. ctemp14 = *(a_offset4 + 1);
  79. ctemp15 = *(a_offset4 + 2);
  80. ctemp16 = *(a_offset4 + 3);
  81. a_offset1 += 4;
  82. a_offset2 += 4;
  83. a_offset3 += 4;
  84. a_offset4 += 4;
  85. *(b_offset1 + 0) = ctemp1;
  86. *(b_offset1 + 1) = ctemp2;
  87. *(b_offset1 + 2) = ctemp3;
  88. *(b_offset1 + 3) = ctemp4;
  89. *(b_offset1 + 4) = ctemp5;
  90. *(b_offset1 + 5) = ctemp6;
  91. *(b_offset1 + 6) = ctemp7;
  92. *(b_offset1 + 7) = ctemp8;
  93. *(b_offset1 + 8) = ctemp9;
  94. *(b_offset1 + 9) = ctemp10;
  95. *(b_offset1 + 10) = ctemp11;
  96. *(b_offset1 + 11) = ctemp12;
  97. *(b_offset1 + 12) = ctemp13;
  98. *(b_offset1 + 13) = ctemp14;
  99. *(b_offset1 + 14) = ctemp15;
  100. *(b_offset1 + 15) = ctemp16;
  101. b_offset1 += m * 4;
  102. i --;
  103. }while(i > 0);
  104. }
  105. if (n & 2) {
  106. ctemp1 = *(a_offset1 + 0);
  107. ctemp2 = *(a_offset1 + 1);
  108. ctemp3 = *(a_offset2 + 0);
  109. ctemp4 = *(a_offset2 + 1);
  110. ctemp5 = *(a_offset3 + 0);
  111. ctemp6 = *(a_offset3 + 1);
  112. ctemp7 = *(a_offset4 + 0);
  113. ctemp8 = *(a_offset4 + 1);
  114. a_offset1 += 2;
  115. a_offset2 += 2;
  116. a_offset3 += 2;
  117. a_offset4 += 2;
  118. *(b_offset2 + 0) = ctemp1;
  119. *(b_offset2 + 1) = ctemp2;
  120. *(b_offset2 + 2) = ctemp3;
  121. *(b_offset2 + 3) = ctemp4;
  122. *(b_offset2 + 4) = ctemp5;
  123. *(b_offset2 + 5) = ctemp6;
  124. *(b_offset2 + 6) = ctemp7;
  125. *(b_offset2 + 7) = ctemp8;
  126. b_offset2 += 8;
  127. }
  128. if (n & 1) {
  129. ctemp1 = *(a_offset1 + 0);
  130. ctemp2 = *(a_offset2 + 0);
  131. ctemp3 = *(a_offset3 + 0);
  132. ctemp4 = *(a_offset4 + 0);
  133. *(b_offset3 + 0) = ctemp1;
  134. *(b_offset3 + 1) = ctemp2;
  135. *(b_offset3 + 2) = ctemp3;
  136. *(b_offset3 + 3) = ctemp4;
  137. b_offset3 += 4;
  138. }
  139. j--;
  140. }while(j > 0);
  141. }
  142. if (m & 2){
  143. a_offset1 = a_offset;
  144. a_offset2 = a_offset1 + lda;
  145. a_offset += 2 * lda;
  146. b_offset1 = b_offset;
  147. b_offset += 8;
  148. i = (n >> 2);
  149. if (i > 0){
  150. do{
  151. ctemp1 = *(a_offset1 + 0);
  152. ctemp2 = *(a_offset1 + 1);
  153. ctemp3 = *(a_offset1 + 2);
  154. ctemp4 = *(a_offset1 + 3);
  155. ctemp5 = *(a_offset2 + 0);
  156. ctemp6 = *(a_offset2 + 1);
  157. ctemp7 = *(a_offset2 + 2);
  158. ctemp8 = *(a_offset2 + 3);
  159. a_offset1 += 4;
  160. a_offset2 += 4;
  161. *(b_offset1 + 0) = ctemp1;
  162. *(b_offset1 + 1) = ctemp2;
  163. *(b_offset1 + 2) = ctemp3;
  164. *(b_offset1 + 3) = ctemp4;
  165. *(b_offset1 + 4) = ctemp5;
  166. *(b_offset1 + 5) = ctemp6;
  167. *(b_offset1 + 6) = ctemp7;
  168. *(b_offset1 + 7) = ctemp8;
  169. b_offset1 += m * 4;
  170. i --;
  171. }while(i > 0);
  172. }
  173. if (n & 2) {
  174. ctemp1 = *(a_offset1 + 0);
  175. ctemp2 = *(a_offset1 + 1);
  176. ctemp3 = *(a_offset2 + 0);
  177. ctemp4 = *(a_offset2 + 1);
  178. a_offset1 += 2;
  179. a_offset2 += 2;
  180. *(b_offset2 + 0) = ctemp1;
  181. *(b_offset2 + 1) = ctemp2;
  182. *(b_offset2 + 2) = ctemp3;
  183. *(b_offset2 + 3) = ctemp4;
  184. b_offset2 += 4;
  185. }
  186. if (n & 1) {
  187. ctemp1 = *(a_offset1 + 0);
  188. ctemp2 = *(a_offset2 + 0);
  189. *(b_offset3 + 0) = ctemp1;
  190. *(b_offset3 + 1) = ctemp2;
  191. b_offset3 += 2;
  192. }
  193. }
  194. if (m & 1){
  195. a_offset1 = a_offset;
  196. b_offset1 = b_offset;
  197. i = (n >> 2);
  198. if (i > 0){
  199. do{
  200. ctemp1 = *(a_offset1 + 0);
  201. ctemp2 = *(a_offset1 + 1);
  202. ctemp3 = *(a_offset1 + 2);
  203. ctemp4 = *(a_offset1 + 3);
  204. a_offset1 += 4;
  205. *(b_offset1 + 0) = ctemp1;
  206. *(b_offset1 + 1) = ctemp2;
  207. *(b_offset1 + 2) = ctemp3;
  208. *(b_offset1 + 3) = ctemp4;
  209. b_offset1 += 4 * m;
  210. i --;
  211. }while(i > 0);
  212. }
  213. if (n & 2) {
  214. ctemp1 = *(a_offset1 + 0);
  215. ctemp2 = *(a_offset1 + 1);
  216. a_offset1 += 2;
  217. *(b_offset2 + 0) = ctemp1;
  218. *(b_offset2 + 1) = ctemp2;
  219. }
  220. if (n & 1) {
  221. ctemp1 = *(a_offset1 + 0);
  222. *(b_offset3 + 0) = ctemp1;
  223. }
  224. }
  225. return 0;
  226. }