Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f196c1797 | ||
|
|
312d78b7f1 | ||
|
|
ebad29e044 | ||
|
|
59df3e53ec | ||
|
|
d120f9a1cd |
@@ -45,6 +45,8 @@ if(NOT ${PCIUTILS_FOUND})
|
||||
else()
|
||||
include_directories(${PCIUTILS_INCLUDE_DIR})
|
||||
link_libraries(${PCIUTILS_LIBRARIES})
|
||||
# Needed for linking libpci in FreeBSD
|
||||
link_directories(/usr/local/lib/)
|
||||
endif()
|
||||
|
||||
add_executable(gpufetch ${COMMON_DIR}/main.cpp ${COMMON_DIR}/args.cpp ${COMMON_DIR}/gpu.cpp ${COMMON_DIR}/pci.cpp ${COMMON_DIR}/sort.cpp ${COMMON_DIR}/global.cpp ${COMMON_DIR}/printer.cpp ${COMMON_DIR}/master.cpp ${COMMON_DIR}/uarch.cpp)
|
||||
@@ -68,8 +70,10 @@ if(ENABLE_CUDA_BACKEND)
|
||||
|
||||
# https://en.wikipedia.org/w/index.php?title=CUDA§ion=5#GPUs_supported
|
||||
# https://raw.githubusercontent.com/PointCloudLibrary/pcl/master/cmake/pcl_find_cuda.cmake
|
||||
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.0")
|
||||
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.1")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 35 37 50 52 53 60 61 62 70 72 75 80 86)
|
||||
elseif(${CMAKE_CUDA_COMPILER_VERSION} EQUAL "11.0")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30 32 35 37 50 52 53 60 61 62 70 72 75 80)
|
||||
elseif(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL "10.0")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30 32 35 37 50 52 53 60 61 62 70 72 75)
|
||||
elseif(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL "9.0")
|
||||
@@ -78,13 +82,21 @@ if(ENABLE_CUDA_BACKEND)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 20 21 30 32 35 37 50 52 53 60 61 62)
|
||||
endif()
|
||||
|
||||
# https://docs.nvidia.com/cuda/cuda-samples/index.html#new-features-in-cuda-toolkit-11-6
|
||||
# Not sure about this. Why the heck did they change this?
|
||||
if(${CMAKE_CUDA_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.6")
|
||||
set(CUDA_SAMPLES_PATH ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/samples/Common)
|
||||
else()
|
||||
set(CUDA_SAMPLES_PATH ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/samples/common/inc)
|
||||
endif()
|
||||
|
||||
add_library(cuda_backend STATIC ${CUDA_DIR}/cuda.cpp ${CUDA_DIR}/uarch.cpp ${CUDA_DIR}/pci.cpp)
|
||||
|
||||
if(NOT ${PCIUTILS_FOUND})
|
||||
add_dependencies(cuda_backend pciutils)
|
||||
endif()
|
||||
|
||||
target_include_directories(cuda_backend PUBLIC ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/samples/common/inc ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/targets/x86_64-linux/include)
|
||||
target_include_directories(cuda_backend PUBLIC ${CUDA_SAMPLES_PATH} ${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/targets/x86_64-linux/include)
|
||||
|
||||
target_link_libraries(cuda_backend PRIVATE cudart)
|
||||
target_link_libraries(gpufetch cuda_backend)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<p align="center"> </p>
|
||||
|
||||
<p align="center">
|
||||
gpufetch is a command-line tool written in C that displays the GPU information in a clean and beautiful way
|
||||
gpufetch is a command-line tool written in C++ that displays the GPU information in a clean and beautiful way
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
||||
9
build.sh
9
build.sh
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# gpufetch build script
|
||||
set -e
|
||||
@@ -27,6 +27,13 @@ fi
|
||||
# cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_INTEL_BACKEND=OFF ..
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..
|
||||
|
||||
os=$(uname)
|
||||
if [ "$os" == 'Linux' ]; then
|
||||
make -j$(nproc)
|
||||
elif [ "$os" == 'FreeBSD' ]; then
|
||||
gmake -j4
|
||||
fi
|
||||
|
||||
cd -
|
||||
ln -s build/gpufetch .
|
||||
|
||||
@@ -26,6 +26,8 @@ struct args_struct {
|
||||
bool verbose_flag;
|
||||
bool version_flag;
|
||||
bool list_gpus;
|
||||
bool logo_long;
|
||||
bool logo_short;
|
||||
int gpu_idx;
|
||||
STYLE style;
|
||||
struct color** colors;
|
||||
@@ -38,6 +40,8 @@ const char args_chr[] = {
|
||||
/* [ARG_COLOR] = */ 'c',
|
||||
/* [ARG_GPU] = */ 'g',
|
||||
/* [ARG_LIST] = */ 'l',
|
||||
/* [ARG_LOGO_LONG] = */ 1,
|
||||
/* [ARG_LOGO_SHORT] = */ 2,
|
||||
/* [ARG_HELP] = */ 'h',
|
||||
/* [ARG_VERBOSE] = */ 'v',
|
||||
/* [ARG_VERSION] = */ 'V',
|
||||
@@ -47,6 +51,8 @@ const char *args_str[] = {
|
||||
/* [ARG_COLOR] = */ "color",
|
||||
/* [ARG_GPU] = */ "gpu",
|
||||
/* [ARG_LIST] = */ "list-gpus",
|
||||
/* [ARG_LOGO_LONG] = */ "logo-long",
|
||||
/* [ARG_LOGO_SHORT] = */ "logo-short",
|
||||
/* [ARG_HELP] = */ "help",
|
||||
/* [ARG_VERBOSE] = */ "verbose",
|
||||
/* [ARG_VERSION] = */ "version",
|
||||
@@ -111,6 +117,14 @@ bool list_gpus() {
|
||||
return args.list_gpus;
|
||||
}
|
||||
|
||||
bool show_logo_long() {
|
||||
return args.logo_long;
|
||||
}
|
||||
|
||||
bool show_logo_short() {
|
||||
return args.logo_short;
|
||||
}
|
||||
|
||||
bool show_version() {
|
||||
return args.version_flag;
|
||||
}
|
||||
@@ -134,8 +148,9 @@ char* build_short_options() {
|
||||
char* str = (char *) emalloc(sizeof(char) * (len*2 + 1));
|
||||
memset(str, 0, sizeof(char) * (len*2 + 1));
|
||||
|
||||
sprintf(str, "%c:%c:%c%c%c%c", c[ARG_GPU],
|
||||
sprintf(str, "%c:%c:%c%c%c%c%c%c", c[ARG_GPU],
|
||||
c[ARG_COLOR], c[ARG_HELP], c[ARG_LIST],
|
||||
c[ARG_LOGO_SHORT], c[ARG_LOGO_LONG],
|
||||
c[ARG_VERBOSE], c[ARG_VERSION]);
|
||||
|
||||
return str;
|
||||
@@ -203,6 +218,8 @@ bool parse_args(int argc, char* argv[]) {
|
||||
args.version_flag = false;
|
||||
args.help_flag = false;
|
||||
args.list_gpus = false;
|
||||
args.logo_long = false;
|
||||
args.logo_short = false;
|
||||
args.gpu_idx = 0;
|
||||
args.colors = NULL;
|
||||
|
||||
@@ -210,6 +227,8 @@ bool parse_args(int argc, char* argv[]) {
|
||||
{args_str[ARG_COLOR], required_argument, 0, args_chr[ARG_COLOR] },
|
||||
{args_str[ARG_GPU], required_argument, 0, args_chr[ARG_GPU] },
|
||||
{args_str[ARG_LIST], no_argument, 0, args_chr[ARG_LIST] },
|
||||
{args_str[ARG_LOGO_SHORT], no_argument, 0, args_chr[ARG_LOGO_SHORT] },
|
||||
{args_str[ARG_LOGO_LONG], no_argument, 0, args_chr[ARG_LOGO_LONG] },
|
||||
{args_str[ARG_HELP], no_argument, 0, args_chr[ARG_HELP] },
|
||||
{args_str[ARG_VERBOSE], no_argument, 0, args_chr[ARG_VERBOSE] },
|
||||
{args_str[ARG_VERSION], no_argument, 0, args_chr[ARG_VERSION] },
|
||||
@@ -237,6 +256,12 @@ bool parse_args(int argc, char* argv[]) {
|
||||
else if(opt == args_chr[ARG_LIST]) {
|
||||
args.list_gpus = true;
|
||||
}
|
||||
else if(opt == args_chr[ARG_LOGO_SHORT]) {
|
||||
args.logo_short = true;
|
||||
}
|
||||
else if(opt == args_chr[ARG_LOGO_LONG]) {
|
||||
args.logo_long = true;
|
||||
}
|
||||
else if(opt == args_chr[ARG_HELP]) {
|
||||
args.help_flag = true;
|
||||
}
|
||||
@@ -260,6 +285,12 @@ bool parse_args(int argc, char* argv[]) {
|
||||
args.help_flag = true;
|
||||
}
|
||||
|
||||
if(args.logo_short && args.logo_long) {
|
||||
printWarn("%s and %s cannot be specified together", args_str[ARG_LOGO_SHORT], args_str[ARG_LOGO_LONG]);
|
||||
args.logo_short = false;
|
||||
args.logo_long = false;
|
||||
}
|
||||
|
||||
if((args.help_flag + args.version_flag) > 1) {
|
||||
printWarn("You should specify just one option");
|
||||
args.help_flag = true;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef __ARGS__
|
||||
#define __ARGS__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct color {
|
||||
int32_t R;
|
||||
int32_t G;
|
||||
@@ -20,6 +22,8 @@ enum {
|
||||
ARG_COLOR,
|
||||
ARG_GPU,
|
||||
ARG_LIST,
|
||||
ARG_LOGO_LONG,
|
||||
ARG_LOGO_SHORT,
|
||||
ARG_HELP,
|
||||
ARG_VERBOSE,
|
||||
ARG_VERSION
|
||||
@@ -34,6 +38,8 @@ int max_arg_str_length();
|
||||
bool parse_args(int argc, char* argv[]);
|
||||
bool show_help();
|
||||
bool list_gpus();
|
||||
bool show_logo_long();
|
||||
bool show_logo_short();
|
||||
bool show_version();
|
||||
bool verbose_enabled();
|
||||
void free_colors_struct(struct color** cs);
|
||||
|
||||
@@ -22,6 +22,8 @@ void print_help(char *argv[]) {
|
||||
printf(" -%c, --%s %*s Set the color scheme (by default, gpufetch uses the system color scheme) See COLORS section for a more detailed explanation\n", c[ARG_COLOR], t[ARG_COLOR], (int) (max_len-strlen(t[ARG_COLOR])), "");
|
||||
printf(" -%c, --%s %*s List the available GPUs in the system\n", c[ARG_LIST], t[ARG_LIST], (int) (max_len-strlen(t[ARG_LIST])), "");
|
||||
printf(" -%c, --%s %*s Select the GPU to use (default: 0)\n", c[ARG_GPU], t[ARG_GPU], (int) (max_len-strlen(t[ARG_GPU])), "");
|
||||
printf(" --%s %*s Show the short version of the logo\n", t[ARG_LOGO_SHORT], (int) (max_len-strlen(t[ARG_LOGO_SHORT])), "");
|
||||
printf(" --%s %*s Show the long version of the logo\n", t[ARG_LOGO_LONG], (int) (max_len-strlen(t[ARG_LOGO_LONG])), "");
|
||||
printf(" -%c, --%s %*s Enable verbose output\n", c[ARG_VERBOSE], t[ARG_VERBOSE], (int) (max_len-strlen(t[ARG_VERBOSE])), "");
|
||||
printf(" -%c, --%s %*s Print this help and exit\n", c[ARG_HELP], t[ARG_HELP], (int) (max_len-strlen(t[ARG_HELP])), "");
|
||||
printf(" -%c, --%s %*s Print gpufetch version and exit\n", c[ARG_VERSION], t[ARG_VERSION], (int) (max_len-strlen(t[ARG_VERSION])), "");
|
||||
|
||||
@@ -219,6 +219,8 @@ void replace_bgbyfg_color(struct ascii_logo* logo) {
|
||||
}
|
||||
|
||||
struct ascii_logo* choose_ascii_art_aux(struct ascii_logo* logo_long, struct ascii_logo* logo_short, struct terminal* term, int lf) {
|
||||
if(show_logo_long()) return logo_long;
|
||||
if(show_logo_short()) return logo_short;
|
||||
if(ascii_fits_screen(term->w, *logo_long, lf)) {
|
||||
return logo_long;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ static const char *uarch_str[] = {
|
||||
/*[ARCH_GEN9] = */ "Gen9",
|
||||
/*[ARCH_GEN9_5] = */ "Gen9.5",
|
||||
/*[ARCH_GEN11] = */ "Gen11",
|
||||
/*[ARCH_GEN12_RKL] = */ "Gen12"
|
||||
/*[ARCH_GEN12_RKL] = */ "Gen12",
|
||||
/*[ARCH_GEN12_TGL] = */ "Gen12"
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user