diff --git a/CMakeLists.txt b/CMakeLists.txt index f15affd..57150dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/src/common/printer.cpp b/src/common/printer.cpp index a58181b..7612191 100644 --- a/src/common/printer.cpp +++ b/src/common/printer.cpp @@ -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); diff --git a/src/common/uarch.cpp b/src/common/uarch.cpp new file mode 100644 index 0000000..1549fa0 --- /dev/null +++ b/src/common/uarch.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +#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; +} + diff --git a/src/common/uarch.hpp b/src/common/uarch.hpp index 98efa50..fd253f1 100644 --- a/src/common/uarch.hpp +++ b/src/common/uarch.hpp @@ -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; diff --git a/src/cuda/uarch.cpp b/src/cuda/uarch.cpp index b0aeea1..20268d6 100644 --- a/src/cuda/uarch.cpp +++ b/src/cuda/uarch.cpp @@ -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; } diff --git a/src/intel/uarch.cpp b/src/intel/uarch.cpp index dd12ecf..7f5512c 100644 --- a/src/intel/uarch.cpp +++ b/src/intel/uarch.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #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; } diff --git a/src/intel/uarch.hpp b/src/intel/uarch.hpp index 5b6dbdd..e368227 100644 --- a/src/intel/uarch.hpp +++ b/src/intel/uarch.hpp @@ -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