forked from OpenMathLib/OpenBLAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_sparc.h
224 lines (182 loc) · 6.83 KB
/
common_sparc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*********************************************************************/
/* Copyright 2009, 2010 The University of Texas at Austin. */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* 1. Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* */
/* 2. Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of The University of Texas at Austin. */
/*********************************************************************/
#ifndef COMMON_POWER
#define COMMON_POWER
#define MB __asm__ __volatile__ ("nop")
#define WMB __asm__ __volatile__ ("nop")
#ifndef ASSEMBLER
static void __inline blas_lock(volatile unsigned long *address){
long int ret = 1;
do {
while (*address) {YIELDING;};
__asm__ __volatile__(
"ldstub [%1], %0"
: "=&r"(ret)
: "r" (address)
: "memory");
} while (ret);
}
static __inline unsigned long rpcc(void){
unsigned long clocks;
__asm__ __volatile__ ("rd %%tick, %0" : "=r" (clocks));
return clocks;
};
#ifdef __64BIT__
#define RPCC64BIT
#endif
#ifndef __BIG_ENDIAN__
#define __BIG_ENDIAN__
#endif
#ifdef DOUBLE
#define GET_IMAGE(res) __asm__ __volatile__("fmovd %%f2, %0" : "=f"(res) : : "memory")
#else
#define GET_IMAGE(res) __asm__ __volatile__("fmovs %%f1, %0" : "=f"(res) : : "memory")
#endif
#define GET_IMAGE_CANCEL
#ifdef SMP
static __inline int blas_quickdivide(blasint x, blasint y){
return x / y;
}
#endif
#endif
#ifdef ASSEMBLER
#ifndef __64BIT__
#define STACK_START 128
#define SAVESP save %sp, -64, %sp
#else
#define STACK_START 2423
#define SAVESP save %sp, -256, %sp
#endif
#define NOP or %g1, %g1, %g1
#ifdef DOUBLE
#define LDF ldd
#define STF std
#define FADD faddd
#define FMUL fmuld
#define FMOV fmovd
#define FABS fabsd
#define FSUB fsubd
#define FCMP fcmpd
#define FMOVG fmovdg
#define FMOVL fmovdl
#define FSQRT fsqrtd
#define FDIV fdivd
#else
#define LDF ld
#define STF st
#define FADD fadds
#define FMUL fmuls
#define FMOV fmovs
#define FABS fabss
#define FSUB fsubs
#define FCMP fcmps
#define FMOVG fmovsg
#define FMOVL fmovsl
#define FSQRT fsqrts
#define FDIV fdivs
#endif
#define HALT prefetch [%g0], 5
#define FMADDS(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 1 << 5) | (rs2))
#define FMADDD(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 2 << 5) | (rs2))
#define FMSUBS(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 5 << 5) | (rs2))
#define FMSUBD(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 6 << 5) | (rs2))
#define FNMSUBS(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | ( 9 << 5) | (rs2))
#define FNMSUBD(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | (10 << 5) | (rs2))
#define FNMADDS(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | (13 << 5) | (rs2))
#define FNMADDD(rs1, rs2, rs3, rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x37 << 19) | ((rs1) << 14) | ((rs3) << 9) | (14 << 5) | (rs2))
#define FCLRS(rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x61 << 5))
#define FCLRD(rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x60 << 5))
#define FONES(rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x7f << 5))
#define FONED(rd) \
.word ((2 << 30) | ((rd) << 25) | ( 0x36 << 19) | ( 0x7e << 5))
#ifndef DOUBLE
#define FCLR(a) FCLRS(a)
#define FONE(a) FONES(a)
#define FMADD(a, b, c, d) FMADDS(a, b, c, d)
#define FMSUB(a, b, c, d) FMSUBS(a, b, c, d)
#define FNMADD(a, b, c, d) FNMADDS(a, b, c, d)
#define FNMSUB(a, b, c, d) FNMSUBS(a, b, c, d)
#else
#define FCLR(a) FCLRD(a)
#define FONE(a) FONED(a)
#define FMADD(a, b, c, d) FMADDD(a, b, c, d)
#define FMSUB(a, b, c, d) FMSUBD(a, b, c, d)
#define FNMADD(a, b, c, d) FNMADDD(a, b, c, d)
#define FNMSUB(a, b, c, d) FNMSUBD(a, b, c, d)
#endif
#ifndef F_INTERFACE
#define REALNAME ASMNAME
#else
#define REALNAME ASMFNAME
#endif
#ifdef sparc
#define PROLOGUE \
.section ".text"; \
.align 32; \
.global REALNAME;\
.type REALNAME, #function; \
.proc 07; \
REALNAME:;
#define EPILOGUE \
.size REALNAME, .-REALNAME
#endif
#endif
#ifdef sparc
#define SEEK_ADDRESS
#endif
#define BUFFER_SIZE (32 << 20)
#ifndef PAGESIZE
#define PAGESIZE ( 8 << 10)
#endif
#define HUGE_PAGESIZE ( 4 << 20)
#define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
#endif