mirror of
https://github.com/amd/blis.git
synced 2026-05-11 09:39:59 +00:00
Fixed off-by-one indexing in bli_cpuid.c.
Details: - In bli_cpuid.c, fixed an off-by-one indexing statement in vpu_count() whereby a string-terminating NULL character, '\0', is written beyond the bounds of the model_num string. - Minor whitespace and formatting edits to bli_cpuid.c.
This commit is contained in:
@@ -660,88 +660,88 @@ uint32_t bli_cpuid_query
|
||||
return VENDOR_UNKNOWN;
|
||||
}
|
||||
|
||||
void get_cpu_name(char *cpu_name)
|
||||
void get_cpu_name( char *cpu_name )
|
||||
{
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
|
||||
__cpuid(0x80000002u, eax, ebx, ecx, edx);
|
||||
//printf("%x %x %x %x\n", eax, ebx, ecx, edx);
|
||||
__cpuid( 0x80000002u, eax, ebx, ecx, edx );
|
||||
//printf("%x %x %x %x\n", eax, ebx, ecx, edx);
|
||||
|
||||
*(uint32_t *)&cpu_name[0] = eax;
|
||||
*(uint32_t *)&cpu_name[4] = ebx;
|
||||
*(uint32_t *)&cpu_name[8] = ecx;
|
||||
*(uint32_t *)&cpu_name[12] = edx;
|
||||
*(uint32_t *)&cpu_name[0 ] = eax;
|
||||
*(uint32_t *)&cpu_name[4 ] = ebx;
|
||||
*(uint32_t *)&cpu_name[8 ] = ecx;
|
||||
*(uint32_t *)&cpu_name[12] = edx;
|
||||
|
||||
__cpuid(0x80000003u, eax, ebx, ecx, edx);
|
||||
//printf("%x %x %x %x\n", eax, ebx, ecx, edx);
|
||||
__cpuid( 0x80000003u, eax, ebx, ecx, edx );
|
||||
//printf("%x %x %x %x\n", eax, ebx, ecx, edx);
|
||||
|
||||
*(uint32_t *)&cpu_name[16+0] = eax;
|
||||
*(uint32_t *)&cpu_name[16+4] = ebx;
|
||||
*(uint32_t *)&cpu_name[16+8] = ecx;
|
||||
*(uint32_t *)&cpu_name[16+12] = edx;
|
||||
*(uint32_t *)&cpu_name[16+ 0] = eax;
|
||||
*(uint32_t *)&cpu_name[16+ 4] = ebx;
|
||||
*(uint32_t *)&cpu_name[16+ 8] = ecx;
|
||||
*(uint32_t *)&cpu_name[16+12] = edx;
|
||||
|
||||
__cpuid(0x80000004u, eax, ebx, ecx, edx);
|
||||
//printf("%x %x %x %x\n", eax, ebx, ecx, edx);
|
||||
|
||||
*(uint32_t *)&cpu_name[32+0] = eax;
|
||||
*(uint32_t *)&cpu_name[32+4] = ebx;
|
||||
*(uint32_t *)&cpu_name[32+8] = ecx;
|
||||
*(uint32_t *)&cpu_name[32+12] = edx;
|
||||
__cpuid( 0x80000004u, eax, ebx, ecx, edx );
|
||||
//printf("%x %x %x %x\n", eax, ebx, ecx, edx);
|
||||
|
||||
*(uint32_t *)&cpu_name[32+ 0] = eax;
|
||||
*(uint32_t *)&cpu_name[32+ 4] = ebx;
|
||||
*(uint32_t *)&cpu_name[32+ 8] = ecx;
|
||||
*(uint32_t *)&cpu_name[32+12] = edx;
|
||||
}
|
||||
|
||||
int vpu_count()
|
||||
int vpu_count( void )
|
||||
{
|
||||
char cpu_name[48] = {};
|
||||
char *loc;
|
||||
char model_num[5];
|
||||
int sku;
|
||||
|
||||
get_cpu_name(cpu_name);
|
||||
get_cpu_name( cpu_name );
|
||||
|
||||
if (strstr(cpu_name, "Intel(R) Xeon(R)") != NULL)
|
||||
if ( strstr( cpu_name, "Intel(R) Xeon(R)" ) != NULL )
|
||||
{
|
||||
loc = strstr(cpu_name, "Platinum");
|
||||
if (loc == NULL)
|
||||
loc = strstr(cpu_name, "Gold");
|
||||
if (loc == NULL)
|
||||
loc = strstr(cpu_name, "Silver");
|
||||
if (loc == NULL)
|
||||
loc = strstr(cpu_name, "Bronze");
|
||||
if (loc == NULL)
|
||||
loc = strstr(cpu_name, "W");
|
||||
if (loc == NULL)
|
||||
loc = strstr( cpu_name, "Platinum" );
|
||||
if ( loc == NULL )
|
||||
loc = strstr( cpu_name, "Gold" );
|
||||
if ( loc == NULL )
|
||||
loc = strstr( cpu_name, "Silver" );
|
||||
if ( loc == NULL )
|
||||
loc = strstr( cpu_name, "Bronze" );
|
||||
if ( loc == NULL )
|
||||
loc = strstr( cpu_name, "W" );
|
||||
if ( loc == NULL )
|
||||
return -1;
|
||||
|
||||
loc = strstr(loc+1," ");
|
||||
if(loc == NULL)
|
||||
loc = strstr( loc+1, " " );
|
||||
if ( loc == NULL )
|
||||
return -1;
|
||||
|
||||
strncpy(model_num, loc+1, 4);
|
||||
model_num[5] = '\0';
|
||||
strncpy( model_num, loc+1, 4 );
|
||||
model_num[4] = '\0';
|
||||
|
||||
sku = atoi(model_num);
|
||||
sku = atoi( model_num );
|
||||
|
||||
if (8199 >= sku && sku >= 8100) return 2;
|
||||
else if (6199 >= sku && sku >= 6100) return 2;
|
||||
else if (sku == 5122) return 2;
|
||||
else if (5199 >= sku && sku >= 5100) return 1;
|
||||
else if (4199 >= sku && sku >= 4100) return 1;
|
||||
else if (3199 >= sku && sku >= 3100) return 1;
|
||||
else if (2199 >= sku && sku >= 2120) return 2;
|
||||
else if (2119 >= sku && sku >= 2100) return 1;
|
||||
if ( 8199 >= sku && sku >= 8100 ) return 2;
|
||||
else if ( 6199 >= sku && sku >= 6100 ) return 2;
|
||||
else if ( sku == 5122 ) return 2;
|
||||
else if ( 5199 >= sku && sku >= 5100 ) return 1;
|
||||
else if ( 4199 >= sku && sku >= 4100 ) return 1;
|
||||
else if ( 3199 >= sku && sku >= 3100 ) return 1;
|
||||
else if ( 2199 >= sku && sku >= 2120 ) return 2;
|
||||
else if ( 2119 >= sku && sku >= 2100 ) return 1;
|
||||
else return -1;
|
||||
}
|
||||
else if (strstr(cpu_name, "Intel(R) Core(TM) i9") != NULL)
|
||||
else if ( strstr( cpu_name, "Intel(R) Core(TM) i9" ) != NULL )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (strstr(cpu_name, "Intel(R) Core(TM) i7") != NULL)
|
||||
else if ( strstr( cpu_name, "Intel(R) Core(TM) i7" ) != NULL )
|
||||
{
|
||||
if (strstr(cpu_name, "7800X") != NULL ||
|
||||
strstr(cpu_name, "7820X") != NULL)
|
||||
if ( strstr( cpu_name, "7800X" ) != NULL ||
|
||||
strstr( cpu_name, "7820X" ) != NULL )
|
||||
return 1;
|
||||
else return -1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user