Browse Source

Enable thread affinity on Loongson 3B. Fixed the bug of reading cycle counter.

In Loongson 3A and 3B, the CPU core increases the counter in every 2 cycles by default.
tags/v0.1.0^2
Xianyi Zhang 14 years ago
parent
commit
d1baf14a64
2 changed files with 23 additions and 7 deletions
  1. +2
    -0
      Makefile.system
  2. +21
    -7
      common_mips64.h

+ 2
- 0
Makefile.system View File

@@ -591,9 +591,11 @@ endif

ifneq ($(ARCH), x86_64)
ifneq ($(ARCH), x86)
ifneq ($(CORE), LOONGSON3B)
NO_AFFINITY = 1
endif
endif
endif

ifdef NO_AFFINITY
CCOMMON_OPT += -DNO_AFFINITY


+ 21
- 7
common_mips64.h View File

@@ -101,13 +101,15 @@ static void INLINE blas_lock(volatile unsigned long *address){

static inline unsigned int rpcc(void){
unsigned long ret;
#if defined(LOONGSON3A)
unsigned long long tmp;
__asm__ __volatile__("dmfc0 %0, $25, 1": "=r"(tmp):: "memory");
ret=tmp;
#elif defined(LOONGSON3B)
//Temp Implementation.
return 1;
#if defined(LOONGSON3A) || defined(LOONGSON3B)
// unsigned long long tmp;
//__asm__ __volatile__("dmfc0 %0, $25, 1": "=r"(tmp):: "memory");
//ret=tmp;
__asm__ __volatile__(".set push \n"
".set mips32r2\n"
"rdhwr %0, $2\n"
".set pop": "=r"(ret):: "memory");

#else
__asm__ __volatile__(".set push \n"
".set mips32r2\n"
@@ -117,6 +119,18 @@ static inline unsigned int rpcc(void){
return ret;
}

//#if defined(LOONGSON3A) || defined(LOONGSON3B)
static inline int WhereAmI(void){
int ret=0;
__asm__ __volatile__(".set push \n"
".set mips32r2\n"
"rdhwr %0, $0\n"
".set pop": "=r"(ret):: "memory");
return ret;

}
//#endif

static inline int blas_quickdivide(blasint x, blasint y){
return x / y;
}


Loading…
Cancel
Save