mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 03:59:41 +00:00
Removed unused code.
This commit is contained in:
parent
630a5dce67
commit
6f93b7b38d
12 changed files with 19 additions and 591 deletions
|
@ -42,7 +42,6 @@ set(HEADERS
|
|||
src/net/strategies/DonateStrategy.h
|
||||
src/Summary.h
|
||||
src/version.h
|
||||
src/workers/CpuThreadLegacy.h
|
||||
)
|
||||
|
||||
set(HEADERS_CRYPTO
|
||||
|
@ -88,7 +87,6 @@ set(SOURCES
|
|||
src/net/NetworkState.cpp
|
||||
src/net/strategies/DonateStrategy.cpp
|
||||
src/Summary.cpp
|
||||
src/workers/CpuThreadLegacy.cpp
|
||||
src/xmrig.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -84,29 +84,11 @@ static void print_cpu(xmrig::Config *)
|
|||
|
||||
static void print_threads(xmrig::Config *config)
|
||||
{
|
||||
if (config->threadsMode() != xmrig::Config::Advanced) {
|
||||
char buf[32] = { 0 };
|
||||
// if (config->affinity() != -1L) {
|
||||
// snprintf(buf, sizeof buf, ", affinity=0x%" PRIX64, config->affinity());
|
||||
// }
|
||||
|
||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", av=%d, %sdonate=%d%%") WHITE_BOLD("%s"),
|
||||
"THREADS",
|
||||
config->threadsCount(),
|
||||
config->algoVariant(),
|
||||
config->pools().donateLevel() == 0 ? RED_BOLD_S : "",
|
||||
config->pools().donateLevel(),
|
||||
buf
|
||||
);
|
||||
}
|
||||
else {
|
||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%d") WHITE_BOLD(", %sdonate=%d%%"),
|
||||
"THREADS",
|
||||
config->threadsCount(),
|
||||
config->pools().donateLevel() == 0 ? RED_BOLD_S : "",
|
||||
config->pools().donateLevel()
|
||||
);
|
||||
}
|
||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") WHITE_BOLD("%s%d%%"),
|
||||
"DONATE",
|
||||
config->pools().donateLevel() == 0 ? RED_BOLD_S : "",
|
||||
config->pools().donateLevel()
|
||||
);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
if (config->cpu().assembly() == xmrig::Assembly::AUTO) {
|
||||
|
|
|
@ -55,7 +55,6 @@ public:
|
|||
virtual size_t L2() const = 0;
|
||||
virtual size_t L3() const = 0;
|
||||
virtual size_t nodes() const = 0;
|
||||
virtual size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const = 0;
|
||||
virtual size_t sockets() const = 0;
|
||||
virtual size_t threads() const = 0;
|
||||
};
|
||||
|
|
|
@ -80,45 +80,6 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
|||
}
|
||||
|
||||
|
||||
size_t xmrig::AdvancedCpuInfo::optimalThreadsCount(size_t memSize, int maxCpuUsage) const
|
||||
{
|
||||
if (threads() == 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t cache = 0;
|
||||
if (m_L3) {
|
||||
cache = m_L2_exclusive ? (m_L2 + m_L3) : m_L3;
|
||||
}
|
||||
else {
|
||||
cache = m_L2;
|
||||
}
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
if (cache) {
|
||||
count = cache / memSize;
|
||||
|
||||
if (cache % memSize >= memSize / 2) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
count = threads() / 2;
|
||||
}
|
||||
|
||||
if (count > (size_t) threads()) {
|
||||
count = threads();
|
||||
}
|
||||
|
||||
if (((float) count / threads() * 100) > maxCpuUsage) {
|
||||
count = (int) ceil((float) threads() * (maxCpuUsage / 100.0));
|
||||
}
|
||||
|
||||
return count < 1 ? 1 : count;
|
||||
}
|
||||
|
||||
|
||||
xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm) const
|
||||
{
|
||||
if (threads() == 1) {
|
||||
|
|
|
@ -38,7 +38,6 @@ public:
|
|||
AdvancedCpuInfo();
|
||||
|
||||
protected:
|
||||
size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override;
|
||||
CpuThreads threads(const Algorithm &algorithm) const override;
|
||||
|
||||
inline Assembly::Id assembly() const override { return m_assembly; }
|
||||
|
|
|
@ -153,14 +153,6 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
|||
}
|
||||
|
||||
|
||||
size_t xmrig::BasicCpuInfo::optimalThreadsCount(size_t memSize, int maxCpuUsage) const
|
||||
{
|
||||
const size_t count = threads() / 2;
|
||||
|
||||
return count < 1 ? 1 : count;
|
||||
}
|
||||
|
||||
|
||||
xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm) const
|
||||
{
|
||||
if (threads() == 1) {
|
||||
|
|
|
@ -38,7 +38,6 @@ public:
|
|||
BasicCpuInfo();
|
||||
|
||||
protected:
|
||||
size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override;
|
||||
CpuThreads threads(const Algorithm &algorithm) const override;
|
||||
|
||||
inline Assembly::Id assembly() const override { return m_assembly; }
|
||||
|
|
|
@ -57,12 +57,6 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
|||
}
|
||||
|
||||
|
||||
size_t xmrig::BasicCpuInfo::optimalThreadsCount(size_t memSize, int maxCpuUsage) const
|
||||
{
|
||||
return threads();
|
||||
}
|
||||
|
||||
|
||||
xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm) const
|
||||
{
|
||||
return CpuThreads(threads());
|
||||
|
|
|
@ -36,12 +36,9 @@
|
|||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include "rapidjson/prettywriter.h"
|
||||
#include "workers/CpuThreadLegacy.h"
|
||||
|
||||
|
||||
xmrig::Config::Config() :
|
||||
m_algoVariant(CnHash::AV_AUTO),
|
||||
m_shouldSave(false)
|
||||
xmrig::Config::Config() : BaseConfig()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -54,10 +51,7 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
|||
|
||||
m_cpu.read(reader.getValue("cpu"));
|
||||
|
||||
setAlgoVariant(reader.getInt("av"));
|
||||
setThreads(reader.getValue("threads"));
|
||||
|
||||
return finalize();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,148 +66,21 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
Value api(kObjectType);
|
||||
api.AddMember("id", m_apiId.toJSON(), allocator);
|
||||
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
|
||||
doc.AddMember("api", api, allocator);
|
||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||
doc.AddMember("av", algoVariant(), allocator);
|
||||
doc.AddMember("background", isBackground(), allocator);
|
||||
doc.AddMember("colors", Log::colors, allocator);
|
||||
|
||||
doc.AddMember("cpu", m_cpu.toJSON(doc), allocator);
|
||||
|
||||
doc.AddMember("api", api, allocator);
|
||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||
doc.AddMember("background", isBackground(), allocator);
|
||||
doc.AddMember("colors", Log::colors, allocator);
|
||||
doc.AddMember("cpu", m_cpu.toJSON(doc), allocator);
|
||||
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
||||
doc.AddMember("donate-over-proxy", m_pools.proxyDonate(), allocator);
|
||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
|
||||
doc.AddMember("pools", m_pools.toJSON(doc), allocator);
|
||||
doc.AddMember("print-time", printTime(), allocator);
|
||||
doc.AddMember("retries", m_pools.retries(), allocator);
|
||||
doc.AddMember("retry-pause", m_pools.retryPause(), allocator);
|
||||
|
||||
if (threadsMode() != Simple) {
|
||||
Value threads(kArrayType);
|
||||
|
||||
for (const IThread *thread : m_threads.list) {
|
||||
threads.PushBack(thread->toConfig(doc), allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("threads", threads, allocator);
|
||||
}
|
||||
else {
|
||||
doc.AddMember("threads", threadsCount(), allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
|
||||
doc.AddMember("syslog", isSyslog(), allocator);
|
||||
doc.AddMember("watch", m_watch, allocator);
|
||||
doc.AddMember("syslog", isSyslog(), allocator);
|
||||
doc.AddMember("user-agent", m_userAgent.toJSON(), allocator);
|
||||
doc.AddMember("watch", m_watch, allocator);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Config::finalize()
|
||||
{
|
||||
Algorithm algorithm(Algorithm::RX_WOW); // FIXME algo
|
||||
|
||||
if (!m_threads.cpu.empty()) {
|
||||
m_threads.mode = Advanced;
|
||||
|
||||
for (size_t i = 0; i < m_threads.cpu.size(); ++i) {
|
||||
m_threads.list.push_back(CpuThreadLegacy::createFromData(i, algorithm, m_threads.cpu[i], m_cpu.priority(), !m_cpu.isHwAES()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const CnHash::AlgoVariant av = getAlgoVariant();
|
||||
m_threads.mode = m_threads.count ? Simple : Automatic;
|
||||
|
||||
const size_t size = CpuThreadLegacy::multiway(av) * CnAlgo<>::memory(algorithm) / 1024; // FIXME MEMORY
|
||||
|
||||
if (!m_threads.count) {
|
||||
m_threads.count = Cpu::info()->optimalThreadsCount(size, 100);
|
||||
}
|
||||
// else if (m_safe) {
|
||||
// const size_t count = Cpu::info()->optimalThreadsCount(size, m_maxCpuUsage);
|
||||
// if (m_threads.count > count) {
|
||||
// m_threads.count = count;
|
||||
// }
|
||||
// }
|
||||
|
||||
for (size_t i = 0; i < m_threads.count; ++i) {
|
||||
m_threads.list.push_back(CpuThreadLegacy::createFromAV(i, algorithm, av, m_threads.mask, m_cpu.priority(), m_cpu.assembly()));
|
||||
}
|
||||
|
||||
m_shouldSave = m_threads.mode == Automatic;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setAlgoVariant(int av)
|
||||
{
|
||||
if (av >= CnHash::AV_AUTO && av < CnHash::AV_MAX) {
|
||||
m_algoVariant = static_cast<CnHash::AlgoVariant>(av);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setThreads(const rapidjson::Value &threads)
|
||||
{
|
||||
if (threads.IsArray()) {
|
||||
m_threads.cpu.clear();
|
||||
|
||||
for (const rapidjson::Value &value : threads.GetArray()) {
|
||||
if (!value.IsObject()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.HasMember("low_power_mode")) {
|
||||
auto data = CpuThreadLegacy::parse(value);
|
||||
|
||||
if (data.valid) {
|
||||
m_threads.cpu.push_back(std::move(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (threads.IsUint()) {
|
||||
const unsigned count = threads.GetUint();
|
||||
if (count < 1024) {
|
||||
m_threads.count = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::CnHash::AlgoVariant xmrig::Config::getAlgoVariant() const
|
||||
{
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
// if (m_algorithm.algo() == xmrig::CRYPTONIGHT_LITE) { // FIXME
|
||||
// return getAlgoVariantLite();
|
||||
// }
|
||||
# endif
|
||||
|
||||
if (m_algoVariant <= CnHash::AV_AUTO || m_algoVariant >= CnHash::AV_MAX) {
|
||||
return Cpu::info()->hasAES() ? CnHash::AV_SINGLE : CnHash::AV_SINGLE_SOFT;
|
||||
}
|
||||
|
||||
// if (m_safe && !Cpu::info()->hasAES() && m_algoVariant <= AV_DOUBLE) {
|
||||
// return static_cast<AlgoVariant>(m_algoVariant + 2);
|
||||
// }
|
||||
|
||||
return m_algoVariant;
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_LITE
|
||||
xmrig::CnHash::AlgoVariant xmrig::Config::getAlgoVariantLite() const
|
||||
{
|
||||
if (m_algoVariant <= CnHash::AV_AUTO || m_algoVariant >= CnHash::AV_MAX) {
|
||||
return Cpu::info()->hasAES() ? CnHash::AV_DOUBLE : CnHash::AV_DOUBLE_SOFT;
|
||||
}
|
||||
|
||||
// if (m_safe && !Cpu::info()->hasAES() && m_algoVariant <= AV_DOUBLE) {
|
||||
// return static_cast<AlgoVariant>(m_algoVariant + 2);
|
||||
// }
|
||||
|
||||
return m_algoVariant;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,13 +27,11 @@
|
|||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "backend/cpu/CpuConfig.h"
|
||||
#include "base/kernel/config/BaseConfig.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
#include "workers/CpuThreadLegacy.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -45,51 +43,17 @@ class IThread;
|
|||
class Config : public BaseConfig
|
||||
{
|
||||
public:
|
||||
enum ThreadsMode {
|
||||
Automatic,
|
||||
Simple,
|
||||
Advanced
|
||||
};
|
||||
|
||||
|
||||
Config();
|
||||
|
||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
void getJSON(rapidjson::Document &doc) const override;
|
||||
|
||||
inline CnHash::AlgoVariant algoVariant() const { return m_algoVariant; }
|
||||
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade || m_cpu.isShouldSave()) && isAutoSave(); }
|
||||
inline const CpuConfig &cpu() const { return m_cpu; }
|
||||
inline const std::vector<IThread *> &threads() const { return m_threads.list; }
|
||||
inline int threadsCount() const { return static_cast<int>(m_threads.list.size()); }
|
||||
inline ThreadsMode threadsMode() const { return m_threads.mode; }
|
||||
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade || m_cpu.isShouldSave()) && isAutoSave(); }
|
||||
inline const CpuConfig &cpu() const { return m_cpu; }
|
||||
|
||||
private:
|
||||
bool finalize();
|
||||
void setAlgoVariant(int av);
|
||||
void setThreads(const rapidjson::Value &threads);
|
||||
|
||||
CnHash::AlgoVariant getAlgoVariant() const;
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
CnHash::AlgoVariant getAlgoVariantLite() const;
|
||||
# endif
|
||||
|
||||
struct Threads
|
||||
{
|
||||
inline Threads() : mask(-1L), count(0), mode(Automatic) {}
|
||||
|
||||
int64_t mask;
|
||||
size_t count;
|
||||
std::vector<CpuThreadLegacy::Data> cpu;
|
||||
std::vector<IThread *> list;
|
||||
ThreadsMode mode;
|
||||
};
|
||||
|
||||
|
||||
CnHash::AlgoVariant m_algoVariant;
|
||||
bool m_shouldSave;
|
||||
bool m_shouldSave = false;
|
||||
CpuConfig m_cpu;
|
||||
Threads m_threads;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,219 +0,0 @@
|
|||
/* 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 <assert.h>
|
||||
|
||||
|
||||
#include "base/io/log/Log.h"
|
||||
#include "crypto/cn/CnHash.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
#include "crypto/common/VirtualMemory.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "workers/CpuThreadLegacy.h"
|
||||
|
||||
|
||||
xmrig::CpuThreadLegacy::CpuThreadLegacy(size_t index, Algorithm algorithm, CnHash::AlgoVariant av, Multiway multiway, int64_t affinity, int priority, bool softAES, bool prefetch, Assembly assembly) :
|
||||
m_algorithm(algorithm),
|
||||
m_av(av),
|
||||
m_assembly(assembly),
|
||||
m_prefetch(prefetch),
|
||||
m_softAES(softAES),
|
||||
m_priority(priority),
|
||||
m_affinity(affinity),
|
||||
m_multiway(multiway),
|
||||
m_index(index)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::cn_hash_fun xmrig::CpuThreadLegacy::fn(const Algorithm &algorithm) const
|
||||
{
|
||||
return CnHash::fn(algorithm, m_av, m_assembly);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool xmrig::CpuThreadLegacy::isSoftAES(CnHash::AlgoVariant av)
|
||||
{
|
||||
return av == CnHash::AV_SINGLE_SOFT || av == CnHash::AV_DOUBLE_SOFT || av > CnHash::AV_PENTA;
|
||||
}
|
||||
|
||||
|
||||
xmrig::CpuThreadLegacy *xmrig::CpuThreadLegacy::createFromAV(size_t index, const Algorithm &algorithm, CnHash::AlgoVariant av, int64_t affinity, int priority, Assembly assembly)
|
||||
{
|
||||
assert(av > CnHash::AV_AUTO && av < CnHash::AV_MAX);
|
||||
|
||||
int64_t cpuId = -1L;
|
||||
|
||||
if (affinity != -1L) {
|
||||
size_t idx = 0;
|
||||
|
||||
for (size_t i = 0; i < 64; i++) {
|
||||
if (!(affinity & (1ULL << i))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (idx == index) {
|
||||
cpuId = i;
|
||||
break;
|
||||
}
|
||||
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
return new CpuThreadLegacy(index, algorithm, av, multiway(av), cpuId, priority, isSoftAES(av), false, assembly);
|
||||
}
|
||||
|
||||
|
||||
xmrig::CpuThreadLegacy *xmrig::CpuThreadLegacy::createFromData(size_t index, const Algorithm &algorithm, const CpuThreadLegacy::Data &data, int priority, bool softAES)
|
||||
{
|
||||
int av = CnHash::AV_AUTO;
|
||||
const Multiway multiway = data.multiway;
|
||||
|
||||
if (multiway <= DoubleWay) {
|
||||
av = softAES ? (multiway + 2) : multiway;
|
||||
}
|
||||
else {
|
||||
av = softAES ? (multiway + 5) : (multiway + 2);
|
||||
}
|
||||
|
||||
assert(av > CnHash::AV_AUTO && av < CnHash::AV_MAX);
|
||||
|
||||
return new CpuThreadLegacy(index, algorithm, static_cast<CnHash::AlgoVariant>(av), multiway, data.affinity, priority, softAES, false, data.assembly);
|
||||
}
|
||||
|
||||
|
||||
xmrig::CpuThreadLegacy::Data xmrig::CpuThreadLegacy::parse(const rapidjson::Value &object)
|
||||
{
|
||||
Data data;
|
||||
|
||||
const auto &multiway = object["low_power_mode"];
|
||||
if (multiway.IsBool()) {
|
||||
data.multiway = multiway.IsTrue() ? DoubleWay : SingleWay;
|
||||
data.valid = true;
|
||||
}
|
||||
else if (multiway.IsUint()) {
|
||||
data.setMultiway(multiway.GetInt());
|
||||
}
|
||||
|
||||
if (!data.valid) {
|
||||
return data;
|
||||
}
|
||||
|
||||
const auto &affinity = object["affine_to_cpu"];
|
||||
if (affinity.IsUint64()) {
|
||||
data.affinity = affinity.GetInt64();
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
data.assembly = object["asm"];
|
||||
# endif
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
xmrig::IThread::Multiway xmrig::CpuThreadLegacy::multiway(CnHash::AlgoVariant av)
|
||||
{
|
||||
switch (av) {
|
||||
case CnHash::AV_SINGLE:
|
||||
case CnHash::AV_SINGLE_SOFT:
|
||||
return SingleWay;
|
||||
|
||||
case CnHash::AV_DOUBLE_SOFT:
|
||||
case CnHash::AV_DOUBLE:
|
||||
return DoubleWay;
|
||||
|
||||
case CnHash::AV_TRIPLE_SOFT:
|
||||
case CnHash::AV_TRIPLE:
|
||||
return TripleWay;
|
||||
|
||||
case CnHash::AV_QUAD_SOFT:
|
||||
case CnHash::AV_QUAD:
|
||||
return QuadWay;
|
||||
|
||||
case CnHash::AV_PENTA_SOFT:
|
||||
case CnHash::AV_PENTA:
|
||||
return PentaWay;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return SingleWay;
|
||||
}
|
||||
|
||||
|
||||
#ifdef APP_DEBUG
|
||||
void xmrig::CpuThreadLegacy::print() const
|
||||
{
|
||||
LOG_DEBUG(GREEN_BOLD("CPU thread: ") " index " WHITE_BOLD("%zu") ", multiway " WHITE_BOLD("%d") ", av " WHITE_BOLD("%d") ",",
|
||||
index(), static_cast<int>(multiway()), static_cast<int>(m_av));
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
LOG_DEBUG(" assembly: %s, affine_to_cpu: %" PRId64, m_assembly.toString(), affinity());
|
||||
# else
|
||||
LOG_DEBUG(" affine_to_cpu: %" PRId64, affinity());
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_API
|
||||
rapidjson::Value xmrig::CpuThreadLegacy::toAPI(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
Value obj(kObjectType);
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
obj.AddMember("type", "cpu", allocator);
|
||||
obj.AddMember("av", m_av, allocator);
|
||||
obj.AddMember("low_power_mode", multiway(), allocator);
|
||||
obj.AddMember("affine_to_cpu", affinity(), allocator);
|
||||
obj.AddMember("priority", priority(), allocator);
|
||||
obj.AddMember("soft_aes", isSoftAES(), allocator);
|
||||
|
||||
return obj;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
rapidjson::Value xmrig::CpuThreadLegacy::toConfig(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
Value obj(kObjectType);
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
obj.AddMember("low_power_mode", multiway(), allocator);
|
||||
obj.AddMember("affine_to_cpu", affinity() == -1L ? Value(kFalseType) : Value(affinity()), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
obj.AddMember("asm", m_assembly.toJSON(), allocator);
|
||||
# endif
|
||||
|
||||
return obj;
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
/* 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_CPUTHREADLEGACY_H
|
||||
#define XMRIG_CPUTHREADLEGACY_H
|
||||
|
||||
|
||||
#include "backend/common/interfaces/IThread.h"
|
||||
#include "crypto/cn/CnHash.h"
|
||||
|
||||
|
||||
struct cryptonight_ctx;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class CpuThreadLegacy : public IThread
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
inline Data() : valid(false), affinity(-1L), multiway(SingleWay) {}
|
||||
|
||||
inline void setMultiway(int value)
|
||||
{
|
||||
if (value >= SingleWay && value <= PentaWay) {
|
||||
multiway = static_cast<Multiway>(value);
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
Assembly assembly;
|
||||
bool valid;
|
||||
int64_t affinity;
|
||||
Multiway multiway;
|
||||
};
|
||||
|
||||
|
||||
CpuThreadLegacy(size_t index, Algorithm algorithm, CnHash::AlgoVariant av, Multiway multiway, int64_t affinity, int priority, bool softAES, bool prefetch, Assembly assembly);
|
||||
|
||||
cn_hash_fun fn(const Algorithm &algorithm) const;
|
||||
|
||||
static bool isSoftAES(CnHash::AlgoVariant av);
|
||||
static CpuThreadLegacy *createFromAV(size_t index, const Algorithm &algorithm, CnHash::AlgoVariant av, int64_t affinity, int priority, Assembly assembly);
|
||||
static CpuThreadLegacy *createFromData(size_t index, const Algorithm &algorithm, const CpuThreadLegacy::Data &data, int priority, bool softAES);
|
||||
static Data parse(const rapidjson::Value &object);
|
||||
static Multiway multiway(CnHash::AlgoVariant av);
|
||||
|
||||
inline bool isPrefetch() const { return m_prefetch; }
|
||||
inline bool isSoftAES() const { return m_softAES; }
|
||||
|
||||
inline Algorithm algorithm() const override { return m_algorithm; }
|
||||
inline int priority() const override { return m_priority; }
|
||||
inline int64_t affinity() const override { return m_affinity; }
|
||||
inline Multiway multiway() const override { return m_multiway; }
|
||||
inline size_t index() const override { return m_index; }
|
||||
inline Type type() const override { return CPU; }
|
||||
|
||||
protected:
|
||||
# ifdef APP_DEBUG
|
||||
void print() const override;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
rapidjson::Value toAPI(rapidjson::Document &doc) const override;
|
||||
# endif
|
||||
|
||||
rapidjson::Value toConfig(rapidjson::Document &doc) const override;
|
||||
|
||||
private:
|
||||
const Algorithm m_algorithm;
|
||||
const CnHash::AlgoVariant m_av;
|
||||
const Assembly m_assembly;
|
||||
const bool m_prefetch;
|
||||
const bool m_softAES;
|
||||
const int m_priority;
|
||||
const int64_t m_affinity;
|
||||
const Multiway m_multiway;
|
||||
const size_t m_index;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_CPUTHREADLEGACY_H */
|
Loading…
Reference in a new issue