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_sparc.h 7.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. #ifndef COMMON_POWER
  39. #define COMMON_POWER
  40. #define MB __asm__ __volatile__ ("nop")
  41. #define WMB __asm__ __volatile__ ("nop")
  42. #define RMB __asm__ __volatile__ ("nop")
  43. #ifndef ASSEMBLER
  44. static void __inline blas_lock(volatile unsigned long *address){
  45. long int ret = 1;
  46. do {
  47. while (*address) {YIELDING;};
  48. __asm__ __volatile__(
  49. "ldstub [%1], %0"
  50. : "=&r"(ret)
  51. : "r" (address)
  52. : "memory");
  53. } while (ret);
  54. }
  55. #define BLAS_LOCK_DEFINED
  56. static __inline unsigned long rpcc(void){
  57. unsigned long clocks;
  58. __asm__ __volatile__ ("rd %%tick, %0" : "=r" (clocks));
  59. return clocks;
  60. };
  61. #define RPCC_DEFINED
  62. #ifdef __64BIT__
  63. #define RPCC64BIT
  64. #endif
  65. #ifndef __BIG_ENDIAN__
  66. #define __BIG_ENDIAN__
  67. #endif
  68. #ifdef C_SUN
  69. #ifndef __64BIT
  70. #define RETURN_BY_STACK
  71. #endif
  72. #endif
  73. #ifdef DOUBLE
  74. #define GET_IMAGE(res) __asm__ __volatile__("fmovd %%f2, %0" : "=f"(res) : : "memory")
  75. #else
  76. #define GET_IMAGE(res) __asm__ __volatile__("fmovs %%f1, %0" : "=f"(res) : : "memory")
  77. #endif
  78. #define GET_IMAGE_CANCEL
  79. #ifdef SMP
  80. static __inline int blas_quickdivide(blasint x, blasint y){
  81. return x / y;
  82. }
  83. #endif
  84. #endif
  85. #ifdef ASSEMBLER
  86. #ifndef __64BIT__
  87. #define STACK_START 128
  88. #define SAVESP save %sp, -64, %sp
  89. #else
  90. #define STACK_START 2423
  91. #define SAVESP save %sp, -256, %sp
  92. #endif
  93. #define NOP or %g1, %g1, %g1
  94. #ifdef DOUBLE
  95. #define LDF ldd
  96. #define STF std
  97. #define FADD faddd
  98. #define FMUL fmuld
  99. #define FMOV fmovd
  100. #define FABS fabsd
  101. #define FSUB fsubd
  102. #define FCMP fcmpd
  103. #define FMOVG fmovdg
  104. #define FMOVL fmovdl
  105. #define FSQRT fsqrtd
  106. #define FDIV fdivd
  107. #else
  108. #define LDF ld
  109. #define STF st
  110. #define FADD fadds
  111. #define FMUL fmuls
  112. #define FMOV fmovs
  113. #define FABS fabss
  114. #define FSUB fsubs
  115. #define FCMP fcmps
  116. #define FMOVG fmovsg
  117. #define FMOVL fmovsl
  118. #define FSQRT fsqrts
  119. #define FDIV fdivs
  120. #endif
  121. #define HALT prefetch [%g0], 5
  122. #define FMADDS(rs1, rs2, rs3, rd) \
  123. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 1 << 5) | (rs2))
  124. #define FMADDD(rs1, rs2, rs3, rd) \
  125. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 2 << 5) | (rs2))
  126. #define FMSUBS(rs1, rs2, rs3, rd) \
  127. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 5 << 5) | (rs2))
  128. #define FMSUBD(rs1, rs2, rs3, rd) \
  129. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 6 << 5) | (rs2))
  130. #define FNMSUBS(rs1, rs2, rs3, rd) \
  131. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 9 << 5) | (rs2))
  132. #define FNMSUBD(rs1, rs2, rs3, rd) \
  133. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | (10 << 5) | (rs2))
  134. #define FNMADDS(rs1, rs2, rs3, rd) \
  135. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | (13 << 5) | (rs2))
  136. #define FNMADDD(rs1, rs2, rs3, rd) \
  137. .word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | (14 << 5) | (rs2))
  138. #define FCLRS(rd) \
  139. .word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x61 << 5))
  140. #define FCLRD(rd) \
  141. .word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x60 << 5))
  142. #define FONES(rd) \
  143. .word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x7f << 5))
  144. #define FONED(rd) \
  145. .word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x7e << 5))
  146. #ifndef DOUBLE
  147. #define FCLR(a) FCLRS(a)
  148. #define FONE(a) FONES(a)
  149. #define FMADD(a, b, c, d) FMADDS(a, b, c, d)
  150. #define FMSUB(a, b, c, d) FMSUBS(a, b, c, d)
  151. #define FNMADD(a, b, c, d) FNMADDS(a, b, c, d)
  152. #define FNMSUB(a, b, c, d) FNMSUBS(a, b, c, d)
  153. #else
  154. #define FCLR(a) FCLRD(a)
  155. #define FONE(a) FONED(a)
  156. #define FMADD(a, b, c, d) FMADDD(a, b, c, d)
  157. #define FMSUB(a, b, c, d) FMSUBD(a, b, c, d)
  158. #define FNMADD(a, b, c, d) FNMADDD(a, b, c, d)
  159. #define FNMSUB(a, b, c, d) FNMSUBD(a, b, c, d)
  160. #endif
  161. #ifndef F_INTERFACE
  162. #define REALNAME ASMNAME
  163. #else
  164. #define REALNAME ASMFNAME
  165. #endif
  166. #ifdef sparc
  167. #define PROLOGUE \
  168. .section ".text"; \
  169. .align 32; \
  170. .global REALNAME;\
  171. .type REALNAME, #function; \
  172. .proc 07; \
  173. REALNAME:;
  174. #if defined(__linux__) && defined(__ELF__)
  175. #define GNUSTACK .section .note.GNU-stack,"",@progbits
  176. #else
  177. #define GNUSTACK
  178. #endif
  179. #define EPILOGUE \
  180. .size REALNAME, .-REALNAME; \
  181. GNUSTACK
  182. #endif
  183. #endif
  184. #ifdef sparc
  185. #define SEEK_ADDRESS
  186. #endif
  187. #define BUFFER_SIZE (32 << 20)
  188. #ifndef PAGESIZE
  189. #define PAGESIZE ( 8 << 10)
  190. #endif
  191. #define HUGE_PAGESIZE ( 4 << 20)
  192. #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
  193. #ifndef MAP_ANONYMOUS
  194. #define MAP_ANONYMOUS MAP_ANON
  195. #endif
  196. #endif