Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 40 additions & 41 deletions cpuid_mips.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*****************************************************************************
Copyright (c) 2011-2014, The OpenBLAS Project
Copyright (c) 2011-2026, The OpenBLAS Project
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -13,9 +13,9 @@ modification, are permitted provided that the following conditions are
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Expand Down Expand Up @@ -109,7 +109,7 @@ int detect(void){
return CPU_1004K;
} else if (strstr(p, " 24K")) {
return CPU_24K;
} else
} else
return CPU_UNKNOWN;
}
#endif
Expand All @@ -136,6 +136,40 @@ void get_subdirname(void){
printf("mips");
}

int get_feature(char *search) {

#ifdef __linux
FILE *infile;
char buffer[2048], *p, *t;
p = (char *)NULL;

infile = fopen("/proc/cpuinfo", "r");

while (fgets(buffer, sizeof(buffer), infile)) {

if (!strncmp("Features", buffer, 8) ||
!strncmp("ASEs implemented", buffer, 16)) {
p = strchr(buffer, ':') + 2;
break;
}
}

fclose(infile);

if (p == NULL)
return 0;

t = strtok(p, " ");
while (t = strtok(NULL, " ")) {
if (strstr(t, search)) {
return (1);
}
}

#endif
return (0);
}

void get_cpuconfig(void){
if(detect()==CPU_P5600){
printf("#define P5600\n");
Expand Down Expand Up @@ -165,7 +199,7 @@ void get_cpuconfig(void){
}else{
printf("#define UNKNOWN\n");
}
#ifndef NO_MSA
#ifndef NO_MSA
if (get_feature("msa")) printf("#define HAVE_MSA\n");
#endif
}
Expand All @@ -181,38 +215,3 @@ void get_libname(void){
printf("mips\n");
}
}

int get_feature(char *search)
{

#ifdef __linux
FILE *infile;
char buffer[2048], *p,*t;
p = (char *) NULL ;

infile = fopen("/proc/cpuinfo", "r");

while (fgets(buffer, sizeof(buffer), infile))
{

if (!strncmp("Features", buffer, 8) || !strncmp("ASEs implemented", buffer, 16))
{
p = strchr(buffer, ':') + 2;
break;
}
}

fclose(infile);

if( p == NULL ) return 0;

t = strtok(p," ");
while( t = strtok(NULL," "))
{
if (strstr(t, search)) { return(1); }
}

#endif
return(0);
}

79 changes: 39 additions & 40 deletions cpuid_mips64.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*****************************************************************************
Copyright (c) 2011-2014, The OpenBLAS Project
Copyright (c) 2011-2026, The OpenBLAS Project
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -13,9 +13,9 @@ modification, are permitted provided that the following conditions are
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Expand Down Expand Up @@ -145,13 +145,47 @@ void get_subarchitecture(void){
printf("SICORTEX");
}else{
printf("MIPS64_GENERIC");
}
}
}

void get_subdirname(void){
printf("mips64");
}

int get_feature(char *search) {

#ifdef __linux
FILE *infile;
char buffer[2048], *p, *t;
p = (char *)NULL;

infile = fopen("/proc/cpuinfo", "r");

while (fgets(buffer, sizeof(buffer), infile)) {

if (!strncmp("Features", buffer, 8) ||
!strncmp("ASEs implemented", buffer, 16)) {
p = strchr(buffer, ':') + 2;
break;
}
}

fclose(infile);

if (p == NULL)
return 0;

t = strtok(p, " ");
while (t = strtok(NULL, " ")) {
if (strstr(t, search)) {
return (1);
}
}

#endif
return (0);
}

void get_cpuconfig(void){
if(detect()==CPU_LOONGSON3R3) {
printf("#define LOONGSON3R3\n");
Expand Down Expand Up @@ -228,38 +262,3 @@ void get_libname(void){
printf("mips64_generic\n");
}
}

int get_feature(char *search)
{

#ifdef __linux
FILE *infile;
char buffer[2048], *p,*t;
p = (char *) NULL ;

infile = fopen("/proc/cpuinfo", "r");

while (fgets(buffer, sizeof(buffer), infile))
{

if (!strncmp("Features", buffer, 8) || !strncmp("ASEs implemented", buffer, 16))
{
p = strchr(buffer, ':') + 2;
break;
}
}

fclose(infile);

if( p == NULL ) return 0;

t = strtok(p," ");
while( t = strtok(NULL," "))
{
if (strstr(t, search)) { return(1); }
}

#endif
return(0);
}

Loading