Compare commits

...

3 Commits
i277 ... i255

Author SHA1 Message Date
Dr-Noob
64ef0d889c [v1.05][X86] Fix for Meteor Lake (#255) 2024-07-30 08:52:22 +01:00
Dr-Noob
d297878a51 [v1.05][X86] Experimental new implementation of abbreviate_intel_cpu_name 2024-07-29 08:53:01 +01:00
Dr-Noob
ac308204c7 [v1.05][X86] Add preeliminary support for Meteor Lake (#255) 2024-07-28 22:53:17 +01:00
6 changed files with 90 additions and 32 deletions

View File

@@ -45,8 +45,9 @@ enum {
};
enum {
CORE_TYPE_EFFICIENCY,
CORE_TYPE_PERFORMANCE,
CORE_TYPE_EFFICIENCY,
CORE_TYPE_LP_EFFICIENCY,
CORE_TYPE_UNKNOWN
};

View File

@@ -614,8 +614,9 @@ bool print_cpufetch_x86(struct cpuInfo* cpu, STYLE s, struct color** cs, struct
}
if(hybrid_architecture) {
if(ptr->core_type == CORE_TYPE_EFFICIENCY) sprintf(cpu_num, "E-cores:");
else if(ptr->core_type == CORE_TYPE_PERFORMANCE) sprintf(cpu_num, "P-cores:");
if (ptr->core_type == CORE_TYPE_PERFORMANCE) sprintf(cpu_num, "P-cores:");
else if (ptr->core_type == CORE_TYPE_EFFICIENCY) sprintf(cpu_num, "E-cores:");
else if (ptr->core_type == CORE_TYPE_LP_EFFICIENCY) sprintf(cpu_num, "LP-E-cores:");
else printBug("Found invalid core type!\n");
setAttribute(art, ATTRIBUTE_CPU_NUM, cpu_num);

View File

@@ -91,6 +91,7 @@ int get_total_cores_module(int total_cores, int module) {
while(!end) {
if(!bind_to_cpu(i)) {
printBug("get_total_cores_module: Cannot bind to core %d", i);
return -1;
}
uint32_t eax = 0x0000001A;
@@ -99,6 +100,17 @@ int get_total_cores_module(int total_cores, int module) {
uint32_t edx = 0;
cpuid(&eax, &ebx, &ecx, &edx);
int32_t core_type = eax >> 24 & 0xFF;
// Here we artificially create a new core type for
// LP-E cores. In case the core has no L3 (on a hybrid)
// architecture, then we now it's an LP-E core.
eax = 0x4;
ebx = 0;
ecx = 0x3;
edx = 0;
cpuid(&eax, &ebx, &ecx, &edx);
core_type += eax == 0;
bool found = false;
for(int j=0; j < total_modules && !found; j++) {

View File

@@ -137,39 +137,31 @@ bool abbreviate_intel_cpu_name(char** name) {
char* new_name_ptr = new_name;
char* aux_ptr = NULL;
// 1. Remove "(R)"
// 1. Find "Intel(R)"
old_name_ptr = strstr(old_name_ptr, "Intel(R)");
if(old_name_ptr == NULL) return false;
strcpy(new_name_ptr, "Intel");
new_name_ptr += strlen("Intel");
old_name_ptr += strlen("Intel(R)");
// 2. Remove "(R)" or "(TM)"
aux_ptr = strstr(old_name_ptr, "(");
if(aux_ptr == NULL) return false;
strncpy(new_name_ptr, old_name_ptr, aux_ptr-old_name_ptr);
new_name_ptr += aux_ptr-old_name_ptr;
strcpy(new_name_ptr, " ");
new_name_ptr++;
old_name_ptr = strstr(aux_ptr, ")");
if(old_name_ptr == NULL) return false;
old_name_ptr++;
while(*old_name_ptr == ' ') old_name_ptr++;
// 3. Copy the CPU name
// 2. Search for "@"
aux_ptr = strstr(old_name_ptr, "@");
if(aux_ptr == NULL) return false;
strncpy(new_name_ptr, old_name_ptr, (aux_ptr-1)-old_name_ptr);
if(aux_ptr == NULL) {
// New CPUs, copy end ptr is end of string
aux_ptr = old_name + strlen(old_name);
strncpy(new_name_ptr, old_name_ptr, (aux_ptr)-old_name_ptr);
}
else {
// Copy end ptr is "@"
strncpy(new_name_ptr, old_name_ptr, (aux_ptr-1)-old_name_ptr);
}
// 4. Remove dummy strings in Intel CPU names
// 3. Remove dummy strings in Intel CPU names
strremove(new_name, "(R)");
strremove(new_name, "(TM)");
strremove(new_name, " CPU");
strremove(new_name, " Dual");
strremove(new_name, " 0");
free(old_name);
*name = new_name;
return true;
}
@@ -397,6 +389,17 @@ bool set_cpu_module(int m, int total_modules, int32_t* first_core) {
uint32_t edx = 0;
cpuid(&eax, &ebx, &ecx, &edx);
int32_t core_type = eax >> 24 & 0xFF;
// Here we artificially create a new core type for
// LP-E cores. In case the core has no L3 (on a hybrid)
// architecture, then we now it's an LP-E core.
eax = 0x4;
ebx = 0;
ecx = 0x3;
edx = 0;
cpuid(&eax, &ebx, &ecx, &edx);
core_type += eax == 0;
bool found = false;
for(int j=0; j < total_modules && !found; j++) {
@@ -423,13 +426,19 @@ bool set_cpu_module(int m, int total_modules, int32_t* first_core) {
#endif
}
else {
// This is a normal architecture
// This is a non-hybrid architecture
*first_core = 0;
}
return true;
}
// Difference between E and LP-E cores:
// According to Intel Core Ultra Processor Datasheet Volume 1 of 2
// (https://www.intel.com/content/www/us/en/content-details/792044/intel-core-ultra-processor-datasheet-volume-1-of-2.html),
// LP-E cores do not have L3 cache. This seems to be the only way of differentiating them.
// - https://community.intel.com/t5/Processors/Detecting-LP-E-Cores-on-Meteor-Lake-in-software/m-p/1584555/highlight/true#M70732
// - https://x.com/InstLatX64/status/1741416428538941718
int32_t get_core_type(void) {
uint32_t eax = 0x0000001A;
uint32_t ebx = 0;
@@ -440,8 +449,26 @@ int32_t get_core_type(void) {
cpuid(&eax, &ebx, &ecx, &edx);
int32_t type = eax >> 24 & 0xFF;
if(type == 0x20) return CORE_TYPE_EFFICIENCY;
else if(type == 0x40) return CORE_TYPE_PERFORMANCE;
if (type == 0x40) return CORE_TYPE_PERFORMANCE;
else if (type == 0x20) {
// get_core_type is only called iff hybrid_flag is true, which can only
// happen if CPUID maxLevel >= 0x7 so we can assume the CPU supports
// CPUID leaf 0x4
eax = 0x4;
ebx = 0;
ecx = 0x3;
edx = 0;
cpuid(&eax, &ebx, &ecx, &edx);
if (eax == 0) {
// No L3 access, this is LP-E
return CORE_TYPE_LP_EFFICIENCY;
}
else {
return CORE_TYPE_EFFICIENCY;
}
}
else {
printErr("Found invalid core type: 0x%.8X\n", type);
return CORE_TYPE_UNKNOWN;
@@ -456,7 +483,6 @@ struct cpuInfo* get_cpu_info(void) {
cpu->cach = NULL;
cpu->feat = NULL;
cpu->num_cpus = 1;
uint32_t eax = 0;
uint32_t ebx = 0;
uint32_t ecx = 0;
@@ -514,7 +540,13 @@ struct cpuInfo* get_cpu_info(void) {
cpu->hybrid_flag = (edx >> 15) & 0x1;
}
if(cpu->hybrid_flag) cpu->num_cpus = 2;
if(cpu->hybrid_flag) {
struct uarch* tmp = get_cpu_uarch(cpu);
cpu->num_cpus = get_hybrid_num_cpus(tmp);
}
else {
cpu->num_cpus = 1;
}
struct cpuInfo* ptr = cpu;
for(uint32_t i=0; i < cpu->num_cpus; i++) {
@@ -529,8 +561,9 @@ struct cpuInfo* get_cpu_info(void) {
ptr->topo = NULL;
ptr->cach = NULL;
ptr->feat = NULL;
// We assume that this cores have the
// same cpuid capabilities
// We assume that this core has the
// same cpuid capabilities as the core in the
// first module
ptr->cpu_vendor = cpu->cpu_vendor;
ptr->maxLevels = cpu->maxLevels;
ptr->maxExtendedLevels = cpu->maxExtendedLevels;
@@ -700,6 +733,8 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach, int
if(cpu->hybrid_flag) {
#ifdef __linux__
topo->total_cores_module = get_total_cores_module(topo->total_cores, module);
printBug("get_total_cores_module: Failed to get number of cores in module");
return NULL;
#else
UNUSED(module);
topo->total_cores_module = topo->total_cores;

View File

@@ -94,6 +94,7 @@ enum {
UARCH_TIGER_LAKE,
UARCH_ALDER_LAKE,
UARCH_RAPTOR_LAKE,
UARCH_METEOR_LAKE,
// AMD //
UARCH_AM486,
UARCH_AM5X86,
@@ -248,6 +249,7 @@ struct uarch* get_uarch_from_cpuid_intel(uint32_t ef, uint32_t f, uint32_t em, u
CHECK_UARCH(arch, 0, 6, 10, 5, NA, "Comet Lake", UARCH_COMET_LAKE, 14) // wikichip
CHECK_UARCH(arch, 0, 6, 10, 6, NA, "Comet Lake", UARCH_COMET_LAKE, 14) // instlatx64.atw.hu (i7-10710U)
CHECK_UARCH(arch, 0, 6, 10, 7, NA, "Rocket Lake", UARCH_ROCKET_LAKE, 14) // instlatx64.atw.hu (i7-11700K)
CHECK_UARCH(arch, 0, 6, 10, 10, NA, "Meteor Lake", UARCH_METEOR_LAKE, 7) // instlatx64.atw.hu (Ultra 7 155H)
CHECK_UARCH(arch, 0, 6, 11, 7, NA, "Raptor Lake", UARCH_RAPTOR_LAKE, 10) // instlatx64.atw.hu (i5-13600K)
CHECK_UARCH(arch, 0, 6, 11, 10, NA, "Raptor Lake", UARCH_RAPTOR_LAKE, 10) // instlatx64.atw.hu (i7-1370P)
CHECK_UARCH(arch, 0, 6, 11, 14, NA, "Alder Lake", UARCH_ALDER_LAKE, 10) // instlatx64.atw.hu (Alder Lake-N)
@@ -536,6 +538,7 @@ int get_number_of_vpus(struct cpuInfo* cpu) {
case UARCH_TIGER_LAKE:
case UARCH_ALDER_LAKE:
case UARCH_RAPTOR_LAKE:
case UARCH_METEOR_LAKE:
// AMD
case UARCH_ZEN2:
@@ -549,6 +552,11 @@ int get_number_of_vpus(struct cpuInfo* cpu) {
}
}
uint32_t get_hybrid_num_cpus(struct uarch* arch) {
if (arch->uarch == UARCH_METEOR_LAKE) return 3;
else return 2;
}
bool choose_new_intel_logo_uarch(struct cpuInfo* cpu) {
switch(cpu->arch->uarch) {
case UARCH_ALDER_LAKE:

View File

@@ -12,6 +12,7 @@ char* infer_cpu_name_from_uarch(struct uarch* arch);
bool vpus_are_AVX512(struct cpuInfo* cpu);
bool is_knights_landing(struct cpuInfo* cpu);
int get_number_of_vpus(struct cpuInfo* cpu);
uint32_t get_hybrid_num_cpus(struct uarch* arch);
bool choose_new_intel_logo_uarch(struct cpuInfo* cpu);
char* get_str_uarch(struct cpuInfo* cpu);
char* get_str_process(struct cpuInfo* cpu);