Skip to content
Open
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
25 changes: 23 additions & 2 deletions src/Auxiliary/Aux_GetCPUInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 );
Expand All @@ -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;
}
}

Expand All @@ -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 );


Expand Down