Browse Source

Fixed the detection bug on Loongson 3A server.

tags/v0.2.4
Zhang Xianyi 13 years ago
parent
commit
758e34efbb
2 changed files with 25 additions and 1 deletions
  1. +4
    -0
      Makefile.system
  2. +21
    -1
      cpuid_mips.c

+ 4
- 0
Makefile.system View File

@@ -61,6 +61,10 @@ ifeq ($(NO_AVX), 1)
GETARCH_FLAGS += -DNO_AVX GETARCH_FLAGS += -DNO_AVX
endif endif


ifeq ($(DEBUG), 1)
GETARCH_FLAGS += -g
endif

# This operation is expensive, so execution should be once. # This operation is expensive, so execution should be once.
ifndef GOTOBLAS_MAKEFILE ifndef GOTOBLAS_MAKEFILE
export GOTOBLAS_MAKEFILE = 1 export GOTOBLAS_MAKEFILE = 1


+ 21
- 1
cpuid_mips.c View File

@@ -1,5 +1,5 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2011, Lab of Parallel Software and Computational Science,ICSAS
Copyright (c) 2011,2012 Lab of Parallel Software and Computational Science,ISCAS
All rights reserved. All rights reserved.


Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@@ -101,12 +101,14 @@ int detect(void){


fclose(infile); fclose(infile);


if(p != NULL){
if (strstr(p, "Loongson-3A")){ if (strstr(p, "Loongson-3A")){
return CPU_LOONGSON3A; return CPU_LOONGSON3A;
}else if(strstr(p, "Loongson-3B")){ }else if(strstr(p, "Loongson-3B")){
return CPU_LOONGSON3B; return CPU_LOONGSON3B;
}else if (strstr(p, "Loongson-3")){ }else if (strstr(p, "Loongson-3")){
infile = fopen("/proc/cpuinfo", "r"); infile = fopen("/proc/cpuinfo", "r");
p = (char *)NULL;
while (fgets(buffer, sizeof(buffer), infile)){ while (fgets(buffer, sizeof(buffer), infile)){
if (!strncmp("system type", buffer, 11)){ if (!strncmp("system type", buffer, 11)){
p = strchr(buffer, ':') + 2; p = strchr(buffer, ':') + 2;
@@ -119,6 +121,24 @@ int detect(void){
}else{ }else{
return CPU_SICORTEX; return CPU_SICORTEX;
} }
}
//Check model name for Loongson3
infile = fopen("/proc/cpuinfo", "r");
p = (char *)NULL;
while (fgets(buffer, sizeof(buffer), infile)){
if (!strncmp("model name", buffer, 10)){
p = strchr(buffer, ':') + 2;
break;
}
}
fclose(infile);
if(p != NULL){
if (strstr(p, "Loongson-3A")){
return CPU_LOONGSON3A;
}else if(strstr(p, "Loongson-3B")){
return CPU_LOONGSON3B;
}
}
#endif #endif
return CPU_UNKNOWN; return CPU_UNKNOWN;
} }


Loading…
Cancel
Save