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_ia64.h 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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_IA64
  39. #define COMMON_IA64
  40. #ifndef ASSEMBLER
  41. #ifndef MAP_WRITECOMBINED
  42. #define MAP_WRITECOMBINED 0x10000
  43. #endif
  44. #define MB
  45. #define WMB
  46. #ifdef __ECC
  47. #include <ia64intrin.h>
  48. #endif
  49. #define RPCC64BIT
  50. #ifndef __ECC
  51. static __inline void blas_lock(volatile unsigned long *address){
  52. unsigned long ret;
  53. do {
  54. while (*address) {YIELDING;};
  55. __asm__ __volatile__ ("mov ar.ccv=r0\n;;\n"
  56. "cmpxchg4.acq %0=[%2],%1,ar.ccv\n"
  57. : "=r"(ret) : "r"(1), "r"(address)
  58. : "ar.ccv", "memory");
  59. } while (ret);
  60. }
  61. static __inline unsigned long rpcc(void) {
  62. unsigned long clocks;
  63. __asm__ __volatile__ ("mov %0=ar.itc" : "=r"(clocks));
  64. return clocks;
  65. }
  66. static __inline unsigned long stmxcsr(void){
  67. unsigned long fp;
  68. __asm__ __volatile__ ("mov.m %0=ar.fpsr" : "=r" (fp));
  69. return fp;
  70. }
  71. static __inline void ldmxcsr(unsigned long fp) {
  72. __asm__ __volatile__ ("mov.m ar.fpsr=%0" :: "r" (fp));
  73. }
  74. #define GET_IMAGE(res) asm __volatile__("mov %0 = f9" : "=f"(res) : : "memory")
  75. #else
  76. static __inline void blas_lock(volatile unsigned long *address){
  77. while (*address || _InterlockedCompareExchange((volatile int *) address,1,0))
  78. ;
  79. }
  80. static __inline unsigned int rpcc(void) {
  81. return __getReg(_IA64_REG_AR_ITC);
  82. }
  83. static __inline unsigned int stmxcsr(void) {
  84. return __getReg(_IA64_REG_AR_FPSR);
  85. }
  86. static __inline void ldmxcsr(unsigned long fp) {
  87. return __setReg(_IA64_REG_AR_FPSR, fp);
  88. }
  89. #ifdef DOUBLE
  90. #define GET_IMAGE(res) __stfd(&res, 9)
  91. #else
  92. #define GET_IMAGE(res) __stfs(&res, 9)
  93. #endif
  94. #endif
  95. #define GET_IMAGE_CANCEL
  96. #ifdef ENABLE_SSE_EXCEPTION
  97. #define IDEBUG_START \
  98. { \
  99. unsigned long fp_sse_mode, new_fp_mode; \
  100. fp_sse_mode = stmxcsr();\
  101. new_fp_mode = (fp_sse_mode & ~(FE_UNDERFLOW | FE_OVERFLOW | FE_UNNORMAL | FE_INVALID));\
  102. ldmxcsr(new_fp_mode);
  103. #define IDEBUG_END \
  104. ldmxcsr(fp_sse_mode); \
  105. }
  106. #endif
  107. #ifdef SMP
  108. #ifdef USE64BITINT
  109. /* 64bit version */
  110. extern unsigned long blas_quick_divide_table[];
  111. #ifndef __ECC
  112. static __inline long blas_quickdivide(unsigned long int x, unsigned long int y){
  113. unsigned long ret;
  114. if (y <= 1) return x;
  115. __asm__ __volatile__("setf.sig f6 = %1\n\t"
  116. "ldf8 f7 = [%2];;\n\t"
  117. "xmpy.hu f6= f6, f7;;\n\t"
  118. "getf.sig %0 = f6;;\n"
  119. : "=r"(ret)
  120. : "r"(x), "r"(&blas_quick_divide_table[y]) : "f6", "f7"
  121. );
  122. return ret;
  123. }
  124. #else
  125. /* Using Intel Compiler */
  126. static __inline long blas_quickdivide(unsigned long int x, unsigned long int y){
  127. if (y <= 1) return x;
  128. return _m64_xmahu(x, blas_quick_divide_table[y], 0);
  129. }
  130. #endif
  131. #else
  132. /* 32bit version */
  133. extern unsigned int blas_quick_divide_table[];
  134. static __inline int blas_quickdivide(unsigned int x, unsigned int y){
  135. if (y <= 1) return x;
  136. return (int)((x * (unsigned long)blas_quick_divide_table[y]) >> 32);
  137. }
  138. #endif
  139. #endif
  140. #endif
  141. #if 0
  142. #ifdef DOUBLE
  143. #define GEMM_NCOPY dgemm_ncopy
  144. #define GEMM_TCOPY dgemm_tcopy
  145. #define ZGEMM_NCOPY zgemm_ncopy
  146. #define ZGEMM_TCOPY zgemm_tcopy
  147. #define GEMM_KERNEL dgemm_kernel
  148. #if defined(NN) || defined(NT) || defined(TN) || defined(TT)
  149. #define ZGEMM_KERNEL zgemm_kernel_n
  150. #endif
  151. #if defined(CN) || defined(CT) || defined(RN) || defined(RT)
  152. #define ZGEMM_KERNEL zgemm_kernel_l
  153. #endif
  154. #if defined(NC) || defined(TC) || defined(NR) || defined(TR)
  155. #define ZGEMM_KERNEL zgemm_kernel_r
  156. #endif
  157. #if defined(CC) || defined(CR) || defined(RC) || defined(RR)
  158. #define ZGEMM_KERNEL zgemm_kernel_b
  159. #endif
  160. #else
  161. #define GEMM_NCOPY sgemm_ncopy
  162. #define GEMM_TCOPY sgemm_tcopy
  163. #define ZGEMM_NCOPY cgemm_ncopy
  164. #define ZGEMM_TCOPY cgemm_tcopy
  165. #define GEMM_KERNEL sgemm_kernel
  166. #if defined(NN) || defined(NT) || defined(TN) || defined(TT)
  167. #define ZGEMM_KERNEL cgemm_kernel_n
  168. #endif
  169. #if defined(CN) || defined(CT) || defined(RN) || defined(RT)
  170. #define ZGEMM_KERNEL cgemm_kernel_l
  171. #endif
  172. #if defined(NC) || defined(TC) || defined(NR) || defined(TR)
  173. #define ZGEMM_KERNEL cgemm_kernel_r
  174. #endif
  175. #if defined(CC) || defined(CR) || defined(RC) || defined(RR)
  176. #define ZGEMM_KERNEL cgemm_kernel_b
  177. #endif
  178. #endif
  179. #endif
  180. #ifdef USE64BITINT
  181. #define LDINT ld8
  182. #define INTSIZE 8
  183. #define CMP4GE cmp.ge
  184. #define CMP4NE cmp.ge
  185. #define CMP4EQ cmp.eq
  186. #else
  187. #define LDINT ld4
  188. #define INTSIZE 4
  189. #define CMP4GE cmp4.ge
  190. #define CMP4NE cmp4.ne
  191. #define CMP4EQ cmp4.eq
  192. #endif
  193. #define HALT mov r0 = 0
  194. #ifdef XDOUBLE
  195. #define LD8 ld8
  196. #define ST8 st8
  197. #define LDFD ldfe
  198. #define LDFPD ldfpe
  199. #define LDFD_T1 ldfe.t1
  200. #define LDFD_NT1 ldfe.nt1
  201. #define LDFD_NT2 ldfe.nt2
  202. #define LDFD_NTA ldfe.nta
  203. #define LDFPD_NT1 ldfpe.nt1
  204. #define LDFPD_NT2 ldfpe.nt2
  205. #define LDFPD_NTA ldfpe.nta
  206. #define STFD stfe
  207. #define STFD_NTA stfe.nta
  208. #define FADD fadd
  209. #define FSUB fsub
  210. #define FMPY fmpy
  211. #define FMA fma
  212. #define FMS fms
  213. #define FNMA fnma
  214. #define FPMA fpma
  215. #define SETF setf.d
  216. #elif defined(DOUBLE)
  217. #define LD8 ld8
  218. #define ST8 st8
  219. #define LDF8 ldf8
  220. #define LDF8_NT1 ldf8.nt1
  221. #define LDF8_NTA ldf8.nta
  222. #define STF8 stf8
  223. #define STF8_NTA stf8.nta
  224. #define LDFD ldfd
  225. #define LDFPD ldfpd
  226. #define LDFD_T1 ldfd.t1
  227. #define LDFD_NT1 ldfd.nt1
  228. #define LDFD_NT2 ldfd.nt2
  229. #define LDFD_NTA ldfd.nta
  230. #define LDFPD_NT1 ldfpd.nt1
  231. #define LDFPD_NT2 ldfpd.nt2
  232. #define LDFPD_NTA ldfpd.nta
  233. #define STFD stfd
  234. #define STFD_NTA stfd.nta
  235. #define FADD fadd.d
  236. #define FSUB fsub.d
  237. #define FMPY fmpy.d
  238. #define FMA fma.d
  239. #define FMS fms.d
  240. #define FNMA fnma.d
  241. #define FPMA fpma.d
  242. #define SETF setf.d
  243. #else
  244. #define LD8 ld4
  245. #define ST8 st4
  246. #define LDF8 ldfs
  247. #define LDF8_NT1 ldfs.nt1
  248. #define LDF8_NTA ldfs.nta
  249. #define STF8 stfs
  250. #define STF8_NTA stfs.nta
  251. #define LDFD ldfs
  252. #define LDFPD ldfps
  253. #define LDFD_T1 ldfs.t1
  254. #define LDFD_NT1 ldfs.nt1
  255. #define LDFD_NT2 ldfs.nt2
  256. #define LDFD_NTA ldfs.nta
  257. #define LDFPD_NT1 ldfps.nt1
  258. #define LDFPD_NT2 ldfps.nt2
  259. #define LDFPD_NTA ldfps.nta
  260. #define STFD stfs
  261. #define STFD_NTA stfs.nta
  262. #if 0
  263. #define FADD fadd.s
  264. #define FSUB fsub.s
  265. #define FMPY fmpy.s
  266. #define FMA fma.s
  267. #define FMS fms.s
  268. #define FNMA fnma.s
  269. #define FPMA fpma.s
  270. #else
  271. #define FADD fadd
  272. #define FSUB fsub
  273. #define FMPY fmpy
  274. #define FMA fma
  275. #define FMS fms
  276. #define FNMA fnma
  277. #define FPMA fpma
  278. #endif
  279. #define SETF setf.s
  280. #endif
  281. #ifndef F_INTERFACE
  282. #define REALNAME ASMNAME
  283. #else
  284. #define REALNAME ASMFNAME
  285. #endif
  286. #ifdef F_INTERFACE_G77
  287. #define RETURN_BY_STACK
  288. #endif
  289. #ifdef F_INTERFACE_G95
  290. #define RETURN_BY_STACK
  291. #endif
  292. #ifdef F_INTERFACE_GFORT
  293. #define RETURN_BY_REGS
  294. #endif
  295. #ifdef F_INTERFACE_INTEL
  296. #define RETURN_BY_STACK
  297. #endif
  298. #define PROLOGUE \
  299. .explicit; \
  300. .text; \
  301. .align 128; \
  302. .global REALNAME; \
  303. .proc REALNAME; \
  304. REALNAME:
  305. #ifdef PROFILE
  306. #define PROFCODE \
  307. .data; \
  308. .align 8; \
  309. .LP0:; \
  310. data8 0; \
  311. .text; \
  312. alloc out0 = ar.pfs, 8, 0, 4, 0; \
  313. mov out1 = r1; \
  314. mov out2 = b0; \
  315. addl out3 = @ltoff(.LP0), r1;;; \
  316. br.call.sptk.many b0 = _mcount;;
  317. #else
  318. #define PROFCODE
  319. #endif
  320. #define EPILOGUE \
  321. .endp REALNAME
  322. #define START_ADDRESS 0x20000fc800000000UL
  323. #undef SEEK_ADDRESS
  324. #if 0
  325. #ifdef CONFIG_IA64_PAGE_SIZE_4KB
  326. #define SEEK_ADDRESS
  327. #endif
  328. #ifdef CONFIG_IA64_PAGE_SIZE_8KB
  329. #define SEEK_ADDRESS
  330. #endif
  331. #endif
  332. #define BUFFER_SIZE (128 << 20)
  333. #ifndef PAGESIZE
  334. #define PAGESIZE (16UL << 10)
  335. #endif
  336. #define HUGE_PAGESIZE ( 4 << 20)
  337. #define BASE_ADDRESS (START_ADDRESS - (BLASULONG)BUFFER_SIZE * MAX_CPU_NUMBER)
  338. #endif

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

Contributors (1)