1 /*****************************************************************************
2 Copyright (c) 2011-2015, The OpenBLAS Project
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
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
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
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 **********************************************************************************/
36 #if defined(ARMV5) || defined(ARMV6)
44 #define MB __asm__ __volatile__ ("dmb ish" : : : "memory")
45 #define WMB __asm__ __volatile__ ("dmb ishst" : : : "memory")
46 #define RMB __asm__ __volatile__ ("dmb ish" : : : "memory")
52 #define RETURN_BY_COMPLEX
56 #if defined(ARMV6) || defined(ARMV7) || defined(ARMV8)
58 static void __inline blas_lock(volatile BLASULONG *address){
63 while (*address) {YIELDING;};
67 "strex %0, %2, [%1] \n\t"
70 : "r"(address), "r"(1)
78 #define BLAS_LOCK_DEFINED
81 static inline int blas_quickdivide(blasint x, blasint y){
85 #if !defined(HAVE_VFP)
86 /* no FPU, soft float */
87 #define GET_IMAGE(res)
89 #define GET_IMAGE(res) __asm__ __volatile__("vstr.f64 d1, %0" : "=m"(res) : : "memory")
91 #define GET_IMAGE(res) __asm__ __volatile__("vstr.f32 s1, %0" : "=m"(res) : : "memory")
94 #define GET_IMAGE_CANCEL
100 #define REALNAME ASMNAME
102 #define REALNAME ASMFNAME
105 #if defined(ASSEMBLER) && !defined(NEEDPARAM)
122 #define PAGESIZE ( 4 << 10)
124 #define HUGE_PAGESIZE ( 4 << 20)
126 #define BUFFER_SIZE (32 << 20)
129 #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
131 #ifndef MAP_ANONYMOUS
132 #define MAP_ANONYMOUS MAP_ANON
135 #if !defined(ARMV5) && !defined(ARMV6) && !defined(ARMV7) && !defined(ARMV8)
136 #error "you must define ARMV5, ARMV6, ARMV7 or ARMV8"