|
kusano |
2b45e8 |
/*********************************************************************/
|
|
kusano |
2b45e8 |
/* Copyright 2009, 2010 The University of Texas at Austin. */
|
|
kusano |
2b45e8 |
/* All rights reserved. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* Redistribution and use in source and binary forms, with or */
|
|
kusano |
2b45e8 |
/* without modification, are permitted provided that the following */
|
|
kusano |
2b45e8 |
/* conditions are met: */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* 1. Redistributions of source code must retain the above */
|
|
kusano |
2b45e8 |
/* copyright notice, this list of conditions and the following */
|
|
kusano |
2b45e8 |
/* disclaimer. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* 2. Redistributions in binary form must reproduce the above */
|
|
kusano |
2b45e8 |
/* copyright notice, this list of conditions and the following */
|
|
kusano |
2b45e8 |
/* disclaimer in the documentation and/or other materials */
|
|
kusano |
2b45e8 |
/* provided with the distribution. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
|
|
kusano |
2b45e8 |
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
|
|
kusano |
2b45e8 |
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
|
|
kusano |
2b45e8 |
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
|
kusano |
2b45e8 |
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
|
|
kusano |
2b45e8 |
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
|
kusano |
2b45e8 |
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
|
|
kusano |
2b45e8 |
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
|
|
kusano |
2b45e8 |
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
|
|
kusano |
2b45e8 |
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
|
|
kusano |
2b45e8 |
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
|
|
kusano |
2b45e8 |
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
|
|
kusano |
2b45e8 |
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
|
kusano |
2b45e8 |
/* POSSIBILITY OF SUCH DAMAGE. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* The views and conclusions contained in the software and */
|
|
kusano |
2b45e8 |
/* documentation are those of the authors and should not be */
|
|
kusano |
2b45e8 |
/* interpreted as representing official policies, either expressed */
|
|
kusano |
2b45e8 |
/* or implied, of The University of Texas at Austin. */
|
|
kusano |
2b45e8 |
/*********************************************************************/
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMMON_ALPHA
|
|
kusano |
2b45e8 |
#define COMMON_ALPHA
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef ASSEMBLER
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#define MB asm("mb")
|
|
kusano |
2b45e8 |
#define WMB asm("wmb")
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
static void __inline blas_lock(unsigned long *address){
|
|
kusano |
2b45e8 |
#ifndef __DECC
|
|
kusano |
2b45e8 |
unsigned long tmp1, tmp2;
|
|
kusano |
2b45e8 |
asm volatile(
|
|
kusano |
2b45e8 |
"1: ldq %1, %0\n"
|
|
kusano |
2b45e8 |
" bne %1, 2f\n"
|
|
kusano |
2b45e8 |
" ldq_l %1, %0\n"
|
|
kusano |
2b45e8 |
" bne %1, 2f\n"
|
|
kusano |
2b45e8 |
" or %1, 1, %2\n"
|
|
kusano |
2b45e8 |
" stq_c %2, %0\n"
|
|
kusano |
2b45e8 |
" beq %2, 2f\n"
|
|
kusano |
2b45e8 |
" mb\n "
|
|
kusano |
2b45e8 |
" br $31, 3f\n"
|
|
kusano |
2b45e8 |
"2: br $31, 1b\n"
|
|
kusano |
2b45e8 |
"3:\n" : "=m"(*address), "=&r"(tmp1), "=&r"(tmp2) : : "memory");
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
asm (
|
|
kusano |
2b45e8 |
"10:"
|
|
kusano |
2b45e8 |
" ldq %t0, 0(%a0); "
|
|
kusano |
2b45e8 |
" bne %t0, 20f; "
|
|
kusano |
2b45e8 |
" ldq_l %t0, 0(%a0); "
|
|
kusano |
2b45e8 |
" bne %t0, 20f; "
|
|
kusano |
2b45e8 |
" or %t0, 1, %t1;"
|
|
kusano |
2b45e8 |
" stq_c %t1, 0(%a0); "
|
|
kusano |
2b45e8 |
" beq %t1, 20f; "
|
|
kusano |
2b45e8 |
" mb; "
|
|
kusano |
2b45e8 |
" br %r31,30f; "
|
|
kusano |
2b45e8 |
"20: "
|
|
kusano |
2b45e8 |
" br %r31,10b; "
|
|
kusano |
2b45e8 |
"30:", address);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
static __inline unsigned int rpcc(void){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
unsigned int r0;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef __DECC
|
|
kusano |
2b45e8 |
asm __volatile__("rpcc %0" : "=r"(r0) : : "memory");
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
r0 = asm("rpcc %v0");
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
return r0;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#define HALT ldq $0, 0($0)
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef __DECC
|
|
kusano |
2b45e8 |
#define GET_IMAGE(res) asm __volatile__("fmov $f1, %0" : "=f"(res) : : "memory")
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define GET_IMAGE(res) res = dasm("fmov $f1, %f0")
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef SMP
|
|
kusano |
2b45e8 |
#ifdef USE64BITINT
|
|
kusano |
2b45e8 |
static __inline long blas_quickdivide(long x, long y){
|
|
kusano |
2b45e8 |
return x/y;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
extern unsigned int blas_quick_divide_table[];
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
static __inline int blas_quickdivide(unsigned int x, unsigned int y){
|
|
kusano |
2b45e8 |
if (y <= 1) return x;
|
|
kusano |
2b45e8 |
return (int)((x * (unsigned long)blas_quick_divide_table[y]) >> 32);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#define BASE_ADDRESS ((0x1b0UL << 33) | (0x1c0UL << 23) | (0x000UL << 13))
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef PAGESIZE
|
|
kusano |
2b45e8 |
#define PAGESIZE ( 8UL << 10)
|
|
kusano |
2b45e8 |
#define HUGE_PAGESIZE ( 4 << 20)
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#define BUFFER_SIZE (32UL << 20)
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef F_INTERFACE
|
|
kusano |
2b45e8 |
#define REALNAME ASMNAME
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define REALNAME ASMFNAME
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#define PROLOGUE \
|
|
kusano |
2b45e8 |
.arch ev6; \
|
|
kusano |
2b45e8 |
.set noat; \
|
|
kusano |
2b45e8 |
.set noreorder; \
|
|
kusano |
2b45e8 |
.text; \
|
|
kusano |
2b45e8 |
.align 5; \
|
|
kusano |
2b45e8 |
.globl REALNAME; \
|
|
kusano |
2b45e8 |
.ent REALNAME; \
|
|
kusano |
2b45e8 |
REALNAME:
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef PROFILE
|
|
kusano |
2b45e8 |
#define PROFCODE \
|
|
kusano |
2b45e8 |
ldgp $gp, 0($27); \
|
|
kusano |
2b45e8 |
lda $28, _mcount; \
|
|
kusano |
2b45e8 |
jsr $28, ($28), _mcount; \
|
|
kusano |
2b45e8 |
.prologue 1
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define PROFCODE .prologue 0
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#define EPILOGUE \
|
|
kusano |
2b45e8 |
.end REALNAME; \
|
|
kusano |
2b45e8 |
.ident VERSION
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef DOUBLE
|
|
kusano |
2b45e8 |
#define SXADDQ s8addq
|
|
kusano |
2b45e8 |
#define SXSUBL s8subl
|
|
kusano |
2b45e8 |
#define LD ldt
|
|
kusano |
2b45e8 |
#define ST stt
|
|
kusano |
2b45e8 |
#define STQ stq
|
|
kusano |
2b45e8 |
#define ADD addt/su
|
|
kusano |
2b45e8 |
#define SUB subt/su
|
|
kusano |
2b45e8 |
#define MUL mult/su
|
|
kusano |
2b45e8 |
#define DIV divt/su
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define SXADDQ s4addq
|
|
kusano |
2b45e8 |
#define SXSUBL s4subl
|
|
kusano |
2b45e8 |
#define LD lds
|
|
kusano |
2b45e8 |
#define ST sts
|
|
kusano |
2b45e8 |
#define STQ stl
|
|
kusano |
2b45e8 |
#define ADD adds/su
|
|
kusano |
2b45e8 |
#define SUB subs/su
|
|
kusano |
2b45e8 |
#define MUL muls/su
|
|
kusano |
2b45e8 |
#define DIV divs/su
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|