diff --git a/src/main.c b/src/main.c index f91b908..0f7b457 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,7 @@ Peak FLOPS: 512 GFLOP/s(in simple precision) ***/ -static const char* VERSION = "0.49"; +static const char* VERSION = "0.410"; void print_help(char *argv[]) { printf("Usage: %s [--version] [--help] [--style STYLE]\n\ diff --git a/src/standart.c b/src/standart.c index 1e908d0..1482153 100644 --- a/src/standart.c +++ b/src/standart.c @@ -5,14 +5,17 @@ #include #include +#ifdef _WIN32 +#include +#else +#include +#include "udev.h" +#endif + #include "standart.h" #include "cpuid.h" #include "global.h" -#ifndef _WIN32 -#include "udev.h" -#endif - #define VENDOR_INTEL_STRING "GenuineIntel" #define VENDOR_AMD_STRING "AuthenticAMD" @@ -69,9 +72,11 @@ struct frequency { }; struct topology { + int64_t total_cores; uint32_t physical_cores; uint32_t logical_cores; - uint32_t smt; + uint32_t smt; + uint32_t sockets; bool ht; }; @@ -276,6 +281,21 @@ struct topology* get_topology_info(struct cpuInfo* cpu) { return NULL; } + // Ask the OS the total number of cores it sees + // If we have one socket, it will be same as the cpuid, + // but in dual socket it will not! + #ifdef _WIN32 + SYSTEM_INFO info; + GetSystemInfo(&info); + topo->total_cores = info.dwNumberOfProcessors; + #else + if((topo->total_cores = sysconf(_SC_NPROCESSORS_ONLN)) == -1) { + perror("sysconf"); + topo->total_cores = topo->logical_cores; // fallback + } + #endif + topo->sockets = topo->total_cores / topo->smt / topo->physical_cores; // Idea borrowed from lscpu + return topo; }