diff --git a/src/Auxiliary/Aux_GetCPUInfo.cpp b/src/Auxiliary/Aux_GetCPUInfo.cpp index b99860798..3123f3f3c 100644 --- a/src/Auxiliary/Aux_GetCPUInfo.cpp +++ b/src/Auxiliary/Aux_GetCPUInfo.cpp @@ -22,7 +22,11 @@ void Aux_GetCPUInfo( const char *FileName ) FILE *Note = fopen( FileName, "a" ); char *line = NULL; size_t len = 0; - char String[2][100]; + char String[2][MAX_STRING]; + char Trash[MAX_STRING]; + int SocketNow = -1, SocketPrevious = -1; + int CorePerSocket = 0, NSocket = 0; + bool GotFirstCPUInfo = false; // 1. get the CPU info @@ -40,6 +44,18 @@ void Aux_GetCPUInfo( const char *FileName ) { sscanf( line, "%s%s", String[0], String[1] ); + if ( strcmp( String[0], "physical" ) == 0 && strcmp( String[1], "id" ) == 0 ) + { + sscanf( line, "%s%s%s%d", String[0], String[1], Trash, &SocketNow ); + if ( SocketNow != SocketPrevious ) + { + SocketPrevious = SocketNow; + NSocket++; + } + } + + if ( GotFirstCPUInfo ) continue; + if ( strcmp( String[0], "model" ) == 0 && strcmp( String[1], "name" ) == 0 ) { memcpy( line, "CPU Type ", 10 ); @@ -62,7 +78,8 @@ void Aux_GetCPUInfo( const char *FileName ) { memcpy( line, "CPU Cores", 9 ); fprintf( Note, "%s", line ); - break; + sscanf( line, "%s%s%s%d", String[0], String[1], Trash, &CorePerSocket ); + GotFirstCPUInfo = true; } } @@ -72,6 +89,10 @@ void Aux_GetCPUInfo( const char *FileName ) line = NULL; } + fprintf( Note, "%-16s: %d\n", "Socket(s)", NSocket ); +// assuming the CPUs in the node are the same + fprintf( Note, "%-16s: %d\n", "Core(s) per Node", CorePerSocket*NSocket ); + fclose( CPUInfo );