Skip to content

Commit

Permalink
Merge branch 'evo' of https://github.com/xmrig/xmrig
Browse files Browse the repository at this point in the history
  • Loading branch information
MoneroOcean committed Jul 29, 2019
2 parents e23d3c4 + 6b3b1c3 commit a88b15d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 24 deletions.
14 changes: 8 additions & 6 deletions src/api/Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "base/tools/Chrono.h"
#include "core/config/Config.h"
#include "core/Controller.h"
#include "crypto/common/Algorithm.h"
#include "crypto/common/keccak.h"
#include "version.h"

Expand All @@ -54,8 +53,8 @@ xmrig::Api::Api(Base *base) :
m_base(base),
m_id(),
m_workerId(),
m_httpd(nullptr),
m_timestamp(Chrono::steadyMSecs())
m_timestamp(Chrono::currentMSecsSinceEpoch()),
m_httpd(nullptr)
{
base->addListener(this);

Expand Down Expand Up @@ -120,7 +119,7 @@ void xmrig::Api::exec(IApiRequest &request)
request.accept();
request.reply().AddMember("id", StringRef(m_id), allocator);
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
request.reply().AddMember("uptime", (Chrono::steadyMSecs() - m_timestamp) / 1000, allocator);
request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);

Value features(kArrayType);
# ifdef XMRIG_FEATURE_API
Expand All @@ -135,6 +134,9 @@ void xmrig::Api::exec(IApiRequest &request)
# ifdef XMRIG_FEATURE_LIBCPUID
features.PushBack("cpuid", allocator);
# endif
# ifdef XMRIG_FEATURE_HWLOC
features.PushBack("hwloc", allocator);
# endif
# ifdef XMRIG_FEATURE_TLS
features.PushBack("tls", allocator);
# endif
Expand Down Expand Up @@ -181,8 +183,8 @@ void xmrig::Api::genId(const String &id)
memcpy(input + sizeof(uint16_t), interfaces[i].phys_addr, addrSize);
memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, strlen(APP_KIND));

xmrig::keccak(input, inSize, hash);
xmrig::Buffer::toHex(hash, 8, m_id);
keccak(input, inSize, hash);
Buffer::toHex(hash, 8, m_id);

delete [] input;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/api/Api.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class Api : public IBaseListener
Base *m_base;
char m_id[32];
char m_workerId[128];
const uint64_t m_timestamp;
Httpd *m_httpd;
std::vector<IApiListener *> m_listeners;
uint64_t m_timestamp;
};


Expand Down
28 changes: 16 additions & 12 deletions src/backend/cpu/platform/HwlocCpuInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ static inline void findByType(hwloc_obj_t obj, hwloc_obj_type_t type, func lambd
}


static inline std::vector<hwloc_obj_t> findByType(hwloc_obj_t obj, hwloc_obj_type_t type)
{
std::vector<hwloc_obj_t> out;
findByType(obj, type, [&out](hwloc_obj_t found) { out.emplace_back(found); });

return out;
}


static inline size_t countByType(hwloc_topology_t topology, hwloc_obj_type_t type)
{
const int count = hwloc_get_nbobjs_by_type(topology, type);
Expand Down Expand Up @@ -132,8 +141,7 @@ xmrig::HwlocCpuInfo::HwlocCpuInfo() : BasicCpuInfo(),
}
# endif

std::vector<hwloc_obj_t> packages;
findByType(hwloc_get_root_obj(m_topology), HWLOC_OBJ_PACKAGE, [&packages](hwloc_obj_t found) { packages.emplace_back(found); });
const std::vector<hwloc_obj_t> packages = findByType(hwloc_get_root_obj(m_topology), HWLOC_OBJ_PACKAGE);
if (packages.size()) {
const char *value = hwloc_obj_get_info_by_name(packages[0], "CPUModel");
if (value) {
Expand Down Expand Up @@ -249,14 +257,9 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith

if (cacheHashes >= PUs) {
for (hwloc_obj_t core : cores) {
if (core->arity == 0) {
continue;
}

for (unsigned i = 0; i < core->arity; ++i) {
if (core->children[i]->type == HWLOC_OBJ_PU) {
threads.push_back(CpuThread(1, core->children[i]->os_index));
}
const std::vector<hwloc_obj_t> units = findByType(core, HWLOC_OBJ_PU);
for (hwloc_obj_t pu : units) {
threads.push_back(CpuThread(1, pu->os_index));
}
}

Expand All @@ -268,15 +271,16 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
bool allocated_pu = false;

for (hwloc_obj_t core : cores) {
if (core->arity <= pu_id || core->children[pu_id]->type != HWLOC_OBJ_PU) {
const std::vector<hwloc_obj_t> units = findByType(core, HWLOC_OBJ_PU);
if (units.size() <= pu_id) {
continue;
}

cacheHashes--;
PUs--;

allocated_pu = true;
threads.push_back(CpuThread(1, core->children[pu_id]->os_index));
threads.push_back(CpuThread(1, units[pu_id]->os_index));

if (cacheHashes == 0) {
break;
Expand Down
15 changes: 13 additions & 2 deletions src/crypto/common/Algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "crypto/cn/CnAlgo.h"
#include "crypto/common/Algorithm.h"
#include "crypto/rx/RxAlgo.h"
#include "rapidjson/document.h"


Expand Down Expand Up @@ -140,7 +139,19 @@ size_t xmrig::Algorithm::memory() const

# ifdef XMRIG_ALGO_RANDOMX
if (f == RANDOM_X) {
return RxAlgo::l3(m_id);
constexpr size_t oneMiB = 0x100000;

switch (m_id) {
case RX_0:
case RX_LOKI:
return oneMiB * 2;

case RX_WOW:
return oneMiB;

default:
break;
}
}
# endif

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/randomx/virtual_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace randomx {

template<bool softAes>
void VmBase<softAes>::generateProgram(void* seed) {
fillAes4Rx4<softAes>(seed, sizeof(program), &program);
fillAes4Rx4<softAes>(seed, 128 + RandomX_CurrentConfig.ProgramSize * 8, &program);
}

template class VmBase<false>;
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
#define APP_ID "xmrig"
#define APP_NAME "XMRig"
#define APP_DESC "XMRig CPU miner"
#define APP_VERSION "2.99.2-evo-mo1"
#define APP_VERSION "2.99.3-evo-mo1"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
#define APP_KIND "cpu"

#define APP_VER_MAJOR 2
#define APP_VER_MINOR 99
#define APP_VER_PATCH 2
#define APP_VER_PATCH 3

#ifdef _MSC_VER
# if (_MSC_VER >= 1920)
Expand Down

0 comments on commit a88b15d

Please sign in to comment.