[v0.11] Print available more information for iGPU

This commit is contained in:
Dr-Noob
2021-11-27 11:22:16 +01:00
parent 8db60b614d
commit b00050e739
7 changed files with 49 additions and 29 deletions

View File

@@ -47,7 +47,7 @@ else()
link_libraries(${PCIUTILS_LIBRARIES})
endif()
add_executable(gpufetch ${COMMON_DIR}/main.cpp ${COMMON_DIR}/args.cpp ${COMMON_DIR}/gpu.cpp ${COMMON_DIR}/pci.cpp ${COMMON_DIR}/global.cpp ${COMMON_DIR}/printer.cpp ${COMMON_DIR}/master.cpp)
add_executable(gpufetch ${COMMON_DIR}/main.cpp ${COMMON_DIR}/args.cpp ${COMMON_DIR}/gpu.cpp ${COMMON_DIR}/pci.cpp ${COMMON_DIR}/global.cpp ${COMMON_DIR}/printer.cpp ${COMMON_DIR}/master.cpp ${COMMON_DIR}/uarch.cpp)
set(SANITY_FLAGS "-Wfloat-equal -Wshadow -Wpointer-arith")
set(CMAKE_CXX_FLAGS "${SANITY_FLAGS} -Wall -Wextra -pedantic -fstack-protector-all -pedantic")

View File

@@ -359,7 +359,12 @@ bool print_gpufetch_intel(struct gpu_info* gpu, STYLE s, struct color** cs, stru
return false;
char* gpu_name = get_str_gpu_name(gpu);
char* uarch = get_str_uarch(gpu->arch);
char* manufacturing_process = get_str_process(gpu->arch);
setAttribute(art, ATTRIBUTE_NAME, gpu_name);
setAttribute(art, ATTRIBUTE_UARCH, uarch);
setAttribute(art, ATTRIBUTE_TECHNOLOGY, manufacturing_process);
const char** attribute_fields = ATTRIBUTE_FIELDS;
uint32_t longest_attribute = longest_attribute_length(art, attribute_fields);

28
src/common/uarch.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "global.hpp"
#include "uarch.hpp"
char* get_str_process(struct uarch* arch) {
char* str = (char *) emalloc(sizeof(char) * (strlen(STRING_UNKNOWN)+1));
int32_t process = arch->process;
if(process == UNK) {
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
}
else if(process > 100) {
sprintf(str, "%.2fum", (double)process/100);
}
else if(process > 0){
sprintf(str, "%dnm", process);
}
else {
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
printBug("Found invalid process: '%d'", process);
}
return str;
}

View File

@@ -1,6 +1,12 @@
#ifndef __COMMON_UARCH__
#define __COMMON_UARCH__
// Data not available
#define NA -1
// Unknown manufacturing process
#define UNK -1
typedef uint32_t GPUCHIP;
typedef uint32_t MICROARCH;

View File

@@ -11,12 +11,6 @@
// Any clock multiplier
#define CM_ANY -1
// Data not available
#define NA -1
// Unknown manufacturing process
#define UNK -1
// MICROARCH values
enum {
UARCH_UNKNOWN,
@@ -332,27 +326,6 @@ char* get_str_cc(struct uarch* arch) {
return cc;
}
char* get_str_process(struct uarch* arch) {
char* str = (char *) emalloc(sizeof(char) * (strlen(STRING_UNKNOWN)+1));
int32_t process = arch->process;
if(process == UNK) {
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
}
else if(process > 100) {
sprintf(str, "%.2fum", (double)process/100);
}
else if(process > 0){
sprintf(str, "%dnm", process);
}
else {
snprintf(str, strlen(STRING_UNKNOWN)+1, STRING_UNKNOWN);
printBug("Found invalid process: '%d'", process);
}
return str;
}
char* get_str_chip(struct uarch* arch) {
return arch->chip_str;
}

View File

@@ -1,6 +1,7 @@
#include <stdint.h>
#include <cstddef>
#include <string.h>
#include <stdio.h>
#include "../common/uarch.hpp"
#include "../common/global.hpp"
@@ -60,6 +61,10 @@ void map_chip_to_uarch(struct uarch* arch) {
CHECK_UARCH_END
}
const char* get_str_uarch(struct uarch* arch) {
return uarch_str[arch->uarch];
}
struct uarch* get_uarch_from_pci(struct pci* pci) {
struct uarch* arch = (struct uarch*) emalloc(sizeof(struct uarch));
@@ -71,5 +76,7 @@ struct uarch* get_uarch_from_pci(struct pci* pci) {
}
char* get_name_from_uarch(struct uarch* arch) {
return arch->chip_str;
char* name = (char *) emalloc(sizeof(char) * (strlen(arch->chip_str) + 6 + 1));
sprintf(name, "Intel %s", arch->chip_str);
return name;
}

View File

@@ -7,5 +7,6 @@ struct uarch;
struct uarch* get_uarch_from_pci(struct pci* pci);
char* get_name_from_uarch(struct uarch* arch);
const char* get_str_uarch(struct uarch* arch);
#endif