diff --git a/CMakeLists.txt b/CMakeLists.txt index 69f40fcdd..fe411cb1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ option(WITH_PROFILING "Enable profiling for developers" OFF) option(WITH_SSE4_1 "Enable SSE 4.1 for Blake2" ON) option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON) option(WITH_SECURE_JIT "Enable secure access to JIT memory" OFF) -option(WITH_DMI "Enable DMI reader" OFF) +option(WITH_DMI "Enable DMI/SMBIOS reader" OFF) option(BUILD_STATIC "Build static binary" OFF) option(ARM_TARGET "Force use specific ARM target 8 or 7" 0) diff --git a/src/Summary.cpp b/src/Summary.cpp index e0c4d58e9..eaee89bf5 100644 --- a/src/Summary.cpp +++ b/src/Summary.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,7 +76,7 @@ inline static const char *asmName(Assembly::Id assembly) #endif -static void print_memory(Config *config) +static void print_pages(const Config *config) { Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") "%s", "HUGE PAGES", config->cpu().isHugePages() ? (VirtualMemory::isHugepagesAvailable() ? kHugepagesSupported : RED_BOLD("unavailable")) : RED_BOLD("disabled")); @@ -92,7 +92,7 @@ static void print_memory(Config *config) } -static void print_cpu(Config *) +static void print_cpu(const Config *) { const auto info = Cpu::info(); @@ -121,7 +121,7 @@ static void print_cpu(Config *) } -static void print_memory() +static void print_memory(const Config *config) { constexpr size_t oneGiB = 1024U * 1024U * 1024U; const auto freeMem = static_cast(uv_get_free_memory()); @@ -137,6 +137,10 @@ static void print_memory() ); # ifdef XMRIG_FEATURE_DMI + if (!config->isDMI()) { + return; + } + DmiReader reader; if (!reader.read()) { return; @@ -167,7 +171,7 @@ static void print_memory() } -static void print_threads(Config *config) +static void print_threads(const Config *config) { Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s%d%%"), "DONATE", @@ -209,14 +213,16 @@ static void print_commands(Config *) void xmrig::Summary::print(Controller *controller) { - controller->config()->printVersions(); - print_memory(controller->config()); - print_cpu(controller->config()); - print_memory(); - print_threads(controller->config()); - controller->config()->pools().print(); + const auto config = controller->config(); - print_commands(controller->config()); + config->printVersions(); + print_pages(config); + print_cpu(config); + print_memory(config); + print_threads(config); + config->pools().print(); + + print_commands(config); } diff --git a/src/Summary.h b/src/Summary.h index 4317d13e1..0b03f6759 100644 --- a/src/Summary.h +++ b/src/Summary.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/base/kernel/interfaces/IConfig.h b/src/base/kernel/interfaces/IConfig.h index 8b5ae278a..792c43a11 100644 --- a/src/base/kernel/interfaces/IConfig.h +++ b/src/base/kernel/interfaces/IConfig.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -84,6 +84,7 @@ public: BenchSeedKey = 1046, BenchHashKey = 1047, BenchTokenKey = 1048, + DmiKey = 1049, // xmrig common CPUPriorityKey = 1021, diff --git a/src/core/config/Config.cpp b/src/core/config/Config.cpp index 792b3873d..f8b7bb858 100644 --- a/src/core/config/Config.cpp +++ b/src/core/config/Config.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,9 +23,9 @@ */ #include +#include #include #include -#include #include "core/config/Config.h" @@ -55,16 +55,19 @@ namespace xmrig { #ifdef XMRIG_FEATURE_OPENCL -static const char *kOcl = "opencl"; +const char *Config::kOcl = "opencl"; #endif #ifdef XMRIG_FEATURE_CUDA -static const char *kCuda = "cuda"; +const char *Config::kCuda = "cuda"; #endif - #if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) -static const char *kHealthPrintTime = "health-print-time"; +const char *Config::kHealthPrintTime = "health-print-time"; +#endif + +#ifdef XMRIG_FEATURE_DMI +const char *Config::kDMI = "dmi"; #endif @@ -88,6 +91,10 @@ public: # if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) uint32_t healthPrintTime = 60; # endif + +# ifdef XMRIG_FEATURE_DMI + bool dmi = true; +# endif }; } @@ -143,6 +150,14 @@ uint32_t xmrig::Config::healthPrintTime() const #endif +#ifdef XMRIG_FEATURE_DMI +bool xmrig::Config::isDMI() const +{ + return d_ptr->dmi; +} +#endif + + bool xmrig::Config::isShouldSave() const { if (!isAutoSave()) { @@ -191,6 +206,10 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName) d_ptr->healthPrintTime = reader.getUint(kHealthPrintTime, d_ptr->healthPrintTime); # endif +# ifdef XMRIG_FEATURE_DMI + d_ptr->dmi = reader.getBool(kDMI, d_ptr->dmi); +# endif + return true; } @@ -236,6 +255,11 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const # if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) doc.AddMember(StringRef(kHealthPrintTime), healthPrintTime(), allocator); # endif + +# ifdef XMRIG_FEATURE_DMI + doc.AddMember(StringRef(kDMI), isDMI(), allocator); +# endif + doc.AddMember(StringRef(kSyslog), isSyslog(), allocator); # ifdef XMRIG_FEATURE_TLS diff --git a/src/core/config/Config.h b/src/core/config/Config.h index 501b8c592..d8433beb2 100644 --- a/src/core/config/Config.h +++ b/src/core/config/Config.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,6 +50,22 @@ class Config : public BaseConfig public: XMRIG_DISABLE_COPY_MOVE(Config); +# ifdef XMRIG_FEATURE_OPENCL + static const char *kOcl; +# endif + +# ifdef XMRIG_FEATURE_CUDA + static const char *kCuda; +# endif + +# if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) + static const char *kHealthPrintTime; +# endif + +# ifdef XMRIG_FEATURE_DMI + static const char *kDMI; +# endif + Config(); ~Config() override; @@ -70,7 +86,13 @@ public: # if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) uint32_t healthPrintTime() const; # else - uint32_t healthPrintTime() const { return 0; } + uint32_t healthPrintTime() const { return 0; } +# endif + +# ifdef XMRIG_FEATURE_DMI + bool isDMI() const; +# else + static constexpr inline bool isDMI() { return false; } # endif bool isShouldSave() const; diff --git a/src/core/config/ConfigTransform.cpp b/src/core/config/ConfigTransform.cpp index b8a431fd1..b32aede37 100644 --- a/src/core/config/ConfigTransform.cpp +++ b/src/core/config/ConfigTransform.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,11 +23,11 @@ */ +#include "core/config/ConfigTransform.h" #include "base/kernel/interfaces/IConfig.h" -#include "backend/cpu/CpuConfig.h" #include "base/net/stratum/Pool.h" #include "base/net/stratum/Pools.h" -#include "core/config/ConfigTransform.h" +#include "core/config/Config.h" #include "crypto/cn/CnHash.h" @@ -51,14 +51,6 @@ static const char *kEnabled = "enabled"; static const char *kIntensity = "intensity"; static const char *kThreads = "threads"; -#ifdef XMRIG_FEATURE_OPENCL -static const char *kOcl = "opencl"; -#endif - -#ifdef XMRIG_FEATURE_CUDA -static const char *kCuda = "cuda"; -#endif - static inline uint64_t intensity(uint64_t av) { @@ -122,7 +114,7 @@ void xmrig::ConfigTransform::finalize(rapidjson::Document &doc) # ifdef XMRIG_FEATURE_OPENCL if (m_opencl) { - set(doc, kOcl, kEnabled, true); + set(doc, Config::kOcl, kEnabled, true); } # endif } @@ -208,47 +200,54 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const break; case IConfig::OclCacheKey: /* --opencl-no-cache */ - return set(doc, kOcl, "cache", false); + return set(doc, Config::kOcl, "cache", false); case IConfig::OclLoaderKey: /* --opencl-loader */ - return set(doc, kOcl, "loader", arg); + return set(doc, Config::kOcl, "loader", arg); case IConfig::OclDevicesKey: /* --opencl-devices */ m_opencl = true; - return set(doc, kOcl, "devices-hint", arg); + return set(doc, Config::kOcl, "devices-hint", arg); case IConfig::OclPlatformKey: /* --opencl-platform */ if (strlen(arg) < 3) { - return set(doc, kOcl, "platform", static_cast(strtol(arg, nullptr, 10))); + return set(doc, Config::kOcl, "platform", static_cast(strtol(arg, nullptr, 10))); } - return set(doc, kOcl, "platform", arg); + return set(doc, Config::kOcl, "platform", arg); # endif # ifdef XMRIG_FEATURE_CUDA case IConfig::CudaKey: /* --cuda */ - return set(doc, kCuda, kEnabled, true); + return set(doc, Config::kCuda, kEnabled, true); case IConfig::CudaLoaderKey: /* --cuda-loader */ - return set(doc, kCuda, "loader", arg); + return set(doc, Config::kCuda, "loader", arg); case IConfig::CudaDevicesKey: /* --cuda-devices */ - set(doc, kCuda, kEnabled, true); - return set(doc, kCuda, "devices-hint", arg); + set(doc, Config::kCuda, kEnabled, true); + return set(doc, Config::kCuda, "devices-hint", arg); case IConfig::CudaBFactorKey: /* --cuda-bfactor-hint */ - return set(doc, kCuda, "bfactor-hint", static_cast(strtol(arg, nullptr, 10))); + return set(doc, Config::kCuda, "bfactor-hint", static_cast(strtol(arg, nullptr, 10))); case IConfig::CudaBSleepKey: /* --cuda-bsleep-hint */ - return set(doc, kCuda, "bsleep-hint", static_cast(strtol(arg, nullptr, 10))); + return set(doc, Config::kCuda, "bsleep-hint", static_cast(strtol(arg, nullptr, 10))); # endif # ifdef XMRIG_FEATURE_NVML case IConfig::NvmlKey: /* --no-nvml */ - return set(doc, kCuda, "nvml", false); + return set(doc, Config::kCuda, "nvml", false); +# endif +# if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) case IConfig::HealthPrintTimeKey: /* --health-print-time */ - return set(doc, "health-print-time", static_cast(strtol(arg, nullptr, 10))); + return set(doc, Config::kHealthPrintTime, static_cast(strtol(arg, nullptr, 10))); +# endif + +# ifdef XMRIG_FEATURE_DMI + case IConfig::DmiKey: /* --no-dmi */ + return set(doc, Config::kDMI, false); # endif # ifdef XMRIG_FEATURE_BENCHMARK diff --git a/src/core/config/ConfigTransform.h b/src/core/config/ConfigTransform.h index 0251777ce..8fd2505ce 100644 --- a/src/core/config/ConfigTransform.h +++ b/src/core/config/ConfigTransform.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2020 SChernykh - * Copyright 2016-2020 XMRig , + * Copyright 2018-2021 SChernykh + * Copyright 2016-2021 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/core/config/Config_platform.h b/src/core/config/Config_platform.h index f698836c4..b6fcd1c1a 100644 --- a/src/core/config/Config_platform.h +++ b/src/core/config/Config_platform.h @@ -155,7 +155,12 @@ static const option options[] = { # endif # ifdef XMRIG_FEATURE_NVML { "no-nvml", 0, nullptr, IConfig::NvmlKey }, +# endif +# if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL) { "health-print-time", 1, nullptr, IConfig::HealthPrintTimeKey }, +# endif +# ifdef XMRIG_FEATURE_DMI + { "no-dmi", 0, nullptr, IConfig::DmiKey }, # endif { nullptr, 0, nullptr, 0 } }; diff --git a/src/core/config/usage.h b/src/core/config/usage.h index 54e629ecb..261e571cf 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -190,6 +190,10 @@ static inline const std::string &usage() u += " --hash=HASH compare benchmark result with specified hash\n"; # endif +# ifdef XMRIG_FEATURE_DMI + u += " --no-dmi disable DMI/SMBIOS reader\n"; +# endif + return u; } diff --git a/src/hw/dmi/dmi.cmake b/src/hw/dmi/dmi.cmake index aee0ff9a3..5140692a7 100644 --- a/src/hw/dmi/dmi.cmake +++ b/src/hw/dmi/dmi.cmake @@ -1,3 +1,7 @@ +if (WITH_DMI) + set(WITH_DMI XMRIG_OS_WIN OR XMRIG_OS_LINUX OR XMRIG_OS_FREEBSD OR (XMRIG_OS_MACOS AND NOT XMRIG_ARM)) +endif() + if (WITH_DMI) add_definitions(/DXMRIG_FEATURE_DMI)