Added initial NVML stub.
This commit is contained in:
parent
3bdf7111ce
commit
175a7b06b7
10 changed files with 335 additions and 17 deletions
|
@ -16,6 +16,7 @@ option(WITH_ASM "Enable ASM PoW implementations" ON)
|
||||||
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)
|
||||||
option(WITH_OPENCL "Enable OpenCL backend" ON)
|
option(WITH_OPENCL "Enable OpenCL backend" ON)
|
||||||
option(WITH_CUDA "Enable CUDA backend" ON)
|
option(WITH_CUDA "Enable CUDA backend" ON)
|
||||||
|
option(WITH_NVML "Enable NVML (NVIDIA Management Library) support (only if CUDA backend enabled)" ON)
|
||||||
option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON)
|
option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON)
|
||||||
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
|
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_NVML
|
||||||
|
#include "backend/cuda/wrappers/NvmlLib.h"
|
||||||
|
|
||||||
|
namespace xmrig { static const char *kNvmlLabel = "NVML"; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,15 +65,16 @@ extern template class Threads<CudaThreads>;
|
||||||
|
|
||||||
|
|
||||||
constexpr const size_t oneMiB = 1024u * 1024u;
|
constexpr const size_t oneMiB = 1024u * 1024u;
|
||||||
|
static const char *kLabel = "CUDA";
|
||||||
static const char *tag = GREEN_BG_BOLD(WHITE_BOLD_S " nv ");
|
static const char *tag = GREEN_BG_BOLD(WHITE_BOLD_S " nv ");
|
||||||
static const String kType = "cuda";
|
static const String kType = "cuda";
|
||||||
static std::mutex mutex;
|
static std::mutex mutex;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void printDisabled(const char *reason)
|
static void printDisabled(const char *label, const char *reason)
|
||||||
{
|
{
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", "CUDA", reason);
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") RED_BOLD("disabled") "%s", label, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,29 +137,44 @@ public:
|
||||||
void init(const CudaConfig &cuda)
|
void init(const CudaConfig &cuda)
|
||||||
{
|
{
|
||||||
if (!cuda.isEnabled()) {
|
if (!cuda.isEnabled()) {
|
||||||
return printDisabled("");
|
return printDisabled(kLabel, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CudaLib::init(cuda.loader())) {
|
if (!CudaLib::init(cuda.loader())) {
|
||||||
return printDisabled(RED_S " (failed to load CUDA plugin)");
|
return printDisabled(kLabel, RED_S " (failed to load CUDA plugin)");
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeVersion = CudaLib::runtimeVersion();
|
runtimeVersion = CudaLib::runtimeVersion();
|
||||||
driverVersion = CudaLib::driverVersion();
|
driverVersion = CudaLib::driverVersion();
|
||||||
|
|
||||||
if (!runtimeVersion || !driverVersion || !CudaLib::deviceCount()) {
|
if (!runtimeVersion || !driverVersion || !CudaLib::deviceCount()) {
|
||||||
return printDisabled(RED_S " (no devices)");
|
return printDisabled(kLabel, RED_S " (no devices)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!devices.empty()) {
|
if (!devices.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" WHITE_BOLD("%s") BLACK_BOLD("/%s"), "CUDA",
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" WHITE_BOLD("%s") BLACK_BOLD("/%s"), kLabel,
|
||||||
CudaLib::version(runtimeVersion).c_str(), CudaLib::version(driverVersion).c_str(), CudaLib::pluginVersion());
|
CudaLib::version(runtimeVersion).c_str(), CudaLib::version(driverVersion).c_str(), CudaLib::pluginVersion());
|
||||||
|
|
||||||
devices = CudaLib::devices(cuda.bfactor(), cuda.bsleep());
|
devices = CudaLib::devices(cuda.bfactor(), cuda.bsleep());
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_NVML
|
||||||
|
if (cuda.isNvmlEnabled()) {
|
||||||
|
if (NvmlLib::init(cuda.nvmlLoader())) {
|
||||||
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s") "/" GREEN_BOLD("%s"), kNvmlLabel,
|
||||||
|
NvmlLib::version(), NvmlLib::driverVersion());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printDisabled(kLabel, RED_S " (failed to load NVML)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printDisabled(kNvmlLabel, "");
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
for (const CudaDevice &device : devices) {
|
for (const CudaDevice &device : devices) {
|
||||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu") YELLOW(" %s") GREEN_BOLD(" %s ") WHITE_BOLD("%u/%u MHz") " smx:" WHITE_BOLD("%u") " arch:" WHITE_BOLD("%u%u") " mem:" CYAN("%zu/%zu") " MB",
|
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("#%zu") YELLOW(" %s") GREEN_BOLD(" %s ") WHITE_BOLD("%u/%u MHz") " smx:" WHITE_BOLD("%u") " arch:" WHITE_BOLD("%u%u") " mem:" CYAN("%zu/%zu") " MB",
|
||||||
"CUDA GPU",
|
"CUDA GPU",
|
||||||
|
@ -238,6 +261,10 @@ xmrig::CudaBackend::~CudaBackend()
|
||||||
delete d_ptr;
|
delete d_ptr;
|
||||||
|
|
||||||
CudaLib::close();
|
CudaLib::close();
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_NVML
|
||||||
|
NvmlLib::close();
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,10 +421,18 @@ rapidjson::Value xmrig::CudaBackend::toJSON(rapidjson::Document &doc) const
|
||||||
out.AddMember("profile", profileName().toJSON(), allocator);
|
out.AddMember("profile", profileName().toJSON(), allocator);
|
||||||
|
|
||||||
Value versions(kObjectType);
|
Value versions(kObjectType);
|
||||||
versions.AddMember("runtime", Value(CudaLib::version(d_ptr->runtimeVersion).c_str(), allocator), allocator);
|
versions.AddMember("cuda-runtime", Value(CudaLib::version(d_ptr->runtimeVersion).c_str(), allocator), allocator);
|
||||||
versions.AddMember("driver", Value(CudaLib::version(d_ptr->driverVersion).c_str(), allocator), allocator);
|
versions.AddMember("cuda-driver", Value(CudaLib::version(d_ptr->driverVersion).c_str(), allocator), allocator);
|
||||||
versions.AddMember("plugin", String(CudaLib::pluginVersion()).toJSON(doc), allocator);
|
versions.AddMember("plugin", String(CudaLib::pluginVersion()).toJSON(doc), allocator);
|
||||||
out.AddMember("versions", versions, allocator);
|
|
||||||
|
# ifdef XMRIG_FEATURE_NVML
|
||||||
|
if (NvmlLib::isReady()) {
|
||||||
|
versions.AddMember("nvml", StringRef(NvmlLib::version()), allocator);
|
||||||
|
versions.AddMember("driver", StringRef(NvmlLib::driverVersion()), allocator);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
out.AddMember("versions", versions, allocator);
|
||||||
|
|
||||||
if (d_ptr->threads.empty() || !hashrate()) {
|
if (d_ptr->threads.empty() || !hashrate()) {
|
||||||
return out;
|
return out;
|
||||||
|
|
|
@ -40,6 +40,10 @@ static const char *kDevicesHint = "devices-hint";
|
||||||
static const char *kEnabled = "enabled";
|
static const char *kEnabled = "enabled";
|
||||||
static const char *kLoader = "loader";
|
static const char *kLoader = "loader";
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_NVML
|
||||||
|
static const char *kNvml = "nvml";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern template class Threads<CudaThreads>;
|
extern template class Threads<CudaThreads>;
|
||||||
|
|
||||||
|
@ -57,6 +61,15 @@ rapidjson::Value xmrig::CudaConfig::toJSON(rapidjson::Document &doc) const
|
||||||
obj.AddMember(StringRef(kEnabled), m_enabled, allocator);
|
obj.AddMember(StringRef(kEnabled), m_enabled, allocator);
|
||||||
obj.AddMember(StringRef(kLoader), m_loader.toJSON(), allocator);
|
obj.AddMember(StringRef(kLoader), m_loader.toJSON(), allocator);
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_NVML
|
||||||
|
if (m_nvmlLoader.isNull()) {
|
||||||
|
obj.AddMember(StringRef(kNvml), m_nvml, allocator);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj.AddMember(StringRef(kNvml), m_nvmlLoader.toJSON(), allocator);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
m_threads.toJSON(obj, doc);
|
m_threads.toJSON(obj, doc);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -95,6 +108,16 @@ void xmrig::CudaConfig::read(const rapidjson::Value &value)
|
||||||
|
|
||||||
setDevicesHint(Json::getString(value, kDevicesHint));
|
setDevicesHint(Json::getString(value, kDevicesHint));
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_NVML
|
||||||
|
auto &nvml = Json::getValue(value, kNvml);
|
||||||
|
if (nvml.IsString()) {
|
||||||
|
m_nvmlLoader = nvml.GetString();
|
||||||
|
}
|
||||||
|
else if (nvml.IsBool()) {
|
||||||
|
m_nvml = nvml.GetBool();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
m_threads.read(value);
|
m_threads.read(value);
|
||||||
|
|
||||||
generate();
|
generate();
|
||||||
|
|
|
@ -50,6 +50,11 @@ public:
|
||||||
inline int32_t bfactor() const { return m_bfactor; }
|
inline int32_t bfactor() const { return m_bfactor; }
|
||||||
inline int32_t bsleep() const { return m_bsleep; }
|
inline int32_t bsleep() const { return m_bsleep; }
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_NVML
|
||||||
|
inline bool isNvmlEnabled() const { return m_nvml; }
|
||||||
|
inline const String &nvmlLoader() const { return m_nvmlLoader; }
|
||||||
|
# endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void generate();
|
void generate();
|
||||||
void setDevicesHint(const char *devicesHint);
|
void setDevicesHint(const char *devicesHint);
|
||||||
|
@ -67,6 +72,11 @@ private:
|
||||||
int32_t m_bfactor = 0;
|
int32_t m_bfactor = 0;
|
||||||
int32_t m_bsleep = 0;
|
int32_t m_bsleep = 0;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_NVML
|
||||||
|
bool m_nvml = true;
|
||||||
|
String m_nvmlLoader;
|
||||||
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,22 @@ if (WITH_CUDA)
|
||||||
src/backend/cuda/wrappers/CudaDevice.cpp
|
src/backend/cuda/wrappers/CudaDevice.cpp
|
||||||
src/backend/cuda/wrappers/CudaLib.cpp
|
src/backend/cuda/wrappers/CudaLib.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (WITH_NVML AND NOT APPLE)
|
||||||
|
add_definitions(/DXMRIG_FEATURE_NVML)
|
||||||
|
|
||||||
|
list(APPEND HEADERS_BACKEND_CUDA
|
||||||
|
src/backend/cuda/wrappers/nvml_lite.h
|
||||||
|
src/backend/cuda/wrappers/NvmlLib.h
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND SOURCES_BACKEND_CUDA src/backend/cuda/wrappers/NvmlLib.cpp)
|
||||||
|
else()
|
||||||
|
remove_definitions(/DXMRIG_FEATURE_NVML)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
remove_definitions(/DXMRIG_FEATURE_CUDA)
|
remove_definitions(/DXMRIG_FEATURE_CUDA)
|
||||||
|
remove_definitions(/DXMRIG_FEATURE_NVML)
|
||||||
|
|
||||||
set(HEADERS_BACKEND_CUDA "")
|
set(HEADERS_BACKEND_CUDA "")
|
||||||
set(SOURCES_BACKEND_CUDA "")
|
set(SOURCES_BACKEND_CUDA "")
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
|
|
||||||
#include "backend/cuda/wrappers/CudaLib.h"
|
#include "backend/cuda/wrappers/CudaLib.h"
|
||||||
#include "base/io/log/Log.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
136
src/backend/cuda/wrappers/NvmlLib.cpp
Normal file
136
src/backend/cuda/wrappers/NvmlLib.cpp
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <uv.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/cuda/wrappers/NvmlLib.h"
|
||||||
|
#include "backend/cuda/wrappers/nvml_lite.h"
|
||||||
|
#include "base/io/log/Log.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
static uv_lib_t nvmlLib;
|
||||||
|
|
||||||
|
|
||||||
|
static const char *kNvmlInit = "nvmlInit_v2";
|
||||||
|
static const char *kNvmlShutdown = "nvmlShutdown";
|
||||||
|
static const char *kNvmlSystemGetDriverVersion = "nvmlSystemGetDriverVersion";
|
||||||
|
static const char *kNvmlSystemGetNVMLVersion = "nvmlSystemGetNVMLVersion";
|
||||||
|
static const char *kSymbolNotFound = "symbol not found";
|
||||||
|
|
||||||
|
|
||||||
|
static nvmlReturn_t (*pNvmlInit)() = nullptr;
|
||||||
|
static nvmlReturn_t (*pNvmlShutdown)() = nullptr;
|
||||||
|
static nvmlReturn_t (*pNvmlSystemGetDriverVersion)(char *version, unsigned int length) = nullptr;
|
||||||
|
static nvmlReturn_t (*pNvmlSystemGetNVMLVersion)(char *version, unsigned int length) = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
#define DLSYM(x) if (uv_dlsym(&nvmlLib, k##x, reinterpret_cast<void**>(&p##x)) == -1) { throw std::runtime_error(kSymbolNotFound); }
|
||||||
|
|
||||||
|
|
||||||
|
bool NvmlLib::m_initialized = false;
|
||||||
|
bool NvmlLib::m_ready = false;
|
||||||
|
char NvmlLib::m_driverVersion[80] = { 0 };
|
||||||
|
char NvmlLib::m_nvmlVersion[80] = { 0 };
|
||||||
|
String NvmlLib::m_loader;
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::NvmlLib::init(const char *fileName)
|
||||||
|
{
|
||||||
|
if (!m_initialized) {
|
||||||
|
m_loader = fileName;
|
||||||
|
m_ready = dlopen() && load();
|
||||||
|
m_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *xmrig::NvmlLib::lastError() noexcept
|
||||||
|
{
|
||||||
|
return uv_dlerror(&nvmlLib);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::NvmlLib::close()
|
||||||
|
{
|
||||||
|
if (m_ready) {
|
||||||
|
pNvmlShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
uv_dlclose(&nvmlLib);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::NvmlLib::dlopen()
|
||||||
|
{
|
||||||
|
if (!m_loader.isNull()) {
|
||||||
|
return uv_dlopen(m_loader, &nvmlLib) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef _WIN32
|
||||||
|
if (uv_dlopen("nvml.dll", &nvmlLib) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
char path[MAX_PATH] = { 0 };
|
||||||
|
ExpandEnvironmentStringsA("%PROGRAMFILES%\\NVIDIA Corporation\\NVSMI\\nvml.dll", path, sizeof(path));
|
||||||
|
|
||||||
|
return uv_dlopen(path, &nvmlLib) == 0;
|
||||||
|
# else
|
||||||
|
return uv_dlopen("libnvidia-ml.so", &nvmlLib) == 0;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::NvmlLib::load()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
DLSYM(NvmlInit);
|
||||||
|
DLSYM(NvmlShutdown);
|
||||||
|
DLSYM(NvmlSystemGetDriverVersion);
|
||||||
|
DLSYM(NvmlSystemGetNVMLVersion);
|
||||||
|
} catch (std::exception &ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pNvmlInit() != NVML_SUCCESS) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pNvmlSystemGetDriverVersion(m_driverVersion, sizeof(m_driverVersion));
|
||||||
|
pNvmlSystemGetNVMLVersion(m_nvmlVersion, sizeof(m_nvmlVersion));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
62
src/backend/cuda/wrappers/NvmlLib.h
Normal file
62
src/backend/cuda/wrappers/NvmlLib.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_NVMLLIB_H
|
||||||
|
#define XMRIG_NVMLLIB_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/tools/String.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class NvmlLib
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool init(const char *fileName = nullptr);
|
||||||
|
static const char *lastError() noexcept;
|
||||||
|
static void close();
|
||||||
|
|
||||||
|
static inline bool isInitialized() noexcept { return m_initialized; }
|
||||||
|
static inline bool isReady() noexcept { return m_ready; }
|
||||||
|
static inline const char *driverVersion() noexcept { return m_driverVersion; }
|
||||||
|
static inline const char *version() noexcept { return m_nvmlVersion; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool dlopen();
|
||||||
|
static bool load();
|
||||||
|
|
||||||
|
static bool m_initialized;
|
||||||
|
static bool m_ready;
|
||||||
|
static char m_driverVersion[80];
|
||||||
|
static char m_nvmlVersion[80];
|
||||||
|
static String m_loader;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_NVMLLIB_H */
|
38
src/backend/cuda/wrappers/nvml_lite.h
Normal file
38
src/backend/cuda/wrappers/nvml_lite.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||||
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
|
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMRIG_NVML_LITE_H
|
||||||
|
#define XMRIG_NVML_LITE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
|
#define NVML_SUCCESS 0
|
||||||
|
|
||||||
|
|
||||||
|
using nvmlReturn_t = uint32_t;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_NVML_LITE_H */
|
|
@ -48,8 +48,8 @@ xmrig::Nonce::Nonce()
|
||||||
{
|
{
|
||||||
m_paused = true;
|
m_paused = true;
|
||||||
|
|
||||||
for (int i = 0; i < MAX; ++i) {
|
for (auto &i : m_sequence) {
|
||||||
m_sequence[i] = 1;
|
i = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,15 +85,15 @@ void xmrig::Nonce::stop()
|
||||||
{
|
{
|
||||||
pause(false);
|
pause(false);
|
||||||
|
|
||||||
for (int i = 0; i < MAX; ++i) {
|
for (auto &i : m_sequence) {
|
||||||
m_sequence[i] = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Nonce::touch()
|
void xmrig::Nonce::touch()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX; ++i) {
|
for (auto &i : m_sequence) {
|
||||||
m_sequence[i]++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue