1 /*****************************************************************************
2 Copyright (c) 2011-2016, The OpenBLAS Project
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16 3. Neither the name of the OpenBLAS project nor the names of
17 its contributors may be used to endorse or promote products
18 derived from this software without specific prior written
19 permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 **********************************************************************************/
32
33 #ifndef COMMON_ZARCH
34 #define COMMON_ZARCH
35
36 #define MB
37 #define WMB
38 #define RMB
39
40
41 #define INLINE inline
42
43 #define RETURN_BY_COMPLEX
44
45 #ifndef ASSEMBLER
46
47 /*
48 static void __inline blas_lock(volatile BLASULONG *address){
49
50 BLASULONG ret;
51
52 do {
53 while (*address) {YIELDING;};
54
55 __asm__ __volatile__(
56 "mov x4, #1 \n\t"
57 "1: \n\t"
58 "ldaxr x2, [%1] \n\t"
59 "cbnz x2, 1b \n\t"
60 "2: \n\t"
61 "stxr w3, x4, [%1] \n\t"
62 "cbnz w3, 1b \n\t"
63 "mov %0, #0 \n\t"
64 : "=r"(ret), "=r"(address)
65 : "1"(address)
66 : "memory", "x2" , "x3", "x4"
67
68
69 );
70
71
72 } while (ret);
73
74 }
75 */
76 //#define BLAS_LOCK_DEFINED
77
78
79
blas_quickdivide(blasint x,blasint y)80 static inline int blas_quickdivide(blasint x, blasint y){
81 return x / y;
82 }
83
84 #if defined(DOUBLE)
85 #define GET_IMAGE(res) __asm__ __volatile__("str d1, %0" : "=m"(res) : : "memory")
86 #else
87 #define GET_IMAGE(res) __asm__ __volatile__("str s1, %0" : "=m"(res) : : "memory")
88 #endif
89
90 #define GET_IMAGE_CANCEL
91
92 #endif
93
94
95 #ifndef F_INTERFACE
96 #define REALNAME ASMNAME
97 #else
98 #define REALNAME ASMFNAME
99 #endif
100
101 #if defined(ASSEMBLER) && !defined(NEEDPARAM)
102
103 #define PROLOGUE \
104 .text ;\
105 .align 256 ;\
106 .global REALNAME ;\
107 .type REALNAME, %function ;\
108 REALNAME:
109
110
111 #define EPILOGUE
112
113 #define PROFCODE
114
115 #endif
116
117
118 #define SEEK_ADDRESS
119
120 #ifndef PAGESIZE
121 #define PAGESIZE ( 4 << 10)
122 #endif
123 #define HUGE_PAGESIZE ( 4 << 20)
124
125 #define BUFFER_SIZE (32 << 22)
126
127
128 #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
129
130 #ifndef MAP_ANONYMOUS
131 #define MAP_ANONYMOUS MAP_ANON
132 #endif
133
134 #endif
135
136