mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-29 22:51:35 +02:00
Added definition GPU_SUPPORT to toggle GPU related code
This commit is contained in:
parent
975525d38f
commit
b87772611c
14
Makefile
14
Makefile
@ -36,6 +36,17 @@ endif
|
|||||||
|
|
||||||
override PLATFORM_LC := $(shell echo $(PLATFORM) | tr '[:upper:]' '[:lower:]')
|
override PLATFORM_LC := $(shell echo $(PLATFORM) | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
#? GPU Support
|
||||||
|
ifeq ($(PLATFORM_LC)$(ARCH),linuxx86_64)
|
||||||
|
GPU_SUPPORT := true
|
||||||
|
else
|
||||||
|
GPU_SUPPORT := false
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(GPU_SUPPORT),true)
|
||||||
|
override ADDFLAGS += -DGPU_SUPPORT
|
||||||
|
endif
|
||||||
|
|
||||||
#? Compiler and Linker
|
#? Compiler and Linker
|
||||||
ifeq ($(shell $(CXX) --version | grep clang >/dev/null 2>&1; echo $$?),0)
|
ifeq ($(shell $(CXX) --version | grep clang >/dev/null 2>&1; echo $$?),0)
|
||||||
override CXX_IS_CLANG := true
|
override CXX_IS_CLANG := true
|
||||||
@ -218,6 +229,7 @@ info:
|
|||||||
@printf " $(BANNER)\n"
|
@printf " $(BANNER)\n"
|
||||||
@printf "\033[1;92mPLATFORM \033[1;93m?| \033[0m$(PLATFORM)\n"
|
@printf "\033[1;92mPLATFORM \033[1;93m?| \033[0m$(PLATFORM)\n"
|
||||||
@printf "\033[1;96mARCH \033[1;93m?| \033[0m$(ARCH)\n"
|
@printf "\033[1;96mARCH \033[1;93m?| \033[0m$(ARCH)\n"
|
||||||
|
@printf "\033[1;95mGPU_SUPPORT \033[1;94m:| \033[0m$(GPU_SUPPORT)\n"
|
||||||
@printf "\033[1;93mCXX \033[1;93m?| \033[0m$(CXX) \033[1;93m(\033[97m$(CXX_VERSION)\033[93m)\n"
|
@printf "\033[1;93mCXX \033[1;93m?| \033[0m$(CXX) \033[1;93m(\033[97m$(CXX_VERSION)\033[93m)\n"
|
||||||
@printf "\033[1;94mTHREADS \033[1;94m:| \033[0m$(THREADS)\n"
|
@printf "\033[1;94mTHREADS \033[1;94m:| \033[0m$(THREADS)\n"
|
||||||
@printf "\033[1;92mREQFLAGS \033[1;91m!| \033[0m$(REQFLAGS)\n"
|
@printf "\033[1;92mREQFLAGS \033[1;91m!| \033[0m$(REQFLAGS)\n"
|
||||||
@ -310,7 +322,7 @@ uninstall:
|
|||||||
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
|
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
|
||||||
|
|
||||||
#? Compile rocm_smi
|
#? Compile rocm_smi
|
||||||
ifeq ($(RSMI_STATIC)$(PLATFORM_LC),truelinux)
|
ifeq ($(GPU_SUPPORT)$(RSMI_STATIC),truetrue)
|
||||||
.ONESHELL:
|
.ONESHELL:
|
||||||
rocm_smi:
|
rocm_smi:
|
||||||
@printf "\n\033[1;92mBuilding ROCm SMI static library\033[37m...\033[0m\n"
|
@printf "\n\033[1;92mBuilding ROCm SMI static library\033[37m...\033[0m\n"
|
||||||
|
31
src/btop.cpp
31
src/btop.cpp
@ -183,8 +183,11 @@ void term_resize(bool force) {
|
|||||||
if (force and refreshed) force = false;
|
if (force and refreshed) force = false;
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
static const array<string, 10> all_boxes = {"gpu5", "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4"};
|
static const array<string, 10> all_boxes = {"gpu5", "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4"};
|
||||||
|
#else
|
||||||
|
static const array<string, 5> all_boxes = {"", "cpu", "mem", "net", "proc"};
|
||||||
|
#endif
|
||||||
Global::resized = true;
|
Global::resized = true;
|
||||||
if (Runner::active) Runner::stop();
|
if (Runner::active) Runner::stop();
|
||||||
Term::refresh();
|
Term::refresh();
|
||||||
@ -224,8 +227,12 @@ void term_resize(bool force) {
|
|||||||
clean_quit(0);
|
clean_quit(0);
|
||||||
else if (key.size() == 1 and isint(key)) {
|
else if (key.size() == 1 and isint(key)) {
|
||||||
auto intKey = stoi(key);
|
auto intKey = stoi(key);
|
||||||
auto box = all_boxes.at(intKey);
|
#ifdef GPU_SUPPORT
|
||||||
if (not box.starts_with("gpu") or (intKey == 0 and Gpu::gpu_names.size() >= 5) or (intKey >= 5 and std::cmp_greater_equal(Gpu::gpu_names.size(), intKey - 4))) {
|
if ((intKey == 0 and Gpu::gpu_names.size() >= 5) or (intKey >= 5 and std::cmp_greater_equal(Gpu::gpu_names.size(), intKey - 4))) {
|
||||||
|
#else
|
||||||
|
if (intKey > 0 and intKey < 5) {
|
||||||
|
#endif
|
||||||
|
auto box = all_boxes.at(intKey);
|
||||||
Config::current_preset = -1;
|
Config::current_preset = -1;
|
||||||
Config::toggle_box(box);
|
Config::toggle_box(box);
|
||||||
boxes = Config::getS("shown_boxes");
|
boxes = Config::getS("shown_boxes");
|
||||||
@ -262,7 +269,7 @@ void clean_quit(int sig) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef GPU_SUPPORT
|
||||||
Gpu::Nvml::shutdown();
|
Gpu::Nvml::shutdown();
|
||||||
Gpu::Rsmi::shutdown();
|
Gpu::Rsmi::shutdown();
|
||||||
#endif
|
#endif
|
||||||
@ -499,7 +506,13 @@ namespace Runner {
|
|||||||
//! DEBUG stats
|
//! DEBUG stats
|
||||||
if (Global::debug) {
|
if (Global::debug) {
|
||||||
if (debug_bg.empty() or redraw)
|
if (debug_bg.empty() or redraw)
|
||||||
Runner::debug_bg = Draw::createBox(2, 2, 33, 9, "", true, "μs");
|
Runner::debug_bg = Draw::createBox(2, 2, 33,
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
|
9,
|
||||||
|
#else
|
||||||
|
8,
|
||||||
|
#endif
|
||||||
|
"", true, "μs");
|
||||||
|
|
||||||
debug_times.clear();
|
debug_times.clear();
|
||||||
debug_times["total"] = {0, 0};
|
debug_times["total"] = {0, 0};
|
||||||
@ -509,7 +522,7 @@ namespace Runner {
|
|||||||
|
|
||||||
//* Run collection and draw functions for all boxes
|
//* Run collection and draw functions for all boxes
|
||||||
try {
|
try {
|
||||||
#ifdef __linux__
|
#ifdef GPU_SUPPORT
|
||||||
//? GPU data collection
|
//? GPU data collection
|
||||||
const bool gpu_in_cpu_panel = Gpu::gpu_names.size() > 0 and (
|
const bool gpu_in_cpu_panel = Gpu::gpu_names.size() > 0 and (
|
||||||
Config::getS("cpu_graph_lower").starts_with("gpu-") or Config::getS("cpu_graph_upper").starts_with("gpu-")
|
Config::getS("cpu_graph_lower").starts_with("gpu-") or Config::getS("cpu_graph_upper").starts_with("gpu-")
|
||||||
@ -559,7 +572,7 @@ namespace Runner {
|
|||||||
throw std::runtime_error("Cpu:: -> " + string{e.what()});
|
throw std::runtime_error("Cpu:: -> " + string{e.what()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef __linux__
|
#ifdef GPU_SUPPORT
|
||||||
//? GPU
|
//? GPU
|
||||||
if (not gpu_panels.empty() and not gpus_ref.empty()) {
|
if (not gpu_panels.empty() and not gpus_ref.empty()) {
|
||||||
try {
|
try {
|
||||||
@ -693,7 +706,11 @@ namespace Runner {
|
|||||||
"post"_a = Theme::c("main_fg") + Fx::ub
|
"post"_a = Theme::c("main_fg") + Fx::ub
|
||||||
);
|
);
|
||||||
static auto loc = std::locale(std::locale::classic(), new MyNumPunct);
|
static auto loc = std::locale(std::locale::classic(), new MyNumPunct);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
for (const string name : {"cpu", "mem", "net", "proc", "gpu", "total"}) {
|
for (const string name : {"cpu", "mem", "net", "proc", "gpu", "total"}) {
|
||||||
|
#else
|
||||||
|
for (const string name : {"cpu", "mem", "net", "proc", "total"}) {
|
||||||
|
#endif
|
||||||
if (not debug_times.contains(name)) debug_times[name] = {0,0};
|
if (not debug_times.contains(name)) debug_times[name] = {0,0};
|
||||||
const auto& [time_collect, time_draw] = debug_times.at(name);
|
const auto& [time_collect, time_draw] = debug_times.at(name);
|
||||||
if (name == "total") output += Fx::b;
|
if (name == "total") output += Fx::b;
|
||||||
|
@ -73,9 +73,9 @@ namespace Config {
|
|||||||
"#* Note that \"tty\" only has half the horizontal resolution of the other two, so will show a shorter historical view."},
|
"#* Note that \"tty\" only has half the horizontal resolution of the other two, so will show a shorter historical view."},
|
||||||
|
|
||||||
{"graph_symbol_cpu", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
{"graph_symbol_cpu", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
{"graph_symbol_gpu", "# Graph symbol to use for graphs in gpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
{"graph_symbol_gpu", "# Graph symbol to use for graphs in gpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
||||||
|
#endif
|
||||||
{"graph_symbol_mem", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
{"graph_symbol_mem", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
||||||
|
|
||||||
{"graph_symbol_net", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
{"graph_symbol_net", "# Graph symbol to use for graphs in cpu box, \"default\", \"braille\", \"block\" or \"tty\"."},
|
||||||
@ -114,9 +114,9 @@ namespace Config {
|
|||||||
|
|
||||||
{"cpu_graph_lower", "#* Sets the CPU stat shown in lower half of the CPU graph, \"total\" is always available.\n"
|
{"cpu_graph_lower", "#* Sets the CPU stat shown in lower half of the CPU graph, \"total\" is always available.\n"
|
||||||
"#* Select from a list of detected attributes from the options menu."},
|
"#* Select from a list of detected attributes from the options menu."},
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
{"show_gpu_info", "#* If gpu info should be shown in the cpu box. Available values = \"Auto\", \"On\" and \"Off\"."},
|
{"show_gpu_info", "#* If gpu info should be shown in the cpu box. Available values = \"Auto\", \"On\" and \"Off\"."},
|
||||||
|
#endif
|
||||||
{"cpu_invert_lower", "#* Toggles if the lower CPU graph should be inverted."},
|
{"cpu_invert_lower", "#* Toggles if the lower CPU graph should be inverted."},
|
||||||
|
|
||||||
{"cpu_single_graph", "#* Set to True to completely disable the lower CPU graph."},
|
{"cpu_single_graph", "#* Set to True to completely disable the lower CPU graph."},
|
||||||
@ -197,6 +197,7 @@ namespace Config {
|
|||||||
|
|
||||||
{"log_level", "#* Set loglevel for \"~/.config/btop/btop.log\" levels are: \"ERROR\" \"WARNING\" \"INFO\" \"DEBUG\".\n"
|
{"log_level", "#* Set loglevel for \"~/.config/btop/btop.log\" levels are: \"ERROR\" \"WARNING\" \"INFO\" \"DEBUG\".\n"
|
||||||
"#* The level set includes all lower levels, i.e. \"DEBUG\" will show all logging info."},
|
"#* The level set includes all lower levels, i.e. \"DEBUG\" will show all logging info."},
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
|
|
||||||
{"nvml_measure_pcie_speeds",
|
{"nvml_measure_pcie_speeds",
|
||||||
"#* Measure PCIe throughput on NVIDIA cards, may impact performance on certain cards."},
|
"#* Measure PCIe throughput on NVIDIA cards, may impact performance on certain cards."},
|
||||||
@ -209,6 +210,7 @@ namespace Config {
|
|||||||
{"custom_gpu_name3", "#* Custom gpu3 model name, empty string to disable."},
|
{"custom_gpu_name3", "#* Custom gpu3 model name, empty string to disable."},
|
||||||
{"custom_gpu_name4", "#* Custom gpu4 model name, empty string to disable."},
|
{"custom_gpu_name4", "#* Custom gpu4 model name, empty string to disable."},
|
||||||
{"custom_gpu_name5", "#* Custom gpu5 model name, empty string to disable."},
|
{"custom_gpu_name5", "#* Custom gpu5 model name, empty string to disable."},
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
unordered_flat_map<std::string_view, string> strings = {
|
unordered_flat_map<std::string_view, string> strings = {
|
||||||
@ -237,6 +239,7 @@ namespace Config {
|
|||||||
{"proc_filter", ""},
|
{"proc_filter", ""},
|
||||||
{"proc_command", ""},
|
{"proc_command", ""},
|
||||||
{"selected_name", ""},
|
{"selected_name", ""},
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
{"custom_gpu_name0", ""},
|
{"custom_gpu_name0", ""},
|
||||||
{"custom_gpu_name1", ""},
|
{"custom_gpu_name1", ""},
|
||||||
{"custom_gpu_name2", ""},
|
{"custom_gpu_name2", ""},
|
||||||
@ -244,6 +247,7 @@ namespace Config {
|
|||||||
{"custom_gpu_name4", ""},
|
{"custom_gpu_name4", ""},
|
||||||
{"custom_gpu_name5", ""},
|
{"custom_gpu_name5", ""},
|
||||||
{"show_gpu_info", "Auto"}
|
{"show_gpu_info", "Auto"}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
unordered_flat_map<std::string_view, string> stringsTmp;
|
unordered_flat_map<std::string_view, string> stringsTmp;
|
||||||
|
|
||||||
@ -292,8 +296,10 @@ namespace Config {
|
|||||||
{"lowcolor", false},
|
{"lowcolor", false},
|
||||||
{"show_detailed", false},
|
{"show_detailed", false},
|
||||||
{"proc_filtering", false},
|
{"proc_filtering", false},
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
{"nvml_measure_pcie_speeds", true},
|
{"nvml_measure_pcie_speeds", true},
|
||||||
{"gpu_mirror_graph", true},
|
{"gpu_mirror_graph", true},
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
unordered_flat_map<std::string_view, bool> boolsTmp;
|
unordered_flat_map<std::string_view, bool> boolsTmp;
|
||||||
|
|
||||||
@ -440,8 +446,10 @@ namespace Config {
|
|||||||
else if (name == "shown_boxes" and not value.empty() and not check_boxes(value))
|
else if (name == "shown_boxes" and not value.empty() and not check_boxes(value))
|
||||||
validError = "Invalid box name(s) in shown_boxes!";
|
validError = "Invalid box name(s) in shown_boxes!";
|
||||||
|
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
else if (name == "show_gpu_info" and not v_contains(show_gpu_values, value))
|
else if (name == "show_gpu_info" and not v_contains(show_gpu_values, value))
|
||||||
validError = "Invalid value for show_gpu_info: " + value;
|
validError = "Invalid value for show_gpu_info: " + value;
|
||||||
|
#endif
|
||||||
|
|
||||||
else if (name == "presets" and not presetsValid(value))
|
else if (name == "presets" and not presetsValid(value))
|
||||||
return false;
|
return false;
|
||||||
@ -545,11 +553,13 @@ namespace Config {
|
|||||||
auto new_boxes = ssplit(boxes);
|
auto new_boxes = ssplit(boxes);
|
||||||
for (auto& box : new_boxes) {
|
for (auto& box : new_boxes) {
|
||||||
if (not v_contains(valid_boxes, box)) return false;
|
if (not v_contains(valid_boxes, box)) return false;
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
if (box.starts_with("gpu")) {
|
if (box.starts_with("gpu")) {
|
||||||
size_t gpu_num = stoi(box.substr(3));
|
size_t gpu_num = stoi(box.substr(3));
|
||||||
if (gpu_num == 0) gpu_num = 5;
|
if (gpu_num == 0) gpu_num = 5;
|
||||||
if (std::cmp_greater(gpu_num, Gpu::gpu_names.size())) return false;
|
if (std::cmp_greater(gpu_num, Gpu::gpu_names.size())) return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
current_boxes = std::move(new_boxes);
|
current_boxes = std::move(new_boxes);
|
||||||
return true;
|
return true;
|
||||||
|
@ -43,10 +43,16 @@ namespace Config {
|
|||||||
|
|
||||||
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
|
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
|
||||||
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
|
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
|
||||||
const vector<string> valid_boxes = { "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4", "gpu5" };
|
const vector<string> valid_boxes = {
|
||||||
|
"cpu", "mem", "net", "proc"
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
|
,"gpu0", "gpu1", "gpu2", "gpu3", "gpu4", "gpu5"
|
||||||
|
#endif
|
||||||
|
};
|
||||||
const vector<string> temp_scales = { "celsius", "fahrenheit", "kelvin", "rankine" };
|
const vector<string> temp_scales = { "celsius", "fahrenheit", "kelvin", "rankine" };
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
const vector<string> show_gpu_values = { "Auto", "On", "Off" };
|
const vector<string> show_gpu_values = { "Auto", "On", "Off" };
|
||||||
|
#endif
|
||||||
extern vector<string> current_boxes;
|
extern vector<string> current_boxes;
|
||||||
extern vector<string> preset_list;
|
extern vector<string> preset_list;
|
||||||
extern vector<string> available_batteries;
|
extern vector<string> available_batteries;
|
||||||
|
@ -533,15 +533,23 @@ namespace Cpu {
|
|||||||
auto single_graph = Config::getB("cpu_single_graph");
|
auto single_graph = Config::getB("cpu_single_graph");
|
||||||
bool hide_cores = show_temps and (cpu_temp_only or not Config::getB("show_coretemp"));
|
bool hide_cores = show_temps and (cpu_temp_only or not Config::getB("show_coretemp"));
|
||||||
const int extra_width = (hide_cores ? max(6, 6 * b_column_size) : 0);
|
const int extra_width = (hide_cores ? max(6, 6 * b_column_size) : 0);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
const auto& show_gpu_info = Config::getS("show_gpu_info");
|
const auto& show_gpu_info = Config::getS("show_gpu_info");
|
||||||
const bool gpu_always = show_gpu_info == "On";
|
const bool gpu_always = show_gpu_info == "On";
|
||||||
bool show_gpu = (gpus.size() > 0 and (gpu_always or (show_gpu_info == "Auto" and Gpu::shown == 0)));
|
bool show_gpu = (gpus.size() > 0 and (gpu_always or (show_gpu_info == "Auto" and Gpu::shown == 0)));
|
||||||
|
#else
|
||||||
|
(void)gpus;
|
||||||
|
#endif
|
||||||
auto graph_up_field = Config::getS("cpu_graph_upper");
|
auto graph_up_field = Config::getS("cpu_graph_upper");
|
||||||
if (graph_up_field == "Auto" or not v_contains(Cpu::available_fields, graph_up_field))
|
if (graph_up_field == "Auto" or not v_contains(Cpu::available_fields, graph_up_field))
|
||||||
graph_up_field = "total";
|
graph_up_field = "total";
|
||||||
auto graph_lo_field = Config::getS("cpu_graph_lower");
|
auto graph_lo_field = Config::getS("cpu_graph_lower");
|
||||||
if (graph_lo_field == "Auto" or not v_contains(Cpu::available_fields, graph_lo_field)) {
|
if (graph_lo_field == "Auto" or not v_contains(Cpu::available_fields, graph_lo_field)) {
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
graph_lo_field = show_gpu ? "gpu-totals" : graph_up_field;
|
graph_lo_field = show_gpu ? "gpu-totals" : graph_up_field;
|
||||||
|
#else
|
||||||
|
graph_lo_field = graph_up_field;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
auto tty_mode = Config::getB("tty_mode");
|
auto tty_mode = Config::getB("tty_mode");
|
||||||
auto& graph_symbol = (tty_mode ? "tty" : Config::getS("graph_symbol_cpu"));
|
auto& graph_symbol = (tty_mode ? "tty" : Config::getS("graph_symbol_cpu"));
|
||||||
@ -585,6 +593,7 @@ namespace Cpu {
|
|||||||
const int graph_default_width = x + width - b_width - 3;
|
const int graph_default_width = x + width - b_width - 3;
|
||||||
|
|
||||||
auto init_graphs = [&](vector<Draw::Graph>& graphs, const int graph_height, int& graph_width, const string& graph_field, bool invert) {
|
auto init_graphs = [&](vector<Draw::Graph>& graphs, const int graph_height, int& graph_width, const string& graph_field, bool invert) {
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
if (graph_field.starts_with("gpu")) {
|
if (graph_field.starts_with("gpu")) {
|
||||||
if (graph_field.find("totals") != string::npos) {
|
if (graph_field.find("totals") != string::npos) {
|
||||||
graphs.resize(gpus.size());
|
graphs.resize(gpus.size());
|
||||||
@ -637,9 +646,11 @@ namespace Cpu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#endif
|
||||||
graphs.resize(1);
|
graphs.resize(1);
|
||||||
graph_width = graph_default_width;
|
graph_width = graph_default_width;
|
||||||
graphs[0] = Draw::Graph{ graph_width, graph_height, "cpu", cpu.cpu_percent.at(graph_field), graph_symbol, invert, true };
|
graphs[0] = Draw::Graph{ graph_width, graph_height, "cpu", cpu.cpu_percent.at(graph_field), graph_symbol, invert, true };
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
if (std::cmp_less(Gpu::shown, gpus.size())) {
|
if (std::cmp_less(Gpu::shown, gpus.size())) {
|
||||||
gpu_temp_graphs.resize(gpus.size());
|
gpu_temp_graphs.resize(gpus.size());
|
||||||
gpu_mem_graphs.resize(gpus.size());
|
gpu_mem_graphs.resize(gpus.size());
|
||||||
@ -656,6 +667,7 @@ namespace Cpu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
init_graphs(graphs_upper, graph_up_height, graph_up_width, graph_up_field, false);
|
init_graphs(graphs_upper, graph_up_height, graph_up_width, graph_up_field, false);
|
||||||
@ -733,6 +745,7 @@ namespace Cpu {
|
|||||||
//? Cpu/Gpu graphs
|
//? Cpu/Gpu graphs
|
||||||
out += Fx::ub + Mv::to(y + 1, x + 1);
|
out += Fx::ub + Mv::to(y + 1, x + 1);
|
||||||
auto draw_graphs = [&](vector<Draw::Graph>& graphs, const int graph_height, const int graph_width, const string& graph_field) {
|
auto draw_graphs = [&](vector<Draw::Graph>& graphs, const int graph_height, const int graph_width, const string& graph_field) {
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
if (graph_field.starts_with("gpu"))
|
if (graph_field.starts_with("gpu"))
|
||||||
if (graph_field.find("totals") != string::npos)
|
if (graph_field.find("totals") != string::npos)
|
||||||
for (unsigned long i = 0;;) {
|
for (unsigned long i = 0;;) {
|
||||||
@ -747,8 +760,14 @@ namespace Cpu {
|
|||||||
out += Theme::c("div_line") + (Symbols::v_line + Mv::l(1) + Mv::u(1))*graph_height + Mv::r(1) + Mv::d(1);
|
out += Theme::c("div_line") + (Symbols::v_line + Mv::l(1) + Mv::u(1))*graph_height + Mv::r(1) + Mv::d(1);
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
else out += graphs[0](Gpu::shared_gpu_percent.at(graph_field), (data_same or redraw));
|
else
|
||||||
else out += graphs[0](cpu.cpu_percent.at(graph_field), (data_same or redraw));
|
out += graphs[0](Gpu::shared_gpu_percent.at(graph_field), (data_same or redraw));
|
||||||
|
else
|
||||||
|
#else
|
||||||
|
(void)graph_height;
|
||||||
|
(void)graph_width;
|
||||||
|
#endif
|
||||||
|
out += graphs[0](cpu.cpu_percent.at(graph_field), (data_same or redraw));
|
||||||
};
|
};
|
||||||
|
|
||||||
draw_graphs(graphs_upper, graph_up_height, graph_up_width, graph_up_field);
|
draw_graphs(graphs_upper, graph_up_height, graph_up_width, graph_up_field);
|
||||||
@ -843,10 +862,15 @@ namespace Cpu {
|
|||||||
} else {
|
} else {
|
||||||
lavg_str_len = lavg_str.length();
|
lavg_str_len = lavg_str.length();
|
||||||
}
|
}
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
cy = b_height - 2 - (show_gpu ? (gpus.size() - (gpu_always ? 0 : Gpu::shown)) : 0);
|
cy = b_height - 2 - (show_gpu ? (gpus.size() - (gpu_always ? 0 : Gpu::shown)) : 0);
|
||||||
|
#else
|
||||||
|
cy = b_height - 2;
|
||||||
|
#endif
|
||||||
out += Mv::to(b_y + cy, b_x + cx + 1) + Theme::c("main_fg") + lavg_str;
|
out += Mv::to(b_y + cy, b_x + cx + 1) + Theme::c("main_fg") + lavg_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
//? Gpu brief info
|
//? Gpu brief info
|
||||||
if (show_gpu) {
|
if (show_gpu) {
|
||||||
for (unsigned long i = 0; i < gpus.size(); ++i) {
|
for (unsigned long i = 0; i < gpus.size(); ++i) {
|
||||||
@ -883,6 +907,7 @@ namespace Cpu {
|
|||||||
if (cy < b_height - 1) break;
|
if (cy < b_height - 1) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
redraw = false;
|
redraw = false;
|
||||||
return out + Fx::reset;
|
return out + Fx::reset;
|
||||||
@ -890,6 +915,7 @@ namespace Cpu {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
namespace Gpu {
|
namespace Gpu {
|
||||||
int width_p = 100, height_p = 32;
|
int width_p = 100, height_p = 32;
|
||||||
int min_width = 41, min_height = 11;
|
int min_width = 41, min_height = 11;
|
||||||
@ -1059,6 +1085,7 @@ namespace Gpu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Mem {
|
namespace Mem {
|
||||||
int width_p = 45, height_p = 36;
|
int width_p = 45, height_p = 36;
|
||||||
@ -1919,7 +1946,7 @@ namespace Draw {
|
|||||||
auto proc_left = Config::getB("proc_left");
|
auto proc_left = Config::getB("proc_left");
|
||||||
|
|
||||||
Cpu::box.clear();
|
Cpu::box.clear();
|
||||||
Gpu::box.clear();
|
|
||||||
Mem::box.clear();
|
Mem::box.clear();
|
||||||
Net::box.clear();
|
Net::box.clear();
|
||||||
Proc::box.clear();
|
Proc::box.clear();
|
||||||
@ -1935,11 +1962,14 @@ namespace Draw {
|
|||||||
|
|
||||||
Cpu::x = Mem::x = Net::x = Proc::x = 1;
|
Cpu::x = Mem::x = Net::x = Proc::x = 1;
|
||||||
Cpu::y = Mem::y = Net::y = Proc::y = 1;
|
Cpu::y = Mem::y = Net::y = Proc::y = 1;
|
||||||
Cpu::width = Gpu::width = Mem::width = Net::width = Proc::width = 0;
|
Cpu::width = Mem::width = Net::width = Proc::width = 0;
|
||||||
Cpu::height = Mem::height = Net::height = Proc::height = 0;
|
Cpu::height = Mem::height = Net::height = Proc::height = 0;
|
||||||
Cpu::redraw = Mem::redraw = Net::redraw = Proc::redraw = true;
|
Cpu::redraw = Mem::redraw = Net::redraw = Proc::redraw = true;
|
||||||
|
|
||||||
Cpu::shown = s_contains(boxes, "cpu");
|
Cpu::shown = s_contains(boxes, "cpu");
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
|
Gpu::box.clear();
|
||||||
|
Gpu::width = 0;
|
||||||
Gpu::shown_panels.clear();
|
Gpu::shown_panels.clear();
|
||||||
if (not Gpu::gpu_names.empty()) {
|
if (not Gpu::gpu_names.empty()) {
|
||||||
std::istringstream iss(boxes, std::istringstream::in);
|
std::istringstream iss(boxes, std::istringstream::in);
|
||||||
@ -1954,6 +1984,7 @@ namespace Draw {
|
|||||||
) Gpu::shown_panels.push_back(current.back()-'0');
|
) Gpu::shown_panels.push_back(current.back()-'0');
|
||||||
}
|
}
|
||||||
Gpu::shown = Gpu::shown_panels.size();
|
Gpu::shown = Gpu::shown_panels.size();
|
||||||
|
#endif
|
||||||
Mem::shown = s_contains(boxes, "mem");
|
Mem::shown = s_contains(boxes, "mem");
|
||||||
Net::shown = s_contains(boxes, "net");
|
Net::shown = s_contains(boxes, "net");
|
||||||
Proc::shown = s_contains(boxes, "proc");
|
Proc::shown = s_contains(boxes, "proc");
|
||||||
@ -1961,14 +1992,17 @@ namespace Draw {
|
|||||||
//* Calculate and draw cpu box outlines
|
//* Calculate and draw cpu box outlines
|
||||||
if (Cpu::shown) {
|
if (Cpu::shown) {
|
||||||
using namespace Cpu;
|
using namespace Cpu;
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
const bool show_gpu_on = Config::getS("show_gpu_info") == "On";
|
const bool show_gpu_on = Config::getS("show_gpu_info") == "On";
|
||||||
const bool gpus_shown_in_cpu_panel = Gpu::gpu_names.size() > 0 and (
|
const bool gpus_shown_in_cpu_panel = Gpu::gpu_names.size() > 0 and (
|
||||||
show_gpu_on or (Config::getS("cpu_graph_lower") == "Auto" and Gpu::shown == 0)
|
show_gpu_on or (Config::getS("cpu_graph_lower") == "Auto" and Gpu::shown == 0)
|
||||||
);
|
);
|
||||||
const int gpus_height_offset = (Gpu::gpu_names.size() - Gpu::shown)*gpus_shown_in_cpu_panel;
|
const int gpus_height_offset = (Gpu::gpu_names.size() - Gpu::shown)*gpus_shown_in_cpu_panel;
|
||||||
int gpus_extra_height = gpus_shown_in_cpu_panel ? Gpu::gpu_names.size() - (show_gpu_on ? 0 : Gpu::shown) : 0;
|
int gpus_extra_height = gpus_shown_in_cpu_panel ? Gpu::gpu_names.size() - (show_gpu_on ? 0 : Gpu::shown) : 0;
|
||||||
|
#endif
|
||||||
const bool show_temp = (Config::getB("check_temp") and got_sensors);
|
const bool show_temp = (Config::getB("check_temp") and got_sensors);
|
||||||
width = round((double)Term::width * width_p / 100);
|
width = round((double)Term::width * width_p / 100);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
if (Gpu::shown != 0 and not (Mem::shown or Net::shown or Proc::shown)) {
|
if (Gpu::shown != 0 and not (Mem::shown or Net::shown or Proc::shown)) {
|
||||||
height = Term::height - Gpu::min_height*Gpu::shown - gpus_height_offset;
|
height = Term::height - Gpu::min_height*Gpu::shown - gpus_height_offset;
|
||||||
} else {
|
} else {
|
||||||
@ -1976,11 +2010,17 @@ namespace Draw {
|
|||||||
}
|
}
|
||||||
if (height <= Term::height-gpus_height_offset) height += gpus_height_offset;
|
if (height <= Term::height-gpus_height_offset) height += gpus_height_offset;
|
||||||
if (height - gpus_extra_height < 7) gpus_extra_height = height - 7;
|
if (height - gpus_extra_height < 7) gpus_extra_height = height - 7;
|
||||||
|
#else
|
||||||
|
height = max(8, (int)ceil((double)Term::height * (trim(boxes) == "cpu" ? 100 : height_p) / 100));
|
||||||
|
#endif
|
||||||
x = 1;
|
x = 1;
|
||||||
y = cpu_bottom ? Term::height - height + 1 : 1;
|
y = cpu_bottom ? Term::height - height + 1 : 1;
|
||||||
|
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
b_columns = max(1, (int)ceil((double)(Shared::coreCount + 1) / (height - gpus_extra_height - 5)));
|
b_columns = max(1, (int)ceil((double)(Shared::coreCount + 1) / (height - gpus_extra_height - 5)));
|
||||||
|
#else
|
||||||
|
b_columns = max(1, (int)ceil((double)(Shared::coreCount + 1) / (height - 5)));
|
||||||
|
#endif
|
||||||
if (b_columns * (21 + 12 * show_temp) < width - (width / 3)) {
|
if (b_columns * (21 + 12 * show_temp) < width - (width / 3)) {
|
||||||
b_column_size = 2;
|
b_column_size = 2;
|
||||||
b_width = (21 + 12 * show_temp) * b_columns - (b_columns - 1);
|
b_width = (21 + 12 * show_temp) * b_columns - (b_columns - 1);
|
||||||
@ -1998,7 +2038,11 @@ namespace Draw {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (b_column_size == 0) b_width = (8 + 6 * show_temp) * b_columns + 1;
|
if (b_column_size == 0) b_width = (8 + 6 * show_temp) * b_columns + 1;
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
b_height = min(height - 2, (int)ceil((double)Shared::coreCount / b_columns) + 4 + gpus_extra_height);
|
b_height = min(height - 2, (int)ceil((double)Shared::coreCount / b_columns) + 4 + gpus_extra_height);
|
||||||
|
#else
|
||||||
|
b_height = min(height - 2, (int)ceil((double)Shared::coreCount / b_columns) + 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
b_x = x + width - b_width - 1;
|
b_x = x + width - b_width - 1;
|
||||||
b_y = y + ceil((double)(height - 2) / 2) - ceil((double)b_height / 2) + 1;
|
b_y = y + ceil((double)(height - 2) / 2) - ceil((double)b_height / 2) + 1;
|
||||||
@ -2010,6 +2054,7 @@ namespace Draw {
|
|||||||
box += createBox(b_x, b_y, b_width, b_height, "", false, cpu_title);
|
box += createBox(b_x, b_y, b_width, b_height, "", false, cpu_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
//* Calculate and draw gpu box outlines
|
//* Calculate and draw gpu box outlines
|
||||||
if (Gpu::shown != 0) {
|
if (Gpu::shown != 0) {
|
||||||
using namespace Gpu;
|
using namespace Gpu;
|
||||||
@ -2054,6 +2099,7 @@ namespace Draw {
|
|||||||
box[i] += createBox(b_x_vec[i], b_y_vec[i], b_width, b_height_vec[i], "", false, name.substr(0, b_width-5));
|
box[i] += createBox(b_x_vec[i], b_y_vec[i], b_width, b_height_vec[i], "", false, name.substr(0, b_width-5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//* Calculate and draw mem box outlines
|
//* Calculate and draw mem box outlines
|
||||||
if (Mem::shown) {
|
if (Mem::shown) {
|
||||||
@ -2063,12 +2109,22 @@ namespace Draw {
|
|||||||
auto mem_graphs = Config::getB("mem_graphs");
|
auto mem_graphs = Config::getB("mem_graphs");
|
||||||
|
|
||||||
width = round((double)Term::width * (Proc::shown ? width_p : 100) / 100);
|
width = round((double)Term::width * (Proc::shown ? width_p : 100) / 100);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
height = ceil((double)Term::height * (100 - Net::height_p * Net::shown*4 / ((Gpu::shown != 0 and Cpu::shown) + 4)) / 100) - Cpu::height - Gpu::height*Gpu::shown;
|
height = ceil((double)Term::height * (100 - Net::height_p * Net::shown*4 / ((Gpu::shown != 0 and Cpu::shown) + 4)) / 100) - Cpu::height - Gpu::height*Gpu::shown;
|
||||||
|
#else
|
||||||
|
height = ceil((double)Term::height * (100 - Cpu::height_p * Cpu::shown - Net::height_p * Net::shown) / 100) + 1;
|
||||||
|
#endif
|
||||||
x = (proc_left and Proc::shown) ? Term::width - width + 1: 1;
|
x = (proc_left and Proc::shown) ? Term::width - width + 1: 1;
|
||||||
if (mem_below_net and Net::shown)
|
if (mem_below_net and Net::shown)
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
y = Term::height - height + 1 - (cpu_bottom ? Cpu::height + Gpu::height*Gpu::shown : 0);
|
y = Term::height - height + 1 - (cpu_bottom ? Cpu::height + Gpu::height*Gpu::shown : 0);
|
||||||
else
|
else
|
||||||
y = cpu_bottom ? 1 : Cpu::height + Gpu::height*Gpu::shown + 1;
|
y = cpu_bottom ? 1 : Cpu::height + Gpu::height*Gpu::shown + 1;
|
||||||
|
#else
|
||||||
|
y = Term::height - height + 1 - (cpu_bottom ? Cpu::height : 0);
|
||||||
|
else
|
||||||
|
y = cpu_bottom ? 1 : Cpu::height + 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (show_disks) {
|
if (show_disks) {
|
||||||
mem_width = ceil((double)(width - 3) / 2);
|
mem_width = ceil((double)(width - 3) / 2);
|
||||||
@ -2117,10 +2173,18 @@ namespace Draw {
|
|||||||
if (Net::shown) {
|
if (Net::shown) {
|
||||||
using namespace Net;
|
using namespace Net;
|
||||||
width = round((double)Term::width * (Proc::shown ? width_p : 100) / 100);
|
width = round((double)Term::width * (Proc::shown ? width_p : 100) / 100);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
height = Term::height - Cpu::height - Gpu::height*Gpu::shown - Mem::height;
|
height = Term::height - Cpu::height - Gpu::height*Gpu::shown - Mem::height;
|
||||||
|
#else
|
||||||
|
height = Term::height - Cpu::height - Mem::height;
|
||||||
|
#endif
|
||||||
x = (proc_left and Proc::shown) ? Term::width - width + 1 : 1;
|
x = (proc_left and Proc::shown) ? Term::width - width + 1 : 1;
|
||||||
if (mem_below_net and Mem::shown)
|
if (mem_below_net and Mem::shown)
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
y = cpu_bottom ? 1 : Cpu::height + Gpu::height*Gpu::shown + 1;
|
y = cpu_bottom ? 1 : Cpu::height + Gpu::height*Gpu::shown + 1;
|
||||||
|
#else
|
||||||
|
y = cpu_bottom ? 1 : Cpu::height + 1;
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
y = Term::height - height + 1 - (cpu_bottom ? Cpu::height : 0);
|
y = Term::height - height + 1 - (cpu_bottom ? Cpu::height : 0);
|
||||||
|
|
||||||
@ -2139,9 +2203,17 @@ namespace Draw {
|
|||||||
if (Proc::shown) {
|
if (Proc::shown) {
|
||||||
using namespace Proc;
|
using namespace Proc;
|
||||||
width = Term::width - (Mem::shown ? Mem::width : (Net::shown ? Net::width : 0));
|
width = Term::width - (Mem::shown ? Mem::width : (Net::shown ? Net::width : 0));
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
height = Term::height - Cpu::height - Gpu::height*Gpu::shown;
|
height = Term::height - Cpu::height - Gpu::height*Gpu::shown;
|
||||||
|
#else
|
||||||
|
height = Term::height - Cpu::height;
|
||||||
|
#endif
|
||||||
x = proc_left ? 1 : Term::width - width + 1;
|
x = proc_left ? 1 : Term::width - width + 1;
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
y = (cpu_bottom and Cpu::shown) ? 1 : Cpu::height + Gpu::height*Gpu::shown + 1;
|
y = (cpu_bottom and Cpu::shown) ? 1 : Cpu::height + Gpu::height*Gpu::shown + 1;
|
||||||
|
#else
|
||||||
|
y = (cpu_bottom and Cpu::shown) ? 1 : Cpu::height + 1;
|
||||||
|
#endif
|
||||||
select_max = height - 3;
|
select_max = height - 3;
|
||||||
box = createBox(x, y, width, height, Theme::c("proc_box"), true, "proc", "", 4);
|
box = createBox(x, y, width, height, Theme::c("proc_box"), true, "proc", "", 4);
|
||||||
}
|
}
|
||||||
|
@ -271,11 +271,18 @@ namespace Input {
|
|||||||
}
|
}
|
||||||
else if (key.size() == 1 and isint(key)) {
|
else if (key.size() == 1 and isint(key)) {
|
||||||
auto intKey = stoi(key);
|
auto intKey = stoi(key);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
|
static const array<string, 10> boxes = {"gpu5", "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4"};
|
||||||
if ((intKey == 0 and Gpu::gpu_names.size() < 5) or (intKey >= 5 and std::cmp_less(Gpu::gpu_names.size(), intKey - 4)))
|
if ((intKey == 0 and Gpu::gpu_names.size() < 5) or (intKey >= 5 and std::cmp_less(Gpu::gpu_names.size(), intKey - 4)))
|
||||||
return;
|
return;
|
||||||
|
#else
|
||||||
|
static const array<string, 10> boxes = {"", "cpu", "mem", "net", "proc"};
|
||||||
|
if (intKey == 0 or intKey > 4)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
atomic_wait(Runner::active);
|
atomic_wait(Runner::active);
|
||||||
Config::current_preset = -1;
|
Config::current_preset = -1;
|
||||||
static const array<string, 10> boxes = {"gpu5", "cpu", "mem", "net", "proc", "gpu0", "gpu1", "gpu2", "gpu3", "gpu4"};
|
|
||||||
Config::toggle_box(boxes.at(intKey));
|
Config::toggle_box(boxes.at(intKey));
|
||||||
Draw::calcSizes();
|
Draw::calcSizes();
|
||||||
Runner::run("all", false, true);
|
Runner::run("all", false, true);
|
||||||
|
@ -212,8 +212,10 @@ namespace Menu {
|
|||||||
{"shown_boxes",
|
{"shown_boxes",
|
||||||
"Manually set which boxes to show.",
|
"Manually set which boxes to show.",
|
||||||
"",
|
"",
|
||||||
"Available values are \"cpu mem net proc\",",
|
"Available values are \"cpu mem net proc\".",
|
||||||
"or \"gpu0\" through \"gpu5\" for GPU boxes.",
|
#ifdef GPU_SUPPORT
|
||||||
|
"Or \"gpu0\" through \"gpu5\" for GPU boxes.",
|
||||||
|
#endif
|
||||||
"Separate values with whitespace.",
|
"Separate values with whitespace.",
|
||||||
"",
|
"",
|
||||||
"Toggle between presets with key \"p\"."},
|
"Toggle between presets with key \"p\"."},
|
||||||
@ -324,6 +326,7 @@ namespace Menu {
|
|||||||
"\"user\" = User mode cpu usage.",
|
"\"user\" = User mode cpu usage.",
|
||||||
"\"system\" = Kernel mode cpu usage.",
|
"\"system\" = Kernel mode cpu usage.",
|
||||||
"+ more depending on kernel.",
|
"+ more depending on kernel.",
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
"",
|
"",
|
||||||
"GPU:",
|
"GPU:",
|
||||||
"\"gpu-totals\" = GPU usage split by device.",
|
"\"gpu-totals\" = GPU usage split by device.",
|
||||||
@ -332,7 +335,9 @@ namespace Menu {
|
|||||||
"\"gpu-average\" = Avg usage of all GPUs.",
|
"\"gpu-average\" = Avg usage of all GPUs.",
|
||||||
"\"gpu-vram-total\" = VRAM usage of all GPUs.",
|
"\"gpu-vram-total\" = VRAM usage of all GPUs.",
|
||||||
"\"gpu-pwr-total\" = Power usage of all GPUs.",
|
"\"gpu-pwr-total\" = Power usage of all GPUs.",
|
||||||
"Not all stats are supported on all devices."},
|
"Not all stats are supported on all devices."
|
||||||
|
#endif
|
||||||
|
},
|
||||||
{"cpu_graph_lower",
|
{"cpu_graph_lower",
|
||||||
"Cpu lower graph.",
|
"Cpu lower graph.",
|
||||||
"",
|
"",
|
||||||
@ -344,6 +349,7 @@ namespace Menu {
|
|||||||
"\"user\" = User mode cpu usage.",
|
"\"user\" = User mode cpu usage.",
|
||||||
"\"system\" = Kernel mode cpu usage.",
|
"\"system\" = Kernel mode cpu usage.",
|
||||||
"+ more depending on kernel.",
|
"+ more depending on kernel.",
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
"",
|
"",
|
||||||
"GPU:",
|
"GPU:",
|
||||||
"\"gpu-totals\" = GPU usage split/device. (Auto)",
|
"\"gpu-totals\" = GPU usage split/device. (Auto)",
|
||||||
@ -352,7 +358,9 @@ namespace Menu {
|
|||||||
"\"gpu-average\" = Avg usage of all GPUs.",
|
"\"gpu-average\" = Avg usage of all GPUs.",
|
||||||
"\"gpu-vram-total\" = VRAM usage of all GPUs.",
|
"\"gpu-vram-total\" = VRAM usage of all GPUs.",
|
||||||
"\"gpu-pwr-total\" = Power usage of all GPUs.",
|
"\"gpu-pwr-total\" = Power usage of all GPUs.",
|
||||||
"Not all stats are supported on all devices."},
|
"Not all stats are supported on all devices."
|
||||||
|
#endif
|
||||||
|
},
|
||||||
{"cpu_invert_lower",
|
{"cpu_invert_lower",
|
||||||
"Toggles orientation of the lower CPU graph.",
|
"Toggles orientation of the lower CPU graph.",
|
||||||
"",
|
"",
|
||||||
@ -364,6 +372,7 @@ namespace Menu {
|
|||||||
"to fit to box height.",
|
"to fit to box height.",
|
||||||
"",
|
"",
|
||||||
"True or False."},
|
"True or False."},
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
{"show_gpu_info",
|
{"show_gpu_info",
|
||||||
"Show gpu info in cpu box.",
|
"Show gpu info in cpu box.",
|
||||||
"",
|
"",
|
||||||
@ -374,6 +383,7 @@ namespace Menu {
|
|||||||
"\"Auto\" to show when no gpu box is shown.",
|
"\"Auto\" to show when no gpu box is shown.",
|
||||||
"\"On\" to always show.",
|
"\"On\" to always show.",
|
||||||
"\"Off\" to never show."},
|
"\"Off\" to never show."},
|
||||||
|
#endif
|
||||||
{"check_temp",
|
{"check_temp",
|
||||||
"Enable cpu temperature reporting.",
|
"Enable cpu temperature reporting.",
|
||||||
"",
|
"",
|
||||||
@ -435,6 +445,7 @@ namespace Menu {
|
|||||||
"",
|
"",
|
||||||
"True or False."},
|
"True or False."},
|
||||||
},
|
},
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
{
|
{
|
||||||
{"nvml_measure_pcie_speeds",
|
{"nvml_measure_pcie_speeds",
|
||||||
"Measure PCIe throughput on NVIDIA cards.",
|
"Measure PCIe throughput on NVIDIA cards.",
|
||||||
@ -477,6 +488,7 @@ namespace Menu {
|
|||||||
"",
|
"",
|
||||||
"Empty string to disable."},
|
"Empty string to disable."},
|
||||||
},
|
},
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
{"mem_below_net",
|
{"mem_below_net",
|
||||||
"Mem box location.",
|
"Mem box location.",
|
||||||
@ -1096,7 +1108,6 @@ namespace Menu {
|
|||||||
{"proc_sorting", std::cref(Proc::sort_vector)},
|
{"proc_sorting", std::cref(Proc::sort_vector)},
|
||||||
{"graph_symbol", std::cref(Config::valid_graph_symbols)},
|
{"graph_symbol", std::cref(Config::valid_graph_symbols)},
|
||||||
{"graph_symbol_cpu", std::cref(Config::valid_graph_symbols_def)},
|
{"graph_symbol_cpu", std::cref(Config::valid_graph_symbols_def)},
|
||||||
{"graph_symbol_gpu", std::cref(Config::valid_graph_symbols_def)},
|
|
||||||
{"graph_symbol_mem", std::cref(Config::valid_graph_symbols_def)},
|
{"graph_symbol_mem", std::cref(Config::valid_graph_symbols_def)},
|
||||||
{"graph_symbol_net", std::cref(Config::valid_graph_symbols_def)},
|
{"graph_symbol_net", std::cref(Config::valid_graph_symbols_def)},
|
||||||
{"graph_symbol_proc", std::cref(Config::valid_graph_symbols_def)},
|
{"graph_symbol_proc", std::cref(Config::valid_graph_symbols_def)},
|
||||||
@ -1104,7 +1115,10 @@ namespace Menu {
|
|||||||
{"cpu_graph_lower", std::cref(Cpu::available_fields)},
|
{"cpu_graph_lower", std::cref(Cpu::available_fields)},
|
||||||
{"cpu_sensor", std::cref(Cpu::available_sensors)},
|
{"cpu_sensor", std::cref(Cpu::available_sensors)},
|
||||||
{"selected_battery", std::cref(Config::available_batteries)},
|
{"selected_battery", std::cref(Config::available_batteries)},
|
||||||
{"show_gpu_info", std::cref(Config::show_gpu_values)}
|
#ifdef GPU_SUPPORT
|
||||||
|
{"show_gpu_info", std::cref(Config::show_gpu_values)},
|
||||||
|
{"graph_symbol_gpu", std::cref(Config::valid_graph_symbols_def)},
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
auto tty_mode = Config::getB("tty_mode");
|
auto tty_mode = Config::getB("tty_mode");
|
||||||
auto vim_keys = Config::getB("vim_keys");
|
auto vim_keys = Config::getB("vim_keys");
|
||||||
@ -1336,11 +1350,19 @@ namespace Menu {
|
|||||||
|
|
||||||
//? Category buttons
|
//? Category buttons
|
||||||
out += Mv::to(y+7, x+4);
|
out += Mv::to(y+7, x+4);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
for (int i = 0; const auto& m : {"general", "cpu", "gpu", "mem", "net", "proc"}) {
|
for (int i = 0; const auto& m : {"general", "cpu", "gpu", "mem", "net", "proc"}) {
|
||||||
|
#else
|
||||||
|
for (int i = 0; const auto& m : {"general", "cpu", "mem", "net", "proc"}) {
|
||||||
|
#endif
|
||||||
out += Fx::b + (i == selected_cat
|
out += Fx::b + (i == selected_cat
|
||||||
? Theme::c("hi_fg") + '[' + Theme::c("title") + m + Theme::c("hi_fg") + ']'
|
? Theme::c("hi_fg") + '[' + Theme::c("title") + m + Theme::c("hi_fg") + ']'
|
||||||
: Theme::c("hi_fg") + to_string(i + 1) + Theme::c("title") + m + ' ')
|
: Theme::c("hi_fg") + to_string(i + 1) + Theme::c("title") + m + ' ')
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
+ Mv::r(7);
|
+ Mv::r(7);
|
||||||
|
#else
|
||||||
|
+ Mv::r(10);
|
||||||
|
#endif
|
||||||
if (string button_name = "select_cat_" + to_string(i + 1); not editing and not mouse_mappings.contains(button_name))
|
if (string button_name = "select_cat_" + to_string(i + 1); not editing and not mouse_mappings.contains(button_name))
|
||||||
mouse_mappings[button_name] = {y+6, x+2 + 15*i, 3, 15};
|
mouse_mappings[button_name] = {y+6, x+2 + 15*i, 3, 15};
|
||||||
i++;
|
i++;
|
||||||
|
@ -24,6 +24,7 @@ tab-size = 4
|
|||||||
namespace rng = std::ranges;
|
namespace rng = std::ranges;
|
||||||
using namespace Tools;
|
using namespace Tools;
|
||||||
|
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
namespace Gpu {
|
namespace Gpu {
|
||||||
vector<string> gpu_names;
|
vector<string> gpu_names;
|
||||||
vector<int> gpu_b_height_offsets;
|
vector<int> gpu_b_height_offsets;
|
||||||
@ -34,6 +35,7 @@ namespace Gpu {
|
|||||||
};
|
};
|
||||||
long long gpu_pwr_total_max;
|
long long gpu_pwr_total_max;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Proc {
|
namespace Proc {
|
||||||
void proc_sorter(vector<proc_info>& proc_vec, const string& sorting, bool reverse, bool tree) {
|
void proc_sorter(vector<proc_info>& proc_vec, const string& sorting, bool reverse, bool tree) {
|
||||||
|
@ -87,6 +87,7 @@ namespace Shared {
|
|||||||
|
|
||||||
|
|
||||||
namespace Gpu {
|
namespace Gpu {
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
extern vector<string> box;
|
extern vector<string> box;
|
||||||
extern int width, height, min_width, min_height;
|
extern int width, height, min_width, min_height;
|
||||||
extern vector<int> x_vec, y_vec;
|
extern vector<int> x_vec, y_vec;
|
||||||
@ -151,20 +152,23 @@ namespace Gpu {
|
|||||||
// vector<proc_info> compute_processes = {};
|
// vector<proc_info> compute_processes = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
namespace Nvml {
|
namespace Nvml {
|
||||||
extern bool shutdown();
|
extern bool shutdown();
|
||||||
}
|
}
|
||||||
namespace Rsmi {
|
namespace Rsmi {
|
||||||
extern bool shutdown();
|
extern bool shutdown();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//* Collect gpu stats and temperatures
|
//* Collect gpu stats and temperatures
|
||||||
auto collect(bool no_update = false) -> vector<gpu_info>&;
|
auto collect(bool no_update = false) -> vector<gpu_info>&;
|
||||||
|
|
||||||
//* Draw contents of gpu box using <gpus> as source
|
//* Draw contents of gpu box using <gpus> as source
|
||||||
string draw(const gpu_info& gpu, unsigned long index, bool force_redraw, bool data_same);
|
string draw(const gpu_info& gpu, unsigned long index, bool force_redraw, bool data_same);
|
||||||
|
#else
|
||||||
|
struct gpu_info {
|
||||||
|
bool supported = false;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Cpu {
|
namespace Cpu {
|
||||||
|
@ -103,21 +103,27 @@ namespace Term {
|
|||||||
bool mem = boxes.find("mem") != string::npos;
|
bool mem = boxes.find("mem") != string::npos;
|
||||||
bool net = boxes.find("net") != string::npos;
|
bool net = boxes.find("net") != string::npos;
|
||||||
bool proc = boxes.find("proc") != string::npos;
|
bool proc = boxes.find("proc") != string::npos;
|
||||||
int gpu = 0;
|
#ifdef GPU_SUPPORT
|
||||||
|
int gpu = 0;
|
||||||
if (not Gpu::gpu_names.empty())
|
if (not Gpu::gpu_names.empty())
|
||||||
for (char i = '0'; i <= '5'; ++i)
|
for (char i = '0'; i <= '5'; ++i)
|
||||||
gpu += (boxes.find(std::string("gpu") + i) != string::npos);
|
gpu += (boxes.find(std::string("gpu") + i) != string::npos);
|
||||||
|
#endif
|
||||||
int width = 0;
|
int width = 0;
|
||||||
if (mem) width = Mem::min_width;
|
if (mem) width = Mem::min_width;
|
||||||
else if (net) width = Mem::min_width;
|
else if (net) width = Mem::min_width;
|
||||||
width += (proc ? Proc::min_width : 0);
|
width += (proc ? Proc::min_width : 0);
|
||||||
if (cpu and width < Cpu::min_width) width = Cpu::min_width;
|
if (cpu and width < Cpu::min_width) width = Cpu::min_width;
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
if (gpu != 0 and width < Gpu::min_width) width = Gpu::min_width;
|
if (gpu != 0 and width < Gpu::min_width) width = Gpu::min_width;
|
||||||
|
#endif
|
||||||
|
|
||||||
int height = (cpu ? Cpu::min_height : 0);
|
int height = (cpu ? Cpu::min_height : 0);
|
||||||
if (proc) height += Proc::min_height;
|
if (proc) height += Proc::min_height;
|
||||||
else height += (mem ? Mem::min_height : 0) + (net ? Net::min_height : 0);
|
else height += (mem ? Mem::min_height : 0) + (net ? Net::min_height : 0);
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
height += Gpu::min_height*gpu;
|
height += Gpu::min_height*gpu;
|
||||||
|
#endif
|
||||||
|
|
||||||
return { width, height };
|
return { width, height };
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ namespace Cpu {
|
|||||||
|
|
||||||
namespace Gpu {
|
namespace Gpu {
|
||||||
vector<gpu_info> gpus;
|
vector<gpu_info> gpus;
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
//? NVIDIA data collection
|
//? NVIDIA data collection
|
||||||
namespace Nvml {
|
namespace Nvml {
|
||||||
//? NVML defines, structs & typedefs
|
//? NVML defines, structs & typedefs
|
||||||
@ -190,6 +191,7 @@ namespace Gpu {
|
|||||||
template <bool is_init> bool collect(gpu_info* gpus_slice);
|
template <bool is_init> bool collect(gpu_info* gpus_slice);
|
||||||
uint32_t device_count = 0;
|
uint32_t device_count = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Mem {
|
namespace Mem {
|
||||||
@ -252,6 +254,7 @@ namespace Shared {
|
|||||||
Cpu::core_mapping = Cpu::get_core_mapping();
|
Cpu::core_mapping = Cpu::get_core_mapping();
|
||||||
|
|
||||||
//? Init for namespace Gpu
|
//? Init for namespace Gpu
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
Gpu::Nvml::init();
|
Gpu::Nvml::init();
|
||||||
Gpu::Rsmi::init();
|
Gpu::Rsmi::init();
|
||||||
if (not Gpu::gpu_names.empty()) {
|
if (not Gpu::gpu_names.empty()) {
|
||||||
@ -268,6 +271,7 @@ namespace Shared {
|
|||||||
+ (gpus[i].supported_functions.mem_total or gpus[i].supported_functions.mem_used)
|
+ (gpus[i].supported_functions.mem_total or gpus[i].supported_functions.mem_used)
|
||||||
* (1 + 2*(gpus[i].supported_functions.mem_total and gpus[i].supported_functions.mem_used) + 2*gpus[i].supported_functions.mem_utilization);
|
* (1 + 2*(gpus[i].supported_functions.mem_total and gpus[i].supported_functions.mem_used) + 2*gpus[i].supported_functions.mem_utilization);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//? Init for namespace Mem
|
//? Init for namespace Mem
|
||||||
Mem::old_uptime = system_uptime();
|
Mem::old_uptime = system_uptime();
|
||||||
@ -928,6 +932,7 @@ namespace Cpu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GPU_SUPPORT
|
||||||
namespace Gpu {
|
namespace Gpu {
|
||||||
//? NVIDIA
|
//? NVIDIA
|
||||||
namespace Nvml {
|
namespace Nvml {
|
||||||
@ -973,7 +978,7 @@ namespace Gpu {
|
|||||||
//? Function calls
|
//? Function calls
|
||||||
nvmlReturn_t result = nvmlInit();
|
nvmlReturn_t result = nvmlInit();
|
||||||
if (result != NVML_SUCCESS) {
|
if (result != NVML_SUCCESS) {
|
||||||
Logger::warning(std::string("Failed to initialize NVML, NVIDIA GPUs will not be detected: ") + nvmlErrorString(result));
|
Logger::debug(std::string("Failed to initialize NVML, NVIDIA GPUs will not be detected: ") + nvmlErrorString(result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1203,10 +1208,10 @@ namespace Gpu {
|
|||||||
rsmi_dl_handle = dlopen("/opt/rocm/lib/librocm_smi64.so", RTLD_LAZY); // first try /lib and /usr/lib, then /opt/rocm/lib if that fails
|
rsmi_dl_handle = dlopen("/opt/rocm/lib/librocm_smi64.so", RTLD_LAZY); // first try /lib and /usr/lib, then /opt/rocm/lib if that fails
|
||||||
if (dlerror() != NULL) {
|
if (dlerror() != NULL) {
|
||||||
rsmi_dl_handle = dlopen("librocm_smi64.so", RTLD_LAZY);
|
rsmi_dl_handle = dlopen("librocm_smi64.so", RTLD_LAZY);
|
||||||
if (!rsmi_dl_handle) {
|
}
|
||||||
Logger::info(std::string("Failed to load librocm_smi64.so, AMD GPUs will not be detected: ") + dlerror());
|
if (!rsmi_dl_handle) {
|
||||||
return false;
|
Logger::debug(std::string("Failed to load librocm_smi64.so, AMD GPUs will not be detected: ") + dlerror());
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto load_rsmi_sym = [&](const char sym_name[]) {
|
auto load_rsmi_sym = [&](const char sym_name[]) {
|
||||||
@ -1468,6 +1473,7 @@ namespace Gpu {
|
|||||||
return gpus;
|
return gpus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Mem {
|
namespace Mem {
|
||||||
bool has_swap{}; // defaults to false
|
bool has_swap{}; // defaults to false
|
||||||
|
Loading…
Reference in New Issue
Block a user