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.

common_mips64.h 7.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*****************************************************************************
  2. Copyright (c) 2011, Lab of Parallel Software and Computational Science,ICSAS
  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 ISCAS nor the names of its contributors may
  14. be used to endorse or promote products derived from this software
  15. 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 COPYRIGHT OWNER 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. /* Copyright 2009, 2010 The University of Texas at Austin. */
  29. /* All rights reserved. */
  30. /* */
  31. /* Redistribution and use in source and binary forms, with or */
  32. /* without modification, are permitted provided that the following */
  33. /* conditions are met: */
  34. /* */
  35. /* 1. Redistributions of source code must retain the above */
  36. /* copyright notice, this list of conditions and the following */
  37. /* disclaimer. */
  38. /* */
  39. /* 2. Redistributions in binary form must reproduce the above */
  40. /* copyright notice, this list of conditions and the following */
  41. /* disclaimer in the documentation and/or other materials */
  42. /* provided with the distribution. */
  43. /* */
  44. /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
  45. /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
  46. /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
  47. /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
  48. /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
  49. /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
  50. /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
  51. /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
  52. /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
  53. /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
  54. /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  55. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
  56. /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
  57. /* POSSIBILITY OF SUCH DAMAGE. */
  58. /* */
  59. /* The views and conclusions contained in the software and */
  60. /* documentation are those of the authors and should not be */
  61. /* interpreted as representing official policies, either expressed */
  62. /* or implied, of The University of Texas at Austin. */
  63. /*********************************************************************/
  64. #ifndef COMMON_MIPS64
  65. #define COMMON_MIPS64
  66. #define MB
  67. #define WMB
  68. #define INLINE inline
  69. #ifndef ASSEMBLER
  70. static void INLINE blas_lock(volatile unsigned long *address){
  71. long int ret, val = 1;
  72. do {
  73. while (*address) {YIELDING;};
  74. __asm__ __volatile__(
  75. "1: ll %0, %3\n"
  76. " ori %2, %0, 1\n"
  77. " sc %2, %1\n"
  78. " beqz %2, 1b\n"
  79. " andi %2, %0, 1\n"
  80. " sync\n"
  81. : "=&r" (val), "=m" (address), "=&r" (ret)
  82. : "m" (address)
  83. : "memory");
  84. } while (ret);
  85. }
  86. static inline unsigned int rpcc(void){
  87. unsigned long ret;
  88. #if defined(LOONGSON3A)
  89. unsigned long long tmp;
  90. __asm__ __volatile__("dmfc0 %0, $25, 1": "=r"(tmp):: "memory");
  91. ret=tmp;
  92. #else
  93. __asm__ __volatile__(".set push \n"
  94. ".set mips32r2\n"
  95. "rdhwr %0, $30 \n"
  96. ".set pop" : "=r"(ret) : : "memory");
  97. #endif
  98. return ret;
  99. }
  100. static inline int blas_quickdivide(blasint x, blasint y){
  101. return x / y;
  102. }
  103. #ifdef DOUBLE
  104. #define GET_IMAGE(res) __asm__ __volatile__("mov.d %0, $f2" : "=f"(res) : : "memory")
  105. #else
  106. #define GET_IMAGE(res) __asm__ __volatile__("mov.s %0, $f2" : "=f"(res) : : "memory")
  107. #endif
  108. #define GET_IMAGE_CANCEL
  109. #endif
  110. #ifdef ASSEMBLER
  111. #define HALT teq $0, $0
  112. #define NOP move $0, $0
  113. #ifdef DOUBLE
  114. #define LD ldc1
  115. #define ST sdc1
  116. #define MADD madd.d
  117. #define NMADD nmadd.d
  118. #define MSUB msub.d
  119. #define NMSUB nmsub.d
  120. #define ADD add.d
  121. #define SUB sub.d
  122. #define MUL mul.d
  123. #define MOV mov.d
  124. #define CMOVF movf.d
  125. #define CMOVT movt.d
  126. #define MTC dmtc1
  127. #define FABS abs.d
  128. #define CMPEQ c.eq.d
  129. #define CMPLE c.le.d
  130. #define CMPLT c.lt.d
  131. #else
  132. #define LD lwc1
  133. #define ST swc1
  134. #define MADD madd.s
  135. #define NMADD nmadd.s
  136. #define MSUB msub.s
  137. #define NMSUB nmsub.s
  138. #define ADD add.s
  139. #define SUB sub.s
  140. #define MUL mul.s
  141. #define MOV mov.s
  142. #define CMOVF movf.s
  143. #define CMOVT movt.s
  144. #define MTC mtc1
  145. #define FABS abs.s
  146. #define CMPEQ c.eq.s
  147. #define CMPLE c.le.s
  148. #define CMPLT c.lt.s
  149. #define PLU plu.ps
  150. #define PLL pll.ps
  151. #define PUU puu.ps
  152. #define PUL pul.ps
  153. #define MADPS madd.ps
  154. #define CVTU cvt.s.pu
  155. #define CVTL cvt.s.pl
  156. #endif
  157. #if defined(__64BIT__) && defined(USE64BITINT)
  158. #define LDINT ld
  159. #define LDARG ld
  160. #define SDARG sd
  161. #elif defined(__64BIT__) && !defined(USE64BITINT)
  162. #define LDINT lw
  163. #define LDARG ld
  164. #define SDARG sd
  165. #else
  166. #define LDINT lw
  167. #define LDARG lw
  168. #define SDARG sw
  169. #endif
  170. #ifndef F_INTERFACE
  171. #define REALNAME ASMNAME
  172. #else
  173. #define REALNAME ASMFNAME
  174. #endif
  175. #if defined(ASSEMBLER) && !defined(NEEDPARAM)
  176. #define PROLOGUE \
  177. .text ;\
  178. .set mips64 ;\
  179. .align 5 ;\
  180. .globl REALNAME ;\
  181. .ent REALNAME ;\
  182. .type REALNAME, @function ;\
  183. REALNAME: ;\
  184. .set noreorder ;\
  185. .set nomacro
  186. #define EPILOGUE \
  187. .set macro ;\
  188. .set reorder ;\
  189. .end REALNAME
  190. #define PROFCODE
  191. #endif
  192. #endif
  193. #define SEEK_ADDRESS
  194. #define BUFFER_SIZE ( 32 << 20)
  195. #if defined(LOONGSON3A)
  196. #define PAGESIZE (16UL << 10)
  197. #define FIXED_PAGESIZE (16UL << 10)
  198. #endif
  199. #ifndef PAGESIZE
  200. #define PAGESIZE (64UL << 10)
  201. #endif
  202. #define HUGE_PAGESIZE ( 2 << 20)
  203. #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
  204. #ifndef MAP_ANONYMOUS
  205. #define MAP_ANONYMOUS MAP_ANON
  206. #endif
  207. #if defined(LOONGSON3A)
  208. #define PREFETCHD_(x) ld $0, x
  209. #define PREFETCHD(x) PREFETCHD_(x)
  210. #else
  211. #define PREFETCHD(x)
  212. #endif
  213. #endif

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.