From: Martin Kroeker Date: Wed, 4 May 2022 06:58:56 +0000 (+0200) Subject: Initial attempt at proper cpu detection on RISCV X-Git-Tag: upstream/0.3.21~1^2~33^2~11^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46d22150de5ad28bc3eab2703938a8a816b4e8d5;p=platform%2Fupstream%2Fopenblas.git Initial attempt at proper cpu detection on RISCV --- diff --git a/cpuid_riscv64.c b/cpuid_riscv64.c index 2aa4217..1be10cf 100644 --- a/cpuid_riscv64.c +++ b/cpuid_riscv64.c @@ -79,6 +79,29 @@ static char *cpuname[] = { }; int detect(void){ +#ifdef __linux + FILE *infile; + char buffer[512], *p; + + p = (char *)NULL; + infile = fopen("/proc/cpuinfo", "r"); + while (fgets(buffer, sizeof(buffer), infile)){ + if (!strncmp("isa", buffer, 3)){ + p = strchr(buffer, '4') + 1; /* the 4 in rv64ima... */ +#if 0 + fprintf(stderr, "%s\n", p); +#endif + break; + } + } + + fclose(infile); + + if (strchr(p, 'v')) return CPU_C910V; + + return CPU_GENERIC; +#endif + return CPU_GENERIC; } @@ -91,6 +114,7 @@ void get_architecture(void){ } void get_subarchitecture(void){ + printf("%s",cpuname[detect()]); } void get_subdirname(void){