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.

cgemm_kernel_8x4_power8.S 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. /***************************************************************************
  2. Copyright (c) 2013-2016, The OpenBLAS Project
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. 3. Neither the name of the OpenBLAS project nor the names of
  14. its contributors may be used to endorse or promote products
  15. derived from this software without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
  20. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  25. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *****************************************************************************/
  27. /**************************************************************************************
  28. * 2016/04/04 Werner Saar (wernsaar@googlemail.com)
  29. * BLASTEST : OK
  30. * CTEST : OK
  31. * TEST : OK
  32. * LAPACK-TEST : OK
  33. **************************************************************************************/
  34. /*********************************************************************/
  35. /* Copyright 2009, 2010 The University of Texas at Austin. */
  36. /* All rights reserved. */
  37. /* */
  38. /* Redistribution and use in source and binary forms, with or */
  39. /* without modification, are permitted provided that the following */
  40. /* conditions are met: */
  41. /* */
  42. /* 1. Redistributions of source code must retain the above */
  43. /* copyright notice, this list of conditions and the following */
  44. /* disclaimer. */
  45. /* */
  46. /* 2. Redistributions in binary form must reproduce the above */
  47. /* copyright notice, this list of conditions and the following */
  48. /* disclaimer in the documentation and/or other materials */
  49. /* provided with the distribution. */
  50. /* */
  51. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  52. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  53. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  54. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  55. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  56. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  57. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  58. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  59. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  60. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  61. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  62. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  63. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  64. /* POSSIBILITY OF SUCH DAMAGE. */
  65. /* */
  66. /* The views and conclusions contained in the software and */
  67. /* documentation are those of the authors and should not be */
  68. /* interpreted as representing official policies, either expressed */
  69. /* or implied, of The University of Texas at Austin. */
  70. /*********************************************************************/
  71. #define ASSEMBLER
  72. #include "common.h"
  73. #include "def_vsx.h"
  74. #ifndef __64BIT__
  75. #define LOAD lwz
  76. #else
  77. #define LOAD ld
  78. #endif
  79. #ifdef __64BIT__
  80. #define STACKSIZE 32000
  81. #define ALPHA_R_SP 296(SP)
  82. #define ALPHA_I_SP 304(SP)
  83. #define FZERO 312(SP)
  84. #else
  85. #define STACKSIZE 256
  86. #define ALPHA_R_SP 224(SP)
  87. #define ALPHA_I_SP 232(SP)
  88. #define FZERO 240(SP)
  89. #endif
  90. #define M r3
  91. #define N r4
  92. #define K r5
  93. #ifdef linux
  94. #ifndef __64BIT__
  95. #define A r6
  96. #define B r7
  97. #define C r8
  98. #define LDC r9
  99. #define OFFSET r10
  100. #else
  101. #define A r8
  102. #define B r9
  103. #define C r10
  104. #define LDC r6
  105. #define OFFSET r7
  106. #endif
  107. #endif
  108. #if defined(_AIX) || defined(__APPLE__)
  109. #if !defined(__64BIT__) && defined(DOUBLE)
  110. #define A r10
  111. #define B r6
  112. #define C r7
  113. #define LDC r8
  114. #define OFFSET r9
  115. #else
  116. #define A r8
  117. #define B r9
  118. #define C r10
  119. #define LDC r6
  120. #define OFFSET r7
  121. #endif
  122. #endif
  123. #define o0 0
  124. #define alpha_dr vs28
  125. #define alpha_di vs29
  126. #define alpha_sr vs30
  127. #define alpha_si vs31
  128. #define FRAMEPOINTER r12
  129. #define BBUFFER r14
  130. #define L r15
  131. #define o12 r16
  132. #define o4 r17
  133. #define T2 r19
  134. #define BBO r20
  135. #define o8 r21
  136. #define I r22
  137. #define J r23
  138. #define AO r24
  139. #define BO r25
  140. #define CO r26
  141. #define o16 r27
  142. #define o32 r28
  143. #define o48 r29
  144. #define PRE r30
  145. #define T1 r31
  146. #ifndef NEEDPARAM
  147. PROLOGUE
  148. PROFCODE
  149. mr FRAMEPOINTER, SP
  150. addi SP, SP, -STACKSIZE
  151. addi SP, SP, -STACKSIZE
  152. addi SP, SP, -STACKSIZE
  153. addi SP, SP, -STACKSIZE
  154. li r0, 0
  155. stfd f14, 0(SP)
  156. stfd f15, 8(SP)
  157. stfd f16, 16(SP)
  158. stfd f17, 24(SP)
  159. stfd f18, 32(SP)
  160. stfd f19, 40(SP)
  161. stfd f20, 48(SP)
  162. stfd f21, 56(SP)
  163. stfd f22, 64(SP)
  164. stfd f23, 72(SP)
  165. stfd f24, 80(SP)
  166. stfd f25, 88(SP)
  167. stfd f26, 96(SP)
  168. stfd f27, 104(SP)
  169. stfd f28, 112(SP)
  170. stfd f29, 120(SP)
  171. stfd f30, 128(SP)
  172. stfd f31, 136(SP)
  173. #ifdef __64BIT__
  174. std r31, 144(SP)
  175. std r30, 152(SP)
  176. std r29, 160(SP)
  177. std r28, 168(SP)
  178. std r27, 176(SP)
  179. std r26, 184(SP)
  180. std r25, 192(SP)
  181. std r24, 200(SP)
  182. std r23, 208(SP)
  183. std r22, 216(SP)
  184. std r21, 224(SP)
  185. std r20, 232(SP)
  186. std r19, 240(SP)
  187. std r18, 248(SP)
  188. std r17, 256(SP)
  189. std r16, 264(SP)
  190. std r15, 272(SP)
  191. std r14, 280(SP)
  192. #else
  193. stw r31, 144(SP)
  194. stw r30, 148(SP)
  195. stw r29, 152(SP)
  196. stw r28, 156(SP)
  197. stw r27, 160(SP)
  198. stw r26, 164(SP)
  199. stw r25, 168(SP)
  200. stw r24, 172(SP)
  201. stw r23, 176(SP)
  202. stw r22, 180(SP)
  203. stw r21, 184(SP)
  204. stw r20, 188(SP)
  205. stw r19, 192(SP)
  206. stw r18, 196(SP)
  207. stw r17, 200(SP)
  208. stw r16, 204(SP)
  209. stw r15, 208(SP)
  210. stw r14, 212(SP)
  211. #endif
  212. stfs f1, ALPHA_R_SP
  213. stfs f2, ALPHA_I_SP
  214. // stw r0, FZERO
  215. #ifdef linux
  216. #ifdef __64BIT__
  217. ld LDC, FRAMESLOT(0) + 0(FRAMEPOINTER)
  218. #endif
  219. #endif
  220. #if defined(_AIX) || defined(__APPLE__)
  221. #ifdef __64BIT__
  222. ld LDC, FRAMESLOT(0) + 0(FRAMEPOINTER)
  223. #else
  224. #ifdef DOUBLE
  225. lwz B, FRAMESLOT(0) + 0(FRAMEPOINTER)
  226. lwz C, FRAMESLOT(1) + 0(FRAMEPOINTER)
  227. lwz LDC, FRAMESLOT(2) + 0(FRAMEPOINTER)
  228. #else
  229. lwz LDC, FRAMESLOT(0) + 0(FRAMEPOINTER)
  230. #endif
  231. #endif
  232. #endif
  233. #ifdef TRMMKERNEL
  234. #if defined(linux) && defined(__64BIT__)
  235. ld OFFSET, FRAMESLOT(1) + 0(FRAMEPOINTER)
  236. #endif
  237. #if defined(_AIX) || defined(__APPLE__)
  238. #ifdef __64BIT__
  239. ld OFFSET, FRAMESLOT(1) + 0(FRAMEPOINTER)
  240. #else
  241. #ifdef DOUBLE
  242. lwz OFFSET, FRAMESLOT(3) + 0(FRAMEPOINTER)
  243. #else
  244. lwz OFFSET, FRAMESLOT(1) + 0(FRAMEPOINTER)
  245. #endif
  246. #endif
  247. #endif
  248. #if defined(TRMMKERNEL) && !defined(LEFT)
  249. neg KK, OFFSET
  250. #endif
  251. #endif
  252. #include "cgemm_macros_8x4_power8.S"
  253. cmpwi cr0, M, 0
  254. ble L999_H1
  255. cmpwi cr0, N, 0
  256. ble L999_H1
  257. cmpwi cr0, K, 0
  258. ble L999_H1
  259. slwi LDC, LDC, ZBASE_SHIFT
  260. li PRE, 384
  261. li o4 , 4
  262. li o8 , 8
  263. li o12 , 12
  264. li o16 , 16
  265. li o32 , 32
  266. li o48 , 48
  267. addi BBUFFER, SP, 512+4096
  268. li T1, -4096
  269. and BBUFFER, BBUFFER, T1
  270. #ifdef __64BIT__
  271. addi T1 , SP, 296
  272. #else
  273. addi T1 , SP, 224
  274. #endif
  275. stxsspx vs1, 0, T1
  276. lxsspx alpha_dr, 0, T1
  277. stxsspx vs2, o8 , T1
  278. lxsspx alpha_di, o8, T1
  279. addi T1, SP, 360
  280. li T2, 0
  281. stw T2, 0(T1)
  282. stw T2, 4(T1)
  283. stw T2, 8(T1)
  284. stxsspx alpha_dr, o12, T1
  285. lxvw4x alpha_sr, o0 , T1
  286. addi T1, T1, 16
  287. stw T2, 0(T1)
  288. stw T2, 4(T1)
  289. stw T2, 8(T1)
  290. stxsspx alpha_di, o12, T1
  291. lxvw4x alpha_si, o0 , T1
  292. .align 5
  293. #include "cgemm_logic_8x4_power8.S"
  294. L999:
  295. addi r3, 0, 0
  296. lfd f14, 0(SP)
  297. lfd f15, 8(SP)
  298. lfd f16, 16(SP)
  299. lfd f17, 24(SP)
  300. lfd f18, 32(SP)
  301. lfd f19, 40(SP)
  302. lfd f20, 48(SP)
  303. lfd f21, 56(SP)
  304. lfd f22, 64(SP)
  305. lfd f23, 72(SP)
  306. lfd f24, 80(SP)
  307. lfd f25, 88(SP)
  308. lfd f26, 96(SP)
  309. lfd f27, 104(SP)
  310. lfd f28, 112(SP)
  311. lfd f29, 120(SP)
  312. lfd f30, 128(SP)
  313. lfd f31, 136(SP)
  314. #ifdef __64BIT__
  315. ld r31, 144(SP)
  316. ld r30, 152(SP)
  317. ld r29, 160(SP)
  318. ld r28, 168(SP)
  319. ld r27, 176(SP)
  320. ld r26, 184(SP)
  321. ld r25, 192(SP)
  322. ld r24, 200(SP)
  323. ld r23, 208(SP)
  324. ld r22, 216(SP)
  325. ld r21, 224(SP)
  326. ld r20, 232(SP)
  327. ld r19, 240(SP)
  328. ld r18, 248(SP)
  329. ld r17, 256(SP)
  330. ld r16, 264(SP)
  331. ld r15, 272(SP)
  332. ld r14, 280(SP)
  333. #else
  334. lwz r31, 144(SP)
  335. lwz r30, 148(SP)
  336. lwz r29, 152(SP)
  337. lwz r28, 156(SP)
  338. lwz r27, 160(SP)
  339. lwz r26, 164(SP)
  340. lwz r25, 168(SP)
  341. lwz r24, 172(SP)
  342. lwz r23, 176(SP)
  343. lwz r22, 180(SP)
  344. lwz r21, 184(SP)
  345. lwz r20, 188(SP)
  346. lwz r19, 192(SP)
  347. lwz r18, 196(SP)
  348. lwz r17, 200(SP)
  349. lwz r16, 204(SP)
  350. lwz r15, 208(SP)
  351. lwz r14, 212(SP)
  352. #endif
  353. addi SP, SP, STACKSIZE
  354. addi SP, SP, STACKSIZE
  355. addi SP, SP, STACKSIZE
  356. addi SP, SP, STACKSIZE
  357. blr
  358. EPILOGUE
  359. #endif