WIP GPU integration
This commit is contained in:
parent
cbc56a3a64
commit
c91c7cd798
12 changed files with 432 additions and 110 deletions
|
@ -206,7 +206,8 @@ endif()
|
|||
if (WITH_CC_SERVER OR WITH_CC_CLIENT)
|
||||
set(SOURCES_CC_COMMON
|
||||
src/cc/ControlCommand.cpp
|
||||
src/cc/ClientStatus.cpp)
|
||||
src/cc/ClientStatus.cpp
|
||||
src/cc/GPUInfo.cpp)
|
||||
else()
|
||||
add_definitions(/DXMRIG_NO_CC)
|
||||
endif()
|
||||
|
|
|
@ -324,7 +324,7 @@ Options::Options(int argc, char **argv) :
|
|||
m_ccUseTls(false),
|
||||
m_ccUseRemoteLogging(true),
|
||||
m_ccUploadConfigOnStartup(true),
|
||||
m_configFile(Platform::defaultConfigName()),
|
||||
m_fileName(Platform::defaultConfigName()),
|
||||
m_apiToken(nullptr),
|
||||
m_apiWorkerId(nullptr),
|
||||
m_logFile(nullptr),
|
||||
|
@ -856,7 +856,7 @@ Url *Options::parseUrl(const char *arg) const
|
|||
|
||||
void Options::parseConfig(const char *fileName)
|
||||
{
|
||||
m_configFile = fileName;
|
||||
m_fileName = fileName;
|
||||
|
||||
rapidjson::Document doc;
|
||||
if (!getJSON(fileName, doc)) {
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
inline bool ccUseTls() const { return m_ccUseTls; }
|
||||
inline bool ccUseRemoteLogging() const { return m_ccUseRemoteLogging; }
|
||||
inline bool ccUploadConfigOnStartup() const { return m_ccUploadConfigOnStartup; }
|
||||
inline const char *configFile() const { return m_configFile; }
|
||||
inline const char *fileName() const { return m_fileName; }
|
||||
inline const char *apiToken() const { return m_apiToken; }
|
||||
inline const char *apiWorkerId() const { return m_apiWorkerId; }
|
||||
inline const char *logFile() const { return m_logFile; }
|
||||
|
@ -149,7 +149,7 @@ private:
|
|||
bool m_ccUseTls;
|
||||
bool m_ccUseRemoteLogging;
|
||||
bool m_ccUploadConfigOnStartup;
|
||||
const char* m_configFile;
|
||||
const char* m_fileName;
|
||||
char *m_apiToken;
|
||||
char *m_apiWorkerId;
|
||||
char *m_logFile;
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
/* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
/* XMRigCC
|
||||
* Copyright 2017- BenDr0id <ben@graef.in>
|
||||
*
|
||||
*
|
||||
|
@ -28,18 +22,26 @@
|
|||
#include <3rdparty/rapidjson/stringbuffer.h>
|
||||
#include <3rdparty/rapidjson/prettywriter.h>
|
||||
#include <version.h>
|
||||
#include <log/RemoteLog.h>
|
||||
#include <api/NetworkState.h>
|
||||
|
||||
#include "CCClient.h"
|
||||
#include "App.h"
|
||||
#include "Platform.h"
|
||||
#include "Cpu.h"
|
||||
#include "Mem.h"
|
||||
#include "ControlCommand.h"
|
||||
|
||||
#include "api/NetworkState.h"
|
||||
#ifdef TYPE_AMD_GPU
|
||||
#include "common/log/Log.h"
|
||||
#include "common/log/RemoteLog.h"
|
||||
#include "common/Platform.h"
|
||||
#include "core/Config.h"
|
||||
#else
|
||||
#include "Mem.h"
|
||||
#include "log/Log.h"
|
||||
#include "log/RemoteLog.h"
|
||||
#include "Platform.h"
|
||||
#include "api/NetworkState.h"
|
||||
#endif
|
||||
|
||||
#include "workers/Workers.h"
|
||||
#include "workers/Hashrate.h"
|
||||
|
||||
|
@ -55,8 +57,12 @@
|
|||
CCClient* CCClient::m_self = nullptr;
|
||||
uv_mutex_t CCClient::m_mutex;
|
||||
|
||||
CCClient::CCClient(Options* options, uv_async_t* async)
|
||||
: m_options(options),
|
||||
#ifdef TYPE_AMD_GPU
|
||||
CCClient::CCClient(xmrig::Config* config, uv_async_t* async)
|
||||
#else
|
||||
CCClient::CCClient(Options* config, uv_async_t* async)
|
||||
#endif
|
||||
: m_config(config),
|
||||
m_async(async)
|
||||
{
|
||||
uv_mutex_init(&m_mutex);
|
||||
|
@ -64,8 +70,8 @@ CCClient::CCClient(Options* options, uv_async_t* async)
|
|||
m_self = this;
|
||||
|
||||
std::string clientId;
|
||||
if (m_options->ccWorkerId()) {
|
||||
clientId = m_options->ccWorkerId();
|
||||
if (config->ccWorkerId()) {
|
||||
clientId =m_self->m_config->ccWorkerId();
|
||||
} else {
|
||||
char hostname[128];
|
||||
memset(hostname, 0, sizeof(hostname));
|
||||
|
@ -74,27 +80,28 @@ CCClient::CCClient(Options* options, uv_async_t* async)
|
|||
}
|
||||
|
||||
m_clientStatus.setClientId(clientId);
|
||||
|
||||
if (m_options->algoName() != nullptr) {
|
||||
m_clientStatus.setCurrentAlgoName(m_options->algoName());
|
||||
}
|
||||
|
||||
m_clientStatus.setHashFactor(Mem::hashFactor());
|
||||
m_clientStatus.setVersion(Version::string());
|
||||
m_clientStatus.setCpuBrand(Cpu::brand());
|
||||
m_clientStatus.setCpuAES(Cpu::hasAES());
|
||||
m_clientStatus.setCpuSockets(Cpu::sockets());
|
||||
m_clientStatus.setCpuCores(Cpu::cores());
|
||||
m_clientStatus.setCpuThreads(Cpu::threads());
|
||||
m_clientStatus.setCpuSockets(static_cast<int>(Cpu::sockets()));
|
||||
m_clientStatus.setCpuCores(static_cast<int>(Cpu::cores()));
|
||||
m_clientStatus.setCpuThreads(static_cast<int>(Cpu::threads()));
|
||||
m_clientStatus.setCpuX64(Cpu::isX64());
|
||||
m_clientStatus.setCpuL2(Cpu::l2());
|
||||
m_clientStatus.setCpuL3(Cpu::l3());
|
||||
m_clientStatus.setCurrentThreads(m_options->threads());
|
||||
m_clientStatus.setCpuL2(static_cast<int>(Cpu::l2()));
|
||||
m_clientStatus.setCpuL3(static_cast<int>(Cpu::l3()));
|
||||
|
||||
#ifdef TYPE_AMD_GPU
|
||||
m_clientStatus.setCurrentThreads(static_cast<int>(config->threads().size()));
|
||||
m_clientStatus.setCurrentAlgoName(config->algorithm().name());
|
||||
#else
|
||||
m_clientStatus.setCurrentThreads(static_cast<int>(config->threads()));
|
||||
m_clientStatus.setCurrentAlgoName(config->algoName());
|
||||
#endif
|
||||
|
||||
m_startTime = std::chrono::system_clock::now();
|
||||
|
||||
if (m_options->ccToken() != nullptr) {
|
||||
m_authorization = std::string("Bearer ") + m_self->m_options->ccToken();
|
||||
if (config->ccToken() != nullptr) {
|
||||
m_authorization = std::string("Bearer ") + m_self->m_config->ccToken();
|
||||
}
|
||||
|
||||
uv_thread_create(&m_thread, CCClient::onThreadStarted, this);
|
||||
|
@ -133,16 +140,54 @@ void CCClient::updateNetworkState(const NetworkState& network)
|
|||
m_self->m_clientStatus.setHashesTotal(network.total);
|
||||
m_self->m_clientStatus.setAvgTime(network.avgTime());
|
||||
|
||||
#ifdef TYPE_AMD_GPU
|
||||
m_clientStatus.setHashFactor(0);
|
||||
m_self->m_clientStatus.setHugepagesEnabled(false);
|
||||
m_self->m_clientStatus.setHugepages(false);
|
||||
m_self->m_clientStatus.setTotalPages(0);
|
||||
m_self->m_clientStatus.setTotalHugepages(0);
|
||||
m_self->m_clientStatus.setCurrentPowVariantName(xmrig::Algorithm::getVariantName(network.powVariant));
|
||||
#else
|
||||
m_self->m_clientStatus.setHashFactor(Mem::hashFactor());
|
||||
m_self->m_clientStatus.setHugepagesEnabled(Mem::isHugepagesEnabled());
|
||||
m_self->m_clientStatus.setHugepages(Mem::isHugepagesAvailable());
|
||||
m_self->m_clientStatus.setTotalPages(Mem::getTotalPages());
|
||||
m_self->m_clientStatus.setTotalHugepages(Mem::getTotalHugepages());
|
||||
m_self->m_clientStatus.setCurrentPowVariantName(getPowVariantName(network.powVariant));
|
||||
#endif
|
||||
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TYPE_AMD_GPU
|
||||
void CCClient::updateGpuInfo(const std::vector<GpuContext>& gpuContext)
|
||||
{
|
||||
if (m_self) {
|
||||
uv_mutex_lock(&m_mutex);
|
||||
|
||||
m_self->m_clientStatus.clearGPUInfoList();
|
||||
|
||||
for (auto gpu : gpuContext) {
|
||||
GPUInfo gpuInfo;
|
||||
gpuInfo.setName(gpu.name);
|
||||
gpuInfo.setCompMode(gpu.compMode);
|
||||
gpuInfo.setComputeUnits(gpu.computeUnits);
|
||||
gpuInfo.setDeviceIdx(gpu.deviceIdx);
|
||||
gpuInfo.setFreeMem(gpu.freeMem);
|
||||
gpuInfo.setWorkSize(gpu.workSize);
|
||||
gpuInfo.setMaxWorkSize(gpu.maximumWorkSize);
|
||||
gpuInfo.setMemChunk(gpu.memChunk);
|
||||
gpuInfo.setRawIntensity(gpu.rawIntensity);
|
||||
|
||||
m_self->m_clientStatus.addGPUInfo(gpuInfo);
|
||||
}
|
||||
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CCClient::publishClientStatusReport()
|
||||
{
|
||||
std::string requestUrl = "/client/setClientStatus?clientId=" + m_self->m_clientStatus.getClientId();
|
||||
|
@ -151,10 +196,10 @@ void CCClient::publishClientStatusReport()
|
|||
auto res = performRequest(requestUrl, requestBuffer, "POST");
|
||||
if (!res) {
|
||||
LOG_ERR("[CC-Client] error: unable to performRequest POST -> http://%s:%d%s",
|
||||
m_self->m_options->ccHost(), m_self->m_options->ccPort(), requestUrl.c_str());
|
||||
m_self->m_config->ccHost(), m_self->m_config->ccPort(), requestUrl.c_str());
|
||||
} else if (res->status != 200) {
|
||||
LOG_ERR("[CC-Client] error: \"%d\" -> http://%s:%d%s", res->status, m_self->m_options->ccHost(),
|
||||
m_self->m_options->ccPort(), requestUrl.c_str());
|
||||
LOG_ERR("[CC-Client] error: \"%d\" -> http://%s:%d%s", res->status,m_self->m_config->ccHost(),
|
||||
m_self->m_config->ccPort(), requestUrl.c_str());
|
||||
} else {
|
||||
ControlCommand controlCommand;
|
||||
if (controlCommand.parseFromJsonString(res->body)) {
|
||||
|
@ -194,14 +239,14 @@ void CCClient::updateConfig()
|
|||
auto res = performRequest(requestUrl, requestBuffer, "GET");
|
||||
if (!res) {
|
||||
LOG_ERR("[CC-Client] error: unable to performRequest GET -> http://%s:%d%s",
|
||||
m_self->m_options->ccHost(), m_self->m_options->ccPort(), requestUrl.c_str());
|
||||
m_self->m_config->ccHost(), m_self->m_config->ccPort(), requestUrl.c_str());
|
||||
} else if (res->status != 200) {
|
||||
LOG_ERR("[CC-Client] error: \"%d\" -> http://%s:%d%s", res->status, m_self->m_options->ccHost(),
|
||||
m_self->m_options->ccPort(), requestUrl.c_str());
|
||||
LOG_ERR("[CC-Client] error: \"%d\" -> http://%s:%d%s", res->status, m_self->m_config->ccHost(),
|
||||
m_self->m_config->ccPort(), requestUrl.c_str());
|
||||
} else {
|
||||
rapidjson::Document document;
|
||||
if (!document.Parse(res->body.c_str()).HasParseError()) {
|
||||
std::ofstream clientConfigFile(m_self->m_options->configFile());
|
||||
std::ofstream clientConfigFile(m_self->m_config->fileName());
|
||||
if (clientConfigFile) {
|
||||
rapidjson::StringBuffer buffer(0, 65536);
|
||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
||||
|
@ -213,7 +258,7 @@ void CCClient::updateConfig()
|
|||
|
||||
LOG_WARN("[CC-Client] Config updated. -> trigger restart");
|
||||
} else {
|
||||
LOG_ERR("[CC-Client] Not able to store client config to file %s.", m_self->m_options->configFile());
|
||||
LOG_ERR("[CC-Client] Not able to store client config to file %s.", m_self->m_config->fileName());
|
||||
}
|
||||
} else {
|
||||
LOG_ERR("[CC-Client] Not able to store client config. received client config is broken!");
|
||||
|
@ -226,7 +271,7 @@ void CCClient::publishConfig()
|
|||
std::string requestUrl = "/client/setClientConfig?clientId=" + m_self->m_clientStatus.getClientId();
|
||||
|
||||
std::stringstream data;
|
||||
std::ifstream clientConfig(m_self->m_options->configFile());
|
||||
std::ifstream clientConfig(m_self->m_config->fileName());
|
||||
|
||||
if (clientConfig) {
|
||||
data << clientConfig.rdbuf();
|
||||
|
@ -246,16 +291,16 @@ void CCClient::publishConfig()
|
|||
auto res = performRequest(requestUrl, buffer.GetString(), "POST");
|
||||
if (!res) {
|
||||
LOG_ERR("[CC-Client] error: unable to performRequest POST -> http://%s:%d%s",
|
||||
m_self->m_options->ccHost(), m_self->m_options->ccPort(), requestUrl.c_str());
|
||||
m_self->m_config->ccHost(), m_self->m_config->ccPort(), requestUrl.c_str());
|
||||
} else if (res->status != 200) {
|
||||
LOG_ERR("[CC-Client] error: \"%d\" -> http://%s:%d%s", res->status, m_self->m_options->ccHost(),
|
||||
m_self->m_options->ccPort(), requestUrl.c_str());
|
||||
LOG_ERR("[CC-Client] error: \"%d\" -> http://%s:%d%s", res->status, m_self->m_config->ccHost(),
|
||||
m_self->m_config->ccPort(), requestUrl.c_str());
|
||||
}
|
||||
} else {
|
||||
LOG_ERR("Not able to send config. Client config %s is broken!", m_self->m_options->configFile());
|
||||
LOG_ERR("Not able to send config. Client config %s is broken!", m_self->m_config->fileName());
|
||||
}
|
||||
} else {
|
||||
LOG_ERR("Not able to load client config %s. Please make sure it exists!", m_self->m_options->configFile());
|
||||
LOG_ERR("Not able to load client config %s. Please make sure it exists!", m_self->m_config->fileName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,11 +311,11 @@ std::shared_ptr<httplib::Response> CCClient::performRequest(const std::string& r
|
|||
std::shared_ptr<httplib::Client> cli;
|
||||
|
||||
# ifndef XMRIG_NO_TLS
|
||||
if (m_self->m_options->ccUseTls()) {
|
||||
cli = std::make_shared<httplib::SSLClient>(m_self->m_options->ccHost(), m_self->m_options->ccPort(), 10);
|
||||
if (m_self->m_config->ccUseTls()) {
|
||||
cli = std::make_shared<httplib::SSLClient>(m_self->m_config->ccHost(), m_self->m_config->ccPort(), 10);
|
||||
} else {
|
||||
# endif
|
||||
cli = std::make_shared<httplib::Client>(m_self->m_options->ccHost(), m_self->m_options->ccPort(), 10);
|
||||
cli = std::make_shared<httplib::Client>(m_self->m_config->ccHost(), m_self->m_config->ccPort(), 10);
|
||||
# ifndef XMRIG_NO_TLS
|
||||
}
|
||||
# endif
|
||||
|
@ -317,10 +362,10 @@ void CCClient::onThreadStarted(void* handle)
|
|||
|
||||
uv_timer_init(&m_self->m_client_loop, &m_self->m_timer);
|
||||
uv_timer_start(&m_self->m_timer, CCClient::onReport,
|
||||
static_cast<uint64_t>(m_self->m_options->ccUpdateInterval() * 1000),
|
||||
static_cast<uint64_t>(m_self->m_options->ccUpdateInterval() * 1000));
|
||||
static_cast<uint64_t>(m_self->m_config->ccUpdateInterval() * 1000),
|
||||
static_cast<uint64_t>(m_self->m_config->ccUpdateInterval() * 1000));
|
||||
|
||||
if (m_self->m_options->ccUploadConfigOnStartup()) {
|
||||
if (m_self->m_config->ccUploadConfigOnStartup()) {
|
||||
m_self->publishConfig();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
/* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
/* XMRigCC
|
||||
* Copyright 2017- BenDr0id <ben@graef.in>
|
||||
*
|
||||
*
|
||||
|
@ -31,8 +25,15 @@
|
|||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <3rdparty/cpp-httplib/httplib.h>
|
||||
#include "Options.h"
|
||||
#include "ClientStatus.h"
|
||||
#include "version.h"
|
||||
|
||||
#ifdef TYPE_AMD_GPU
|
||||
#include "amd/GpuContext.h"
|
||||
#include "core/Controller.h"
|
||||
#else
|
||||
#include "Options.h"
|
||||
#endif
|
||||
|
||||
class Hashrate;
|
||||
class NetworkState;
|
||||
|
@ -40,7 +41,13 @@ class NetworkState;
|
|||
class CCClient
|
||||
{
|
||||
public:
|
||||
CCClient(Options *options, uv_async_t* async);
|
||||
#ifdef TYPE_AMD_GPU
|
||||
CCClient(xmrig::Config* m_config, uv_async_t* async);
|
||||
static void updateGpuInfo(const std::vector<GpuContext>& network);
|
||||
#else
|
||||
CCClient(Options* config, uv_async_t* async);
|
||||
#endif
|
||||
|
||||
~CCClient();
|
||||
|
||||
static void updateHashrate(const Hashrate *hashrate);
|
||||
|
@ -60,7 +67,11 @@ private:
|
|||
static void onThreadStarted(void *handle);
|
||||
static void onReport(uv_timer_t *handle);
|
||||
|
||||
const Options* m_options;
|
||||
#ifdef TYPE_AMD_GPU
|
||||
const xmrig::Config* m_config;
|
||||
#else
|
||||
const Options* m_config;
|
||||
#endif
|
||||
|
||||
static CCClient* m_self;
|
||||
static uv_mutex_t m_mutex;
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
/* XMRigCC
|
||||
* Copyright 2017- BenDr0id <ben@graef.in>
|
||||
*
|
||||
*
|
||||
* 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
|
||||
|
@ -27,7 +20,6 @@
|
|||
#include <cstring>
|
||||
#include <3rdparty/rapidjson/stringbuffer.h>
|
||||
#include <3rdparty/rapidjson/prettywriter.h>
|
||||
#include <log/Log.h>
|
||||
|
||||
#include "ClientStatus.h"
|
||||
|
||||
|
@ -491,6 +483,18 @@ bool ClientStatus::parseFromJson(const rapidjson::Document& document)
|
|||
m_cpuL3 = clientStatus["cpu_l3"].GetInt();
|
||||
}
|
||||
|
||||
if (clientStatus.HasMember("gpu_info_list") && clientStatus["gpu_info_list"].IsArray()) {
|
||||
m_gpuInfoList.clear();
|
||||
|
||||
auto gpuInfoList = clientStatus["gpu_info_list"].GetArray();
|
||||
for (rapidjson::Value::ConstValueIterator itr = gpuInfoList.Begin(); itr != gpuInfoList.End(); ++itr) {
|
||||
GPUInfo gpuInfo;
|
||||
gpuInfo.parseFromJson((*itr)["gpu_info"]);
|
||||
|
||||
m_gpuInfoList.push_back(gpuInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (clientStatus.HasMember("shares_good")) {
|
||||
m_sharesGood = clientStatus["shares_good"].GetUint64();
|
||||
}
|
||||
|
@ -515,8 +519,6 @@ bool ClientStatus::parseFromJson(const rapidjson::Document& document)
|
|||
m_lastStatusUpdate = std::chrono::system_clock::to_time_t(time_point);
|
||||
|
||||
result = true;
|
||||
} else {
|
||||
LOG_ERR("Parse Error, JSON does not contain: control_command");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -556,6 +558,14 @@ rapidjson::Value ClientStatus::toJson(rapidjson::MemoryPoolAllocator<rapidjson::
|
|||
clientStatus.AddMember("cpu_l2", m_cpuL2, allocator);
|
||||
clientStatus.AddMember("cpu_l3", m_cpuL3, allocator);
|
||||
|
||||
rapidjson::Value gpuInfoList(rapidjson::kArrayType);
|
||||
for (auto& gpuInfo : m_gpuInfoList) {
|
||||
rapidjson::Value gpuInfoEntry(rapidjson::kObjectType);
|
||||
gpuInfoEntry.AddMember("gpu_info", gpuInfo.toJson(allocator), allocator);
|
||||
gpuInfoList.PushBack(gpuInfoEntry, allocator);
|
||||
}
|
||||
clientStatus.AddMember("gpu_info_list", gpuInfoList, allocator);
|
||||
|
||||
clientStatus.AddMember("shares_good", m_sharesGood, allocator);
|
||||
clientStatus.AddMember("shares_total", m_sharesTotal, allocator);
|
||||
clientStatus.AddMember("hashes_total", m_hashesTotal, allocator);
|
||||
|
@ -563,9 +573,7 @@ rapidjson::Value ClientStatus::toJson(rapidjson::MemoryPoolAllocator<rapidjson::
|
|||
clientStatus.AddMember("avg_time", m_avgTime, allocator);
|
||||
|
||||
clientStatus.AddMember("uptime", m_uptime, allocator);
|
||||
|
||||
clientStatus.AddMember("last_status_update", static_cast<uint64_t >(m_lastStatusUpdate), allocator);
|
||||
|
||||
clientStatus.AddMember("log", rapidjson::StringRef(m_log.c_str()), allocator);
|
||||
|
||||
|
||||
|
@ -589,3 +597,13 @@ std::string ClientStatus::toJsonString()
|
|||
|
||||
return strdup(buffer.GetString());
|
||||
}
|
||||
|
||||
void ClientStatus::clearGPUInfoList()
|
||||
{
|
||||
m_gpuInfoList.clear();
|
||||
}
|
||||
|
||||
void ClientStatus::addGPUInfo(const GPUInfo gpuInfo)
|
||||
{
|
||||
m_gpuInfoList.push_back(gpuInfo);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
/* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
/* XMRigCC
|
||||
* Copyright 2017- BenDr0id <ben@graef.in>
|
||||
*
|
||||
*
|
||||
|
@ -27,7 +21,9 @@
|
|||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
#include <list>
|
||||
#include <rapidjson/document.h>
|
||||
#include "GPUInfo.h"
|
||||
|
||||
class ClientStatus
|
||||
{
|
||||
|
@ -136,6 +132,10 @@ public:
|
|||
int getCpuL3() const;
|
||||
void setCpuL3(int cpuL3);
|
||||
|
||||
const std::list<GPUInfo> getGPUInfoList() const;
|
||||
void addGPUInfo(const GPUInfo gpuInfo);
|
||||
void clearGPUInfoList();
|
||||
|
||||
uint64_t getSharesGood() const;
|
||||
void setSharesGood(uint64_t sharesGood);
|
||||
|
||||
|
@ -157,7 +157,6 @@ public:
|
|||
rapidjson::Value toJson(rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>& allocator);
|
||||
bool parseFromJson(const rapidjson::Document& document);
|
||||
|
||||
|
||||
private:
|
||||
const char* status_str[3] = {
|
||||
"RUNNING",
|
||||
|
@ -196,6 +195,8 @@ private:
|
|||
int m_cpuL2;
|
||||
int m_cpuL3;
|
||||
|
||||
std::list<GPUInfo> m_gpuInfoList;
|
||||
|
||||
uint64_t m_sharesGood;
|
||||
uint64_t m_sharesTotal;
|
||||
uint64_t m_hashesTotal;
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
/* XMRigCC
|
||||
* Copyright 2017- BenDr0id <ben@graef.in>
|
||||
*
|
||||
*
|
||||
* 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
|
||||
|
@ -25,7 +18,12 @@
|
|||
#include <3rdparty/rapidjson/stringbuffer.h>
|
||||
#include <3rdparty/rapidjson/prettywriter.h>
|
||||
|
||||
#ifdef TYPE_AMD_GPU
|
||||
#include "common/log/Log.h"
|
||||
#else
|
||||
#include "log/Log.h"
|
||||
#endif
|
||||
|
||||
#include "ControlCommand.h"
|
||||
|
||||
ControlCommand::ControlCommand()
|
||||
|
@ -81,7 +79,7 @@ rapidjson::Value ControlCommand::toJson(rapidjson::MemoryPoolAllocator<rapidjson
|
|||
return controlCommand;
|
||||
}
|
||||
|
||||
void ControlCommand::setCommand(Command command)
|
||||
void ControlCommand::setCommand(const Command& command)
|
||||
{
|
||||
m_command = command;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
/* 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 2016-2017 XMRig <support@xmrig.com>
|
||||
/* XMRigCC
|
||||
* Copyright 2017- BenDr0id <ben@graef.in>
|
||||
*
|
||||
*
|
||||
* 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
|
||||
|
@ -74,7 +67,7 @@ public:
|
|||
bool parseFromJson(const rapidjson::Document& document);
|
||||
|
||||
Command getCommand() const;
|
||||
void setCommand(Command command);
|
||||
void setCommand(const Command& command);
|
||||
|
||||
bool isOneTimeCommand() const;
|
||||
|
||||
|
|
187
src/cc/GPUInfo.cpp
Normal file
187
src/cc/GPUInfo.cpp
Normal file
|
@ -0,0 +1,187 @@
|
|||
/* XMRigCC
|
||||
* Copyright 2018- BenDr0id <ben@graef.in>
|
||||
*
|
||||
* 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 "GPUInfo.h"
|
||||
|
||||
GPUInfo::GPUInfo()
|
||||
: m_deviceIdx(0),
|
||||
m_rawIntensity(0),
|
||||
m_workSize(0),
|
||||
m_maxWorkSize(0),
|
||||
m_freeMem(0),
|
||||
m_memChunk(0),
|
||||
m_compMode(0),
|
||||
m_computeUnits(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GPUInfo::~GPUInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
rapidjson::Value GPUInfo::toJson(rapidjson::MemoryPoolAllocator <rapidjson::CrtAllocator>& allocator)
|
||||
{
|
||||
rapidjson::Value gpuInfo(rapidjson::kObjectType);
|
||||
|
||||
gpuInfo.AddMember("name", rapidjson::StringRef(m_name.c_str()), allocator);
|
||||
gpuInfo.AddMember("device_idx", m_deviceIdx, allocator);
|
||||
gpuInfo.AddMember("raw_intensity", m_rawIntensity, allocator);
|
||||
gpuInfo.AddMember("work_size", m_workSize, allocator);
|
||||
gpuInfo.AddMember("max_work_size", m_maxWorkSize, allocator);
|
||||
gpuInfo.AddMember("free_mem", m_freeMem, allocator);
|
||||
gpuInfo.AddMember("mem_chunk", m_memChunk, allocator);
|
||||
gpuInfo.AddMember("comp_mode", m_memChunk, allocator);
|
||||
gpuInfo.AddMember("compute_units", m_memChunk, allocator);
|
||||
|
||||
return gpuInfo;
|
||||
}
|
||||
|
||||
bool GPUInfo::parseFromJson(const rapidjson::Value& gpuInfo)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (gpuInfo.HasMember("name")) {
|
||||
m_name = gpuInfo["name"].GetString();
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("device_idx")) {
|
||||
m_deviceIdx = static_cast<size_t>(gpuInfo["device_idx"].GetInt());
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("raw_intensity")) {
|
||||
m_rawIntensity = static_cast<size_t>(gpuInfo["raw_intensity"].GetInt());
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("work_size")) {
|
||||
m_workSize = static_cast<size_t>(gpuInfo["work_size"].GetInt());
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("max_work_size")) {
|
||||
m_maxWorkSize = static_cast<size_t>(gpuInfo["max_work_size"].GetInt());
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("free_mem")) {
|
||||
m_freeMem = static_cast<size_t>(gpuInfo["free_mem"].GetInt());
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("mem_chunk")) {
|
||||
m_memChunk = gpuInfo["mem_chunk"].GetInt();
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("comp_mode")) {
|
||||
m_compMode = gpuInfo["comp_mode"].GetInt();
|
||||
}
|
||||
|
||||
if (gpuInfo.HasMember("compute_units")) {
|
||||
m_computeUnits = gpuInfo["compute_units"].GetInt();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t GPUInfo::getDeviceIdx() const
|
||||
{
|
||||
return m_deviceIdx;
|
||||
}
|
||||
|
||||
void GPUInfo::setDeviceIdx(size_t deviceIdx)
|
||||
{
|
||||
m_deviceIdx = deviceIdx;
|
||||
}
|
||||
|
||||
size_t GPUInfo::getRawIntensity() const
|
||||
{
|
||||
return m_rawIntensity;
|
||||
}
|
||||
|
||||
void GPUInfo::setRawIntensity(size_t rawIntensity)
|
||||
{
|
||||
m_rawIntensity = rawIntensity;
|
||||
}
|
||||
|
||||
size_t GPUInfo::getWorkSize() const
|
||||
{
|
||||
return m_workSize;
|
||||
}
|
||||
|
||||
void GPUInfo::setWorkSize(size_t workSize)
|
||||
{
|
||||
m_workSize = workSize;
|
||||
}
|
||||
|
||||
size_t GPUInfo::getMaxWorkSize() const
|
||||
{
|
||||
return m_maxWorkSize;
|
||||
}
|
||||
|
||||
void GPUInfo::setMaxWorkSize(size_t maxWorkSize)
|
||||
{
|
||||
m_maxWorkSize = maxWorkSize;
|
||||
}
|
||||
|
||||
size_t GPUInfo::getFreeMem() const
|
||||
{
|
||||
return m_freeMem;
|
||||
}
|
||||
|
||||
void GPUInfo::setFreeMem(size_t freeMem)
|
||||
{
|
||||
m_freeMem = freeMem;
|
||||
}
|
||||
|
||||
int GPUInfo::getMemChunk() const
|
||||
{
|
||||
return m_memChunk;
|
||||
}
|
||||
|
||||
void GPUInfo::setMemChunk(int memChunk)
|
||||
{
|
||||
m_memChunk = memChunk;
|
||||
}
|
||||
|
||||
int GPUInfo::getCompMode() const
|
||||
{
|
||||
return m_compMode;
|
||||
}
|
||||
|
||||
void GPUInfo::setCompMode(int compMode)
|
||||
{
|
||||
m_compMode = compMode;
|
||||
}
|
||||
|
||||
int GPUInfo::getComputeUnits() const
|
||||
{
|
||||
return m_computeUnits;
|
||||
}
|
||||
|
||||
void GPUInfo::setComputeUnits(int computeUnits)
|
||||
{
|
||||
m_computeUnits = computeUnits;
|
||||
}
|
||||
|
||||
std::string GPUInfo::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void GPUInfo::setName(const std::string& name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
75
src/cc/GPUInfo.h
Normal file
75
src/cc/GPUInfo.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* XMRigCC
|
||||
* Copyright 2018- BenDr0id <ben@graef.in>
|
||||
*
|
||||
* 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_GPUINFO_H
|
||||
#define XMRIG_GPUINFO_H
|
||||
|
||||
#include <string>
|
||||
#include <3rdparty/rapidjson/document.h>
|
||||
|
||||
class GPUInfo
|
||||
{
|
||||
public:
|
||||
GPUInfo();
|
||||
~GPUInfo();
|
||||
|
||||
rapidjson::Value toJson(rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>& allocator);
|
||||
bool parseFromJson(const rapidjson::Value& gpuInfo);
|
||||
|
||||
std::string getName() const;
|
||||
void setName(const std::string& name);
|
||||
|
||||
size_t getDeviceIdx() const;
|
||||
void setDeviceIdx(size_t deviceIdx);
|
||||
|
||||
size_t getRawIntensity() const;
|
||||
void setRawIntensity(size_t rawIntensity);
|
||||
|
||||
size_t getWorkSize() const;
|
||||
void setWorkSize(size_t workSize);
|
||||
|
||||
size_t getMaxWorkSize() const;
|
||||
void setMaxWorkSize(size_t maxWorkSize);
|
||||
|
||||
size_t getFreeMem() const;
|
||||
void setFreeMem(size_t freeMem);
|
||||
|
||||
int getMemChunk() const;
|
||||
void setMemChunk(int memChunk);
|
||||
|
||||
int getCompMode() const;
|
||||
void setCompMode(int compMode);
|
||||
|
||||
int getComputeUnits() const;
|
||||
void setComputeUnits(int computeUnits);
|
||||
|
||||
private:
|
||||
size_t m_deviceIdx;
|
||||
size_t m_rawIntensity;
|
||||
size_t m_workSize;
|
||||
size_t m_maxWorkSize;
|
||||
size_t m_freeMem;
|
||||
|
||||
int m_memChunk;
|
||||
int m_compMode;
|
||||
int m_computeUnits;
|
||||
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
#endif //XMRIG_GPUINFO_H
|
|
@ -1,7 +0,0 @@
|
|||
# XMRigCC common repository
|
||||
This repository contains all common XMRigCC files.
|
||||
|
||||
# Used in this repos
|
||||
* [xmrigCC](https://github.com/bendr0id/xmrigCC)
|
||||
* [xmrigCC-nvidia](https://github.com/bendr0id/xmrigCC-nvidia)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue