Gromacs
2025-dev-20240913-b871546
|
Classes | |
struct | ApicInfo |
internal structure to return os logical cpu id together with APIC info for it More... | |
struct | ApicIdLayout |
The layout of the bits in the APIC ID. More... | |
Functions | |
void | trimString (std::string *s) |
Remove initial and trailing whitespace from string. More... | |
int | executeX86CpuID (unsigned int gmx_unused level, unsigned int gmx_unused ecxval, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) |
execute x86 cpuid instructions with custom level and extended level More... | |
CpuInfo::Vendor | detectX86Vendor () |
Detect x86 vendors by using the cpuid assembly instructions. More... | |
bool | detectProcCpuInfoSecondAvx512FMA (const std::string &brand, int model) |
Detect second AVX-512 FMA from the processor name. More... | |
void | setFeatureFromBit (std::set< CpuInfo::Feature > *featureSet, CpuInfo::Feature feature, unsigned int registerValue, unsigned char bit) |
Simple utility function to set/clear feature in a set. More... | |
void | detectX86Features (std::string *brand, int *family, int *model, int *stepping, std::set< CpuInfo::Feature > *features) |
Process x86 cpuinfo features that are common to Intel and AMD CPUs. More... | |
std::vector< ApicInfo > | detectX86ApicInfo (bool gmx_unused haveX2Apic) |
Return a vector with x86 APIC info for all processing units. More... | |
ApicIdLayout | detectX2ApicIdLayout () |
Detect the APIC ID layout for x2APIC. | |
ApicIdLayout | detectAmdApicIdLayout (unsigned int maxExtLevel) |
Detect the APIC ID layout for standard APIC or xAPIC on AMD. More... | |
std::vector < CpuInfo::LogicalProcessor > | detectX86LogicalProcessors () |
Try to detect basic CPU topology information using x86 cpuid. More... | |
std::map< std::string, std::string > | parseProcCpuInfo () |
Parse /proc/cpuinfo into a simple string map. More... | |
CpuInfo::Vendor | detectProcCpuInfoVendor (const std::map< std::string, std::string > &cpuInfo) |
Try to detect vendor from /proc/cpuinfo. More... | |
void | detectProcCpuInfoIbm (const std::map< std::string, std::string > &cpuInfo, std::string *brand, std::set< CpuInfo::Feature > *features) |
Detect IBM processor name and features from /proc/cpuinfo. More... | |
void | detectProcCpuInfoArm (const std::map< std::string, std::string > &cpuInfo, std::string *brand, int *family, int *model, int *stepping, std::set< CpuInfo::Feature > *features) |
Detect ARM processor name and features from /proc/cpuinfo. More... | |
void | detectProcCpuInfo (CpuInfo::Vendor *vendor, std::string *brand, int *family, int *model, int *stepping, std::set< CpuInfo::Feature > *features) |
Try to detect vendor, cpu and features from /proc/cpuinfo. More... | |
ApicIdLayout gmx::anonymous_namespace{cpuinfo.cpp}::detectAmdApicIdLayout | ( | unsigned int | maxExtLevel | ) |
Detect the APIC ID layout for standard APIC or xAPIC on AMD.
[in] | maxExtLevel | The largest CPUID extended function input value supported by the processor implementation |
void gmx::anonymous_namespace{cpuinfo.cpp}::detectProcCpuInfo | ( | CpuInfo::Vendor * | vendor, |
std::string * | brand, | ||
int * | family, | ||
int * | model, | ||
int * | stepping, | ||
std::set< CpuInfo::Feature > * | features | ||
) |
Try to detect vendor, cpu and features from /proc/cpuinfo.
[out] | vendor | Detected hardware vendor |
[out] | brand | String where to write the brand string |
[out] | family | Major version of processor |
[out] | model | Middle version of processor |
[out] | stepping | Minor version of processor |
[out] | features | Feature set where supported features are inserted |
This routine reads the /proc/cpuinfo file into a map and calls subroutines that attempt to parse by matching keys and values to known strings. It is much more fragile than our x86 detection, but it does not depend on specific system calls, intrinsics or assembly instructions.
void gmx::anonymous_namespace{cpuinfo.cpp}::detectProcCpuInfoArm | ( | const std::map< std::string, std::string > & | cpuInfo, |
std::string * | brand, | ||
int * | family, | ||
int * | model, | ||
int * | stepping, | ||
std::set< CpuInfo::Feature > * | features | ||
) |
Detect ARM processor name and features from /proc/cpuinfo.
cpuInfo | Map returned from parseProcCpuinfo() | |
[out] | brand | String where to write the brand string |
[out] | family | Major version of processor |
[out] | model | Middle version of processor |
[out] | stepping | Minor version of processor |
[out] | features | Feature set where supported features are inserted |
This routine tries to match a few common labels in /proc/cpuinfo to see if we can find the processor name and features. It is likely fragile.
void gmx::anonymous_namespace{cpuinfo.cpp}::detectProcCpuInfoIbm | ( | const std::map< std::string, std::string > & | cpuInfo, |
std::string * | brand, | ||
std::set< CpuInfo::Feature > * | features | ||
) |
Detect IBM processor name and features from /proc/cpuinfo.
cpuInfo | Map returned from parseProcCpuinfo() | |
[out] | brand | String where to write the brand string |
[out] | features | Feature set where supported features are inserted |
This routine tries to match a few common labels in /proc/cpuinfo to see if we can find the processor name and features. It is likely fragile.
bool gmx::anonymous_namespace{cpuinfo.cpp}::detectProcCpuInfoSecondAvx512FMA | ( | const std::string & | brand, |
int | model | ||
) |
Detect second AVX-512 FMA from the processor name.
Should only be called for processors already determined to support AVX-512.
[in] | brand | x86 processor name |
[in] | model | x86 model |
CpuInfo::Vendor gmx::anonymous_namespace{cpuinfo.cpp}::detectProcCpuInfoVendor | ( | const std::map< std::string, std::string > & | cpuInfo | ) |
Try to detect vendor from /proc/cpuinfo.
cpuInfo | Map returned from parseProcCpuinfo() |
This routine tries to match a few common labels in /proc/cpuinfo to see if they begin with the name of a standard vendor. If the file cannot be read or if no match is found, we return gmx::CpuInfo::Vendor::Unknown.
std::vector<ApicInfo> gmx::anonymous_namespace{cpuinfo.cpp}::detectX86ApicInfo | ( | bool gmx_unused | haveX2Apic | ) |
Return a vector with x86 APIC info for all processing units.
haveX2Apic | True if the processors supports x2APIC, otherwise vanilla APIC. |
void gmx::anonymous_namespace{cpuinfo.cpp}::detectX86Features | ( | std::string * | brand, |
int * | family, | ||
int * | model, | ||
int * | stepping, | ||
std::set< CpuInfo::Feature > * | features | ||
) |
Process x86 cpuinfo features that are common to Intel and AMD CPUs.
[out] | brand | String where to write the x86 brand string |
[out] | family | Major version of processor |
[out] | model | Middle version of processor |
[out] | stepping | Minor version of processor |
[out] | features | Feature set where supported features are inserted |
std::vector<CpuInfo::LogicalProcessor> gmx::anonymous_namespace{cpuinfo.cpp}::detectX86LogicalProcessors | ( | ) |
Try to detect basic CPU topology information using x86 cpuid.
If x2APIC support is present, this is our first choice, otherwise we attempt to use old vanilla APIC.
CpuInfo::Vendor gmx::anonymous_namespace{cpuinfo.cpp}::detectX86Vendor | ( | ) |
Detect x86 vendors by using the cpuid assembly instructions.
If support for the cpuid instruction is present, we check for Intel, AMD or Hygon vendors
int gmx::anonymous_namespace{cpuinfo.cpp}::executeX86CpuID | ( | unsigned int gmx_unused | level, |
unsigned int gmx_unused | ecxval, | ||
unsigned int * | eax, | ||
unsigned int * | ebx, | ||
unsigned int * | ecx, | ||
unsigned int * | edx | ||
) |
execute x86 cpuid instructions with custom level and extended level
level | The main cpuid level (input argument for eax register) |
ecxval | Extended level (input argument for ecx register) |
eax | Output in eax register |
ebx | Output in ebx register |
ecx | Output in ecx register |
edx | Output in edx register |
std::map<std::string, std::string> gmx::anonymous_namespace{cpuinfo.cpp}::parseProcCpuInfo | ( | ) |
Parse /proc/cpuinfo into a simple string map.
This routine will read the contents of /proc/cpuinfo, and for each line that is not empty we will assign the (trimmed) string to the right of the colon as a key, and the left-hand side as the value in the map. For multi-processor systems where lines are repeated the latter lines will overwrite the first occurrence.
void gmx::anonymous_namespace{cpuinfo.cpp}::setFeatureFromBit | ( | std::set< CpuInfo::Feature > * | featureSet, |
CpuInfo::Feature | feature, | ||
unsigned int | registerValue, | ||
unsigned char | bit | ||
) |
Simple utility function to set/clear feature in a set.
featureSet | Pointer to the feature set to update |
feature | The specific feature to set/clear |
registerValue | Register value (returned from cpuid) |
bit | Bit to check in registerValue. The feature will be added to the featureSet if this bit is set. |
void gmx::anonymous_namespace{cpuinfo.cpp}::trimString | ( | std::string * | s | ) |
Remove initial and trailing whitespace from string.
s | Pointer to string where whitespace will be removed |