mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-10 21:04:37 +00:00
Transform affinity and av to internal representation.
This commit is contained in:
parent
a042cbf885
commit
6c970612bf
5 changed files with 96 additions and 21 deletions
|
@ -95,9 +95,9 @@ xmrig::CommonConfig::~CommonConfig()
|
|||
}
|
||||
|
||||
|
||||
const char *xmrig::CommonConfig::algoName() const
|
||||
const char *xmrig::CommonConfig::algoName(Algo algorithm)
|
||||
{
|
||||
return algoNames[m_algorithm];
|
||||
return algoNames[algorithm];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
CommonConfig();
|
||||
~CommonConfig();
|
||||
|
||||
const char *algoName() const;
|
||||
static const char *algoName(Algo algorithm);
|
||||
|
||||
inline Algo algorithm() const { return m_algorithm; }
|
||||
inline bool isApiIPv6() const { return m_apiIPv6; }
|
||||
|
@ -52,6 +52,7 @@ public:
|
|||
inline bool isBackground() const { return m_background; }
|
||||
inline bool isColors() const { return m_colors; }
|
||||
inline bool isSyslog() const { return m_syslog; }
|
||||
inline const char *algoName() const { return algoName(m_algorithm); }
|
||||
inline const char *apiToken() const { return m_apiToken; }
|
||||
inline const char *apiWorkerId() const { return m_apiWorkerId; }
|
||||
inline const char *logFile() const { return m_logFile; }
|
||||
|
|
|
@ -21,18 +21,22 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "core/CommonConfig.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "workers/CpuThread.h"
|
||||
|
||||
|
||||
xmrig::CpuThread::CpuThread(size_t index, Algo algorithm, int multiway, int64_t affinity, int priority, bool softAES, bool prefetch) :
|
||||
xmrig::CpuThread::CpuThread(size_t index, Algo algorithm, AlgoVariant av, Multiway multiway, int64_t affinity, int priority, bool softAES, bool prefetch) :
|
||||
m_algorithm(algorithm),
|
||||
m_av(av),
|
||||
m_prefetch(prefetch),
|
||||
m_softAES(softAES),
|
||||
m_multiway(multiway),
|
||||
m_priority(priority),
|
||||
m_affinity(affinity),
|
||||
m_multiway(multiway),
|
||||
m_index(index)
|
||||
{
|
||||
}
|
||||
|
@ -45,7 +49,64 @@ xmrig::CpuThread::~CpuThread()
|
|||
|
||||
xmrig::CpuThread *xmrig::CpuThread::createFromAV(size_t index, Algo algorithm, AlgoVariant av, int64_t affinity, int priority)
|
||||
{
|
||||
return new CpuThread(index, algorithm, 1, affinity, priority, false, false);
|
||||
assert(av > AV_AUTO && av < AV_MAX);
|
||||
|
||||
Multiway multiway = SingleWay;
|
||||
bool softAES = false;
|
||||
|
||||
switch (av) {
|
||||
case AV_SINGLE_SOFT:
|
||||
softAES = true;
|
||||
break;
|
||||
|
||||
case AV_DOUBLE:
|
||||
multiway = DoubleWay;
|
||||
case AV_DOUBLE_SOFT:
|
||||
softAES = true;
|
||||
break;
|
||||
|
||||
case AV_TRIPLE:
|
||||
multiway = TripleWay;
|
||||
case AV_TRIPLE_SOFT:
|
||||
softAES = true;
|
||||
break;
|
||||
|
||||
case AV_QUAD:
|
||||
multiway = QuadWay;
|
||||
case AV_QUAD_SOFT:
|
||||
softAES = true;
|
||||
break;
|
||||
|
||||
case AV_PENTA:
|
||||
multiway = PentaWay;
|
||||
case AV_PENTA_SOFT:
|
||||
softAES = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
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 CpuThread(index, algorithm, av, multiway, cpuId, priority, softAES, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,11 +117,11 @@ rapidjson::Value xmrig::CpuThread::toAPI(rapidjson::Document &doc) const
|
|||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
obj.AddMember("type", "cpu", allocator);
|
||||
obj.AddMember("algo", algorithm(), allocator);
|
||||
obj.AddMember("algo", rapidjson::StringRef(CommonConfig::algoName(algorithm())), 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("prefetch", isPrefetch(), allocator);
|
||||
obj.AddMember("soft_aes", isSoftAES(), allocator);
|
||||
|
||||
return obj;
|
||||
|
|
|
@ -35,7 +35,15 @@ namespace xmrig {
|
|||
class CpuThread : public IThread
|
||||
{
|
||||
public:
|
||||
CpuThread(size_t index, Algo algorithm, int multiway, int64_t affinity, int priority, bool softAES, bool prefetch);
|
||||
enum Multiway {
|
||||
SingleWay,
|
||||
DoubleWay,
|
||||
TripleWay,
|
||||
QuadWay,
|
||||
PentaWay
|
||||
};
|
||||
|
||||
CpuThread(size_t index, Algo algorithm, AlgoVariant av, Multiway multiway, int64_t affinity, int priority, bool softAES, bool prefetch);
|
||||
~CpuThread();
|
||||
|
||||
static CpuThread *createFromAV(size_t index, Algo algorithm, AlgoVariant av, int64_t affinity, int priority);
|
||||
|
@ -56,11 +64,12 @@ public:
|
|||
|
||||
private:
|
||||
const Algo m_algorithm;
|
||||
const AlgoVariant m_av;
|
||||
const bool m_prefetch;
|
||||
const bool m_softAES;
|
||||
const int m_multiway;
|
||||
const int m_priority;
|
||||
const int64_t m_affinity;
|
||||
const Multiway m_multiway;
|
||||
const size_t m_index;
|
||||
};
|
||||
|
||||
|
|
26
src/xmrig.h
26
src/xmrig.h
|
@ -36,18 +36,22 @@ enum Algo {
|
|||
};
|
||||
|
||||
|
||||
//--av=1 For CPUs with hardware AES.
|
||||
//--av=2 Lower power mode (double hash) of 1.
|
||||
//--av=3 Software AES implementation.
|
||||
//--av=4 Lower power mode (double hash) of 3.
|
||||
enum AlgoVariant {
|
||||
AV_AUTO,
|
||||
AV_SINGLE,
|
||||
AV_DOUBLE,
|
||||
AV_SINGLE_SOFT,
|
||||
AV_DOUBLE_SOFT,
|
||||
AV_TRIPLE,
|
||||
AV_QUAD,
|
||||
AV_PENTA,
|
||||
AV_TRIPLE_SOFT,
|
||||
AV_QUAD_SOFT,
|
||||
AV_PENTA_SOFT,
|
||||
AV_AUTO, // --av=0 Automatic mode.
|
||||
AV_SINGLE, // --av=1 Single hash mode
|
||||
AV_DOUBLE, // --av=2 Double hash mode
|
||||
AV_SINGLE_SOFT, // --av=3 Single hash mode (Software AES)
|
||||
AV_DOUBLE_SOFT, // --av=4 Double hash mode (Software AES)
|
||||
AV_TRIPLE, // --av=5 Triple hash mode
|
||||
AV_QUAD, // --av=6 Quard hash mode
|
||||
AV_PENTA, // --av=7 Penta hash mode
|
||||
AV_TRIPLE_SOFT, // --av=8 Triple hash mode (Software AES)
|
||||
AV_QUAD_SOFT, // --av=9 Quard hash mode (Software AES)
|
||||
AV_PENTA_SOFT, // --av=10 Penta hash mode (Software AES)
|
||||
AV_MAX
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue