Merge xmrig v6.7.0 into master
This commit is contained in:
commit
1719879f7e
249 changed files with 6814 additions and 6134 deletions
|
@ -1,12 +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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -32,8 +26,6 @@
|
|||
|
||||
#if defined(XMRIG_FEATURE_HWLOC)
|
||||
# include "backend/cpu/platform/HwlocCpuInfo.h"
|
||||
#elif defined(XMRIG_FEATURE_LIBCPUID)
|
||||
# include "backend/cpu/platform/AdvancedCpuInfo.h"
|
||||
#else
|
||||
# include "backend/cpu/platform/BasicCpuInfo.h"
|
||||
#endif
|
||||
|
@ -47,8 +39,6 @@ xmrig::ICpuInfo *xmrig::Cpu::info()
|
|||
if (cpuInfo == nullptr) {
|
||||
# if defined(XMRIG_FEATURE_HWLOC)
|
||||
cpuInfo = new HwlocCpuInfo();
|
||||
# elif defined(XMRIG_FEATURE_LIBCPUID)
|
||||
cpuInfo = new AdvancedCpuInfo();
|
||||
# else
|
||||
cpuInfo = new BasicCpuInfo();
|
||||
# endif
|
||||
|
|
|
@ -1,12 +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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
|
|
@ -266,6 +266,12 @@ bool xmrig::CpuBackend::isEnabled(const Algorithm &algorithm) const
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CpuBackend::tick(uint64_t ticks)
|
||||
{
|
||||
return d_ptr->workers.tick(ticks);
|
||||
}
|
||||
|
||||
|
||||
const xmrig::Hashrate *xmrig::CpuBackend::hashrate() const
|
||||
{
|
||||
return d_ptr->workers.hashrate();
|
||||
|
@ -316,9 +322,9 @@ void xmrig::CpuBackend::printHashrate(bool details)
|
|||
Log::print("| %8zu | %8" PRId64 " | %7s | %7s | %7s |",
|
||||
i,
|
||||
data.affinity,
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::ShortInterval), num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i + 1, Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3)
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::ShortInterval), num, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
||||
Hashrate::format(hashrate()->calc(i, Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3)
|
||||
);
|
||||
|
||||
i++;
|
||||
|
@ -405,12 +411,6 @@ void xmrig::CpuBackend::stop()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CpuBackend::tick(uint64_t ticks)
|
||||
{
|
||||
return d_ptr->workers.tick(ticks);
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_API
|
||||
rapidjson::Value xmrig::CpuBackend::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ protected:
|
|||
|
||||
bool isEnabled() const override;
|
||||
bool isEnabled(const Algorithm &algorithm) const override;
|
||||
bool tick(uint64_t ticks) override;
|
||||
const Hashrate *hashrate() const override;
|
||||
const String &profileName() const override;
|
||||
const String &type() const override;
|
||||
|
@ -63,7 +64,6 @@ protected:
|
|||
void setJob(const Job &job) override;
|
||||
void start(IWorker *worker, bool ready) override;
|
||||
void stop() override;
|
||||
bool tick(uint64_t ticks) override;
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const override;
|
||||
|
|
|
@ -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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -80,7 +73,7 @@ xmrig::CpuWorker<N>::CpuWorker(size_t id, const CpuLaunchData &data) :
|
|||
m_threads(data.threads),
|
||||
m_ctx()
|
||||
{
|
||||
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, m_node);
|
||||
m_memory = new VirtualMemory(m_algorithm.l3() * N, data.hugePages, false, true, node());
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,7 +93,7 @@ xmrig::CpuWorker<N>::~CpuWorker()
|
|||
template<size_t N>
|
||||
void xmrig::CpuWorker<N>::allocateRandomX_VM()
|
||||
{
|
||||
RxDataset *dataset = Rx::dataset(m_job.currentJob(), m_node);
|
||||
RxDataset *dataset = Rx::dataset(m_job.currentJob(), node());
|
||||
|
||||
while (dataset == nullptr) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
|
@ -109,13 +102,13 @@ void xmrig::CpuWorker<N>::allocateRandomX_VM()
|
|||
return;
|
||||
}
|
||||
|
||||
dataset = Rx::dataset(m_job.currentJob(), m_node);
|
||||
dataset = Rx::dataset(m_job.currentJob(), node());
|
||||
}
|
||||
|
||||
if (!m_vm) {
|
||||
// Try to allocate scratchpad from dataset's 1 GB huge pages, if normal huge pages are not available
|
||||
uint8_t* scratchpad = m_memory->isHugePages() ? m_memory->scratchpad() : dataset->tryAllocateScrathpad();
|
||||
m_vm = RxVm::create(dataset, scratchpad ? scratchpad : m_memory->scratchpad(), !m_hwAES, m_assembly, m_node);
|
||||
m_vm = RxVm::create(dataset, scratchpad ? scratchpad : m_memory->scratchpad(), !m_hwAES, m_assembly, node());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -200,6 +193,14 @@ bool xmrig::CpuWorker<N>::selfTest()
|
|||
}
|
||||
|
||||
|
||||
template<size_t N>
|
||||
void xmrig::CpuWorker<N>::hashrateData(uint64_t &hashCount, uint64_t &, uint64_t &rawHashes) const
|
||||
{
|
||||
hashCount = m_count;
|
||||
rawHashes = m_count;
|
||||
}
|
||||
|
||||
|
||||
template<size_t N>
|
||||
void xmrig::CpuWorker<N>::start()
|
||||
{
|
||||
|
|
|
@ -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 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -56,10 +49,12 @@ public:
|
|||
|
||||
protected:
|
||||
bool selfTest() override;
|
||||
void hashrateData(uint64_t &hashCount, uint64_t &timeStamp, uint64_t &rawHashes) const override;
|
||||
void start() override;
|
||||
|
||||
inline const VirtualMemory *memory() const override { return m_memory; }
|
||||
inline size_t intensity() const override { return N; }
|
||||
inline const VirtualMemory *memory() const override { return m_memory; }
|
||||
inline size_t intensity() const override { return N; }
|
||||
inline void jobEarlyNotification(const Job&) override {}
|
||||
|
||||
private:
|
||||
inline cn_hash_fun fn(const Algorithm &algorithm) const { return CnHash::fn(algorithm, m_av, m_assembly); }
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
set(HEADERS_BACKEND_CPU
|
||||
src/backend/cpu/Cpu.h
|
||||
src/backend/cpu/CpuBackend.h
|
||||
src/backend/cpu/CpuConfig.h
|
||||
src/backend/cpu/CpuConfig_gen.h
|
||||
src/backend/cpu/CpuConfig.h
|
||||
src/backend/cpu/CpuLaunchData.cpp
|
||||
src/backend/cpu/CpuThread.h
|
||||
src/backend/cpu/CpuThreads.h
|
||||
src/backend/cpu/CpuWorker.h
|
||||
src/backend/cpu/interfaces/ICpuInfo.h
|
||||
src/backend/cpu/platform/BasicCpuInfo.h
|
||||
)
|
||||
|
||||
set(SOURCES_BACKEND_CPU
|
||||
|
@ -20,7 +21,6 @@ set(SOURCES_BACKEND_CPU
|
|||
src/backend/cpu/CpuWorker.cpp
|
||||
)
|
||||
|
||||
|
||||
if (WITH_HWLOC)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
add_subdirectory(src/3rdparty/hwloc)
|
||||
|
@ -32,51 +32,26 @@ if (WITH_HWLOC)
|
|||
set(CPUID_LIB ${HWLOC_LIBRARY})
|
||||
endif()
|
||||
|
||||
set(WITH_LIBCPUID OFF)
|
||||
|
||||
remove_definitions(/DXMRIG_FEATURE_LIBCPUID)
|
||||
add_definitions(/DXMRIG_FEATURE_HWLOC)
|
||||
|
||||
if (HWLOC_DEBUG)
|
||||
add_definitions(/DXMRIG_HWLOC_DEBUG)
|
||||
endif()
|
||||
|
||||
set(SOURCES_CPUID
|
||||
src/backend/cpu/platform/BasicCpuInfo.h
|
||||
src/backend/cpu/platform/HwlocCpuInfo.cpp
|
||||
src/backend/cpu/platform/HwlocCpuInfo.h
|
||||
)
|
||||
elseif (WITH_LIBCPUID)
|
||||
message(WARNING, "libcpuid support is deprecated and will be removed in future versions.")
|
||||
set(WITH_HWLOC OFF)
|
||||
|
||||
add_subdirectory(src/3rdparty/libcpuid)
|
||||
include_directories(src/3rdparty/libcpuid)
|
||||
|
||||
add_definitions(/DXMRIG_FEATURE_LIBCPUID)
|
||||
remove_definitions(/DXMRIG_FEATURE_HWLOC)
|
||||
|
||||
set(CPUID_LIB cpuid)
|
||||
set(SOURCES_CPUID
|
||||
src/backend/cpu/platform/AdvancedCpuInfo.cpp
|
||||
src/backend/cpu/platform/AdvancedCpuInfo.h
|
||||
)
|
||||
list(APPEND HEADERS_BACKEND_CPU src/backend/cpu/platform/HwlocCpuInfo.h)
|
||||
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/HwlocCpuInfo.cpp)
|
||||
else()
|
||||
remove_definitions(/DXMRIG_FEATURE_LIBCPUID)
|
||||
remove_definitions(/DXMRIG_FEATURE_HWLOC)
|
||||
|
||||
set(CPUID_LIB "")
|
||||
set(SOURCES_CPUID
|
||||
src/backend/cpu/platform/BasicCpuInfo.h
|
||||
)
|
||||
endif()
|
||||
|
||||
if (XMRIG_ARM)
|
||||
list(APPEND SOURCES_CPUID src/backend/cpu/platform/BasicCpuInfo_arm.cpp)
|
||||
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo_arm.cpp)
|
||||
|
||||
if (XMRIG_OS_UNIX)
|
||||
list(APPEND SOURCES_CPUID src/backend/cpu/platform/lscpu_arm.cpp)
|
||||
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/lscpu_arm.cpp)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND SOURCES_CPUID src/backend/cpu/platform/BasicCpuInfo.cpp)
|
||||
list(APPEND SOURCES_BACKEND_CPU src/backend/cpu/platform/BasicCpuInfo.cpp)
|
||||
endif()
|
||||
|
|
|
@ -1,12 +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 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -46,6 +40,14 @@ public:
|
|||
VENDOR_AMD
|
||||
};
|
||||
|
||||
enum Arch : uint32_t {
|
||||
ARCH_UNKNOWN,
|
||||
ARCH_ZEN,
|
||||
ARCH_ZEN_PLUS,
|
||||
ARCH_ZEN2,
|
||||
ARCH_ZEN3
|
||||
};
|
||||
|
||||
enum MsrMod : uint32_t {
|
||||
MSR_MOD_NONE,
|
||||
MSR_MOD_RYZEN_17H,
|
||||
|
@ -59,6 +61,7 @@ public:
|
|||
|
||||
enum Flag : uint32_t {
|
||||
FLAG_AES,
|
||||
FLAG_AVX,
|
||||
FLAG_AVX2,
|
||||
FLAG_AVX512F,
|
||||
FLAG_BMI2,
|
||||
|
@ -70,6 +73,7 @@ public:
|
|||
FLAG_XOP,
|
||||
FLAG_POPCNT,
|
||||
FLAG_CAT_L3,
|
||||
FLAG_VM,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
|
@ -77,18 +81,21 @@ public:
|
|||
virtual ~ICpuInfo() = default;
|
||||
|
||||
# if defined(__x86_64__) || defined(_M_AMD64) || defined (__arm64__) || defined (__aarch64__)
|
||||
inline constexpr static bool isX64() { return true; }
|
||||
inline constexpr static bool is64bit() { return true; }
|
||||
# else
|
||||
inline constexpr static bool isX64() { return false; }
|
||||
inline constexpr static bool is64bit() { return false; }
|
||||
# endif
|
||||
|
||||
virtual Assembly::Id assembly() const = 0;
|
||||
virtual bool has(Flag feature) const = 0;
|
||||
virtual bool hasAES() const = 0;
|
||||
virtual bool hasAVX() const = 0;
|
||||
virtual bool hasAVX2() const = 0;
|
||||
virtual bool hasBMI2() const = 0;
|
||||
virtual bool hasOneGbPages() const = 0;
|
||||
virtual bool hasXOP() const = 0;
|
||||
virtual bool hasCatL3() const = 0;
|
||||
virtual bool isVM() const = 0;
|
||||
virtual const char *backend() const = 0;
|
||||
virtual const char *brand() const = 0;
|
||||
virtual CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const = 0;
|
||||
|
@ -101,6 +108,7 @@ public:
|
|||
virtual size_t packages() const = 0;
|
||||
virtual size_t threads() const = 0;
|
||||
virtual Vendor vendor() const = 0;
|
||||
virtual Arch arch() const = 0;
|
||||
virtual bool jccErratum() const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,136 +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-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 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 "backend/cpu/platform/AdvancedCpuInfo.h"
|
||||
#include "3rdparty/libcpuid/libcpuid.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
|
||||
xmrig::AdvancedCpuInfo::AdvancedCpuInfo()
|
||||
{
|
||||
struct cpu_raw_data_t raw = {};
|
||||
struct cpu_id_t data = {};
|
||||
|
||||
cpuid_get_raw_data(&raw);
|
||||
cpu_identify(&raw, &data);
|
||||
|
||||
snprintf(m_backend, sizeof m_backend, "libcpuid/%s", cpuid_lib_version());
|
||||
|
||||
m_threads = static_cast<size_t>(data.total_logical_cpus);
|
||||
m_packages = std::max<size_t>(m_threads / static_cast<size_t>(data.num_logical_cpus), 1);
|
||||
m_cores = static_cast<size_t>(data.num_cores) * m_packages;
|
||||
m_L3 = data.l3_cache > 0 ? static_cast<size_t>(data.l3_cache) * m_packages : 0;
|
||||
|
||||
const auto l2 = static_cast<size_t>(data.l2_cache);
|
||||
|
||||
// Workaround for AMD CPUs https://github.com/anrieff/libcpuid/issues/97
|
||||
if (m_vendor == VENDOR_AMD && data.ext_family >= 0x15 && data.ext_family < 0x17) {
|
||||
m_L2 = l2 * (cores() / 2) * m_packages;
|
||||
m_L2_exclusive = true;
|
||||
}
|
||||
// Workaround for Intel Pentium Dual-Core, Core Duo, Core 2 Duo, Core 2 Quad and their Xeon homologue
|
||||
// These processors have L2 cache shared by 2 cores.
|
||||
else if (m_vendor == VENDOR_INTEL && data.ext_family == 0x06 && (data.ext_model == 0x0E || data.ext_model == 0x0F || data.ext_model == 0x17)) {
|
||||
size_t l2_count_per_socket = cores() > 1 ? cores() / 2 : 1;
|
||||
m_L2 = data.l2_cache > 0 ? l2 * l2_count_per_socket * m_packages : 0;
|
||||
}
|
||||
else{
|
||||
m_L2 = data.l2_cache > 0 ? l2 * cores() * m_packages : 0;
|
||||
}
|
||||
|
||||
m_L2 *= 1024;
|
||||
m_L3 *= 1024;
|
||||
}
|
||||
|
||||
|
||||
xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm, uint32_t limit) const
|
||||
{
|
||||
if (threads() == 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (algorithm == Algorithm::CN_GPU) {
|
||||
return CpuThreads(threads());
|
||||
}
|
||||
# endif
|
||||
|
||||
size_t cache = 0;
|
||||
size_t count = 0;
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (algorithm == Algorithm::ASTROBWT_DERO) {
|
||||
CpuThreads t;
|
||||
count = threads();
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
t.add(i, 0);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
# endif
|
||||
|
||||
if (m_L3) {
|
||||
cache = m_L2_exclusive ? (m_L2 + m_L3) : m_L3;
|
||||
}
|
||||
else {
|
||||
cache = m_L2;
|
||||
}
|
||||
|
||||
if (cache) {
|
||||
const size_t memory = algorithm.l3();
|
||||
assert(memory > 0);
|
||||
|
||||
count = cache / memory;
|
||||
|
||||
if (cache % memory >= memory / 2) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
count = threads() / 2;
|
||||
}
|
||||
|
||||
uint32_t intensity = algorithm.maxIntensity() == 1 ? 0 : 1;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
if (algorithm == Algorithm::CN_PICO_0 && (count / cores()) >= 2) {
|
||||
intensity = 2;
|
||||
}
|
||||
# endif
|
||||
|
||||
if (limit > 0 && limit < 100) {
|
||||
count = std::min(count, static_cast<size_t>(round(threads() * (limit / 100.0))));
|
||||
}
|
||||
else {
|
||||
count = std::min(count, threads());
|
||||
}
|
||||
|
||||
return CpuThreads(std::max<size_t>(count, 1), intensity);
|
||||
}
|
|
@ -1,63 +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-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 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_ADVANCEDCPUINFO_H
|
||||
#define XMRIG_ADVANCEDCPUINFO_H
|
||||
|
||||
|
||||
#include "backend/cpu/platform/BasicCpuInfo.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class AdvancedCpuInfo : public BasicCpuInfo
|
||||
{
|
||||
public:
|
||||
AdvancedCpuInfo();
|
||||
|
||||
protected:
|
||||
CpuThreads threads(const Algorithm &algorithm, uint32_t limit) const override;
|
||||
|
||||
inline const char *backend() const override { return m_backend; }
|
||||
inline size_t cores() const override { return m_cores; }
|
||||
inline size_t L2() const override { return m_L2; }
|
||||
inline size_t L3() const override { return m_L3; }
|
||||
inline size_t packages() const override { return m_packages; }
|
||||
inline size_t threads() const override { return m_threads; }
|
||||
|
||||
private:
|
||||
bool m_L2_exclusive = false;
|
||||
char m_backend[32]{};
|
||||
size_t m_cores = 0;
|
||||
size_t m_L2 = 0;
|
||||
size_t m_L3 = 0;
|
||||
size_t m_packages = 1;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_ADVANCEDCPUINFO_H */
|
|
@ -52,8 +52,8 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
constexpr size_t kCpuFlagsSize = 12;
|
||||
static const std::array<const char *, kCpuFlagsSize> flagNames = { "aes", "avx2", "avx512f", "bmi2", "osxsave", "pdpe1gb", "sse2", "ssse3", "sse4.1", "xop", "popcnt", "cat_l3" };
|
||||
constexpr size_t kCpuFlagsSize = 14;
|
||||
static const std::array<const char *, kCpuFlagsSize> flagNames = { "aes", "avx", "avx2", "avx512f", "bmi2", "osxsave", "pdpe1gb", "sse2", "ssse3", "sse4.1", "xop", "popcnt", "cat_l3", "vm" };
|
||||
static_assert(kCpuFlagsSize == ICpuInfo::FLAG_MAX, "kCpuFlagsSize and FLAG_MAX mismatch");
|
||||
|
||||
|
||||
|
@ -134,11 +134,12 @@ static inline uint64_t xgetbv()
|
|||
#endif
|
||||
}
|
||||
|
||||
static inline bool has_xcr_avx2() { return (xgetbv() & 0x06) == 0x06; }
|
||||
static inline bool has_xcr_avx() { return (xgetbv() & 0x06) == 0x06; }
|
||||
static inline bool has_xcr_avx512() { return (xgetbv() & 0xE6) == 0xE6; }
|
||||
static inline bool has_osxsave() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 27); }
|
||||
static inline bool has_aes_ni() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 25); }
|
||||
static inline bool has_avx2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 5) && has_osxsave() && has_xcr_avx2(); }
|
||||
static inline bool has_avx() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 28) && has_osxsave() && has_xcr_avx(); }
|
||||
static inline bool has_avx2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 5) && has_osxsave() && has_xcr_avx(); }
|
||||
static inline bool has_avx512f() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 16) && has_osxsave() && has_xcr_avx512(); }
|
||||
static inline bool has_bmi2() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 8); }
|
||||
static inline bool has_pdpe1gb() { return has_feature(PROCESSOR_EXT_INFO, EDX_Reg, 1 << 26); }
|
||||
|
@ -148,6 +149,7 @@ static inline bool has_sse41() { return has_feature(PROCESSOR_INFO,
|
|||
static inline bool has_xop() { return has_feature(0x80000001, ECX_Reg, 1 << 11); }
|
||||
static inline bool has_popcnt() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 23); }
|
||||
static inline bool has_cat_l3() { return has_feature(EXTENDED_FEATURES, EBX_Reg, 1 << 15) && has_feature(0x10, EBX_Reg, 1 << 1); }
|
||||
static inline bool is_vm() { return has_feature(PROCESSOR_INFO, ECX_Reg, 1 << 31); }
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
@ -174,6 +176,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
|||
cpu_brand_string(m_brand);
|
||||
|
||||
m_flags.set(FLAG_AES, has_aes_ni());
|
||||
m_flags.set(FLAG_AVX, has_avx());
|
||||
m_flags.set(FLAG_AVX2, has_avx2());
|
||||
m_flags.set(FLAG_AVX512F, has_avx512f());
|
||||
m_flags.set(FLAG_BMI2, has_bmi2());
|
||||
|
@ -185,6 +188,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
|||
m_flags.set(FLAG_XOP, has_xop());
|
||||
m_flags.set(FLAG_POPCNT, has_popcnt());
|
||||
m_flags.set(FLAG_CAT_L3, has_cat_l3());
|
||||
m_flags.set(FLAG_VM, is_vm());
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
if (hasAES()) {
|
||||
|
@ -213,9 +217,27 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
|||
switch (m_family) {
|
||||
case 0x17:
|
||||
m_msrMod = MSR_MOD_RYZEN_17H;
|
||||
switch (m_model) {
|
||||
case 1:
|
||||
case 17:
|
||||
case 32:
|
||||
m_arch = ARCH_ZEN;
|
||||
break;
|
||||
case 8:
|
||||
case 24:
|
||||
m_arch = ARCH_ZEN_PLUS;
|
||||
break;
|
||||
case 49:
|
||||
case 96:
|
||||
case 113:
|
||||
case 144:
|
||||
m_arch = ARCH_ZEN2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x19:
|
||||
m_arch = ARCH_ZEN3;
|
||||
m_msrMod = MSR_MOD_RYZEN_19H;
|
||||
break;
|
||||
|
||||
|
@ -353,7 +375,8 @@ rapidjson::Value xmrig::BasicCpuInfo::toJSON(rapidjson::Document &doc) const
|
|||
out.AddMember("proc_info", m_procInfo, allocator);
|
||||
out.AddMember("aes", hasAES(), allocator);
|
||||
out.AddMember("avx2", hasAVX2(), allocator);
|
||||
out.AddMember("x64", isX64(), allocator);
|
||||
out.AddMember("x64", is64bit(), allocator); // DEPRECATED will be removed in the next major release.
|
||||
out.AddMember("64_bit", is64bit(), allocator);
|
||||
out.AddMember("l2", static_cast<uint64_t>(L2()), allocator);
|
||||
out.AddMember("l3", static_cast<uint64_t>(L3()), allocator);
|
||||
out.AddMember("cores", static_cast<uint64_t>(cores()), allocator);
|
||||
|
|
|
@ -48,10 +48,13 @@ protected:
|
|||
inline Assembly::Id assembly() const override { return m_assembly; }
|
||||
inline bool has(Flag flag) const override { return m_flags.test(flag); }
|
||||
inline bool hasAES() const override { return has(FLAG_AES); }
|
||||
inline bool hasAVX() const override { return has(FLAG_AVX); }
|
||||
inline bool hasAVX2() const override { return has(FLAG_AVX2); }
|
||||
inline bool hasBMI2() const override { return has(FLAG_BMI2); }
|
||||
inline bool hasOneGbPages() const override { return has(FLAG_PDPE1GB); }
|
||||
inline bool hasXOP() const override { return has(FLAG_XOP); }
|
||||
inline bool hasCatL3() const override { return has(FLAG_CAT_L3); }
|
||||
inline bool isVM() const override { return has(FLAG_VM); }
|
||||
inline const char *brand() const override { return m_brand; }
|
||||
inline MsrMod msrMod() const override { return m_msrMod; }
|
||||
inline size_t cores() const override { return 0; }
|
||||
|
@ -61,19 +64,24 @@ protected:
|
|||
inline size_t packages() const override { return 1; }
|
||||
inline size_t threads() const override { return m_threads; }
|
||||
inline Vendor vendor() const override { return m_vendor; }
|
||||
inline Arch arch() const override { return m_arch; }
|
||||
inline bool jccErratum() const override { return m_jccErratum; }
|
||||
|
||||
protected:
|
||||
char m_brand[64 + 6]{};
|
||||
size_t m_threads;
|
||||
Vendor m_vendor = VENDOR_UNKNOWN;
|
||||
Arch m_arch = ARCH_UNKNOWN;
|
||||
bool m_jccErratum = false;
|
||||
|
||||
private:
|
||||
# ifndef XMRIG_ARM
|
||||
uint32_t m_procInfo = 0;
|
||||
uint32_t m_family = 0;
|
||||
uint32_t m_model = 0;
|
||||
uint32_t m_stepping = 0;
|
||||
# endif
|
||||
|
||||
Assembly m_assembly = Assembly::NONE;
|
||||
MsrMod m_msrMod = MSR_MOD_NONE;
|
||||
std::bitset<FLAG_MAX> m_flags;
|
||||
|
|
|
@ -36,12 +36,14 @@
|
|||
#include "3rdparty/rapidjson/document.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_OS_UNIX
|
||||
#if defined(XMRIG_OS_UNIX)
|
||||
namespace xmrig {
|
||||
|
||||
extern String cpu_name_arm();
|
||||
|
||||
} // namespace xmrig
|
||||
#elif defined(XMRIG_OS_MACOS)
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -62,13 +64,16 @@ xmrig::BasicCpuInfo::BasicCpuInfo() :
|
|||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_OS_UNIX
|
||||
# if defined(XMRIG_OS_UNIX)
|
||||
auto name = cpu_name_arm();
|
||||
if (!name.isNull()) {
|
||||
strncpy(m_brand, name, sizeof(m_brand) - 1);
|
||||
}
|
||||
|
||||
m_flags.set(FLAG_PDPE1GB, std::ifstream("/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages").good());
|
||||
# elif defined(XMRIG_OS_MACOS)
|
||||
size_t buflen = sizeof(m_brand);
|
||||
sysctlbyname("machdep.cpu.brand_string", &m_brand, &buflen, nullptr, 0);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -95,7 +100,8 @@ rapidjson::Value xmrig::BasicCpuInfo::toJSON(rapidjson::Document &doc) const
|
|||
out.AddMember("brand", StringRef(brand()), allocator);
|
||||
out.AddMember("aes", hasAES(), allocator);
|
||||
out.AddMember("avx2", false, allocator);
|
||||
out.AddMember("x64", isX64(), allocator);
|
||||
out.AddMember("x64", is64bit(), allocator); // DEPRECATED will be removed in the next major release.
|
||||
out.AddMember("64_bit", is64bit(), allocator);
|
||||
out.AddMember("l2", static_cast<uint64_t>(L2()), allocator);
|
||||
out.AddMember("l3", static_cast<uint64_t>(L3()), allocator);
|
||||
out.AddMember("cores", static_cast<uint64_t>(cores()), allocator);
|
||||
|
|
|
@ -1,12 +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 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -91,6 +85,15 @@ static inline void findByType(hwloc_obj_t obj, hwloc_obj_type_t type, func lambd
|
|||
}
|
||||
|
||||
|
||||
static inline size_t countByType(hwloc_topology_t topology, hwloc_obj_type_t type)
|
||||
{
|
||||
const int count = hwloc_get_nbobjs_by_type(topology, type);
|
||||
|
||||
return count > 0 ? static_cast<size_t>(count) : 0;
|
||||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_ARM
|
||||
static inline std::vector<hwloc_obj_t> findByType(hwloc_obj_t obj, hwloc_obj_type_t type)
|
||||
{
|
||||
std::vector<hwloc_obj_t> out;
|
||||
|
@ -100,14 +103,6 @@ static inline std::vector<hwloc_obj_t> findByType(hwloc_obj_t obj, hwloc_obj_typ
|
|||
}
|
||||
|
||||
|
||||
static inline size_t countByType(hwloc_topology_t topology, hwloc_obj_type_t type)
|
||||
{
|
||||
const int count = hwloc_get_nbobjs_by_type(topology, type);
|
||||
|
||||
return count > 0 ? static_cast<size_t>(count) : 0;
|
||||
}
|
||||
|
||||
|
||||
static inline size_t countByType(hwloc_obj_t obj, hwloc_obj_type_t type)
|
||||
{
|
||||
size_t count = 0;
|
||||
|
@ -122,6 +117,7 @@ static inline bool isCacheExclusive(hwloc_obj_t obj)
|
|||
const char *value = hwloc_obj_get_info_by_name(obj, "Inclusive");
|
||||
return value == nullptr || value[0] != '1';
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
@ -191,6 +187,12 @@ xmrig::HwlocCpuInfo::HwlocCpuInfo()
|
|||
m_nodeset.emplace_back(node->os_index);
|
||||
}
|
||||
}
|
||||
|
||||
# if defined(XMRIG_OS_MACOS) && defined(XMRIG_ARM)
|
||||
if (L2() == 33554432U && m_cores == 8 && m_cores == m_threads) {
|
||||
m_cache[2] = 16777216U;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +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 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -52,7 +46,7 @@ public:
|
|||
HwlocCpuInfo();
|
||||
~HwlocCpuInfo() override;
|
||||
|
||||
static inline bool has(Feature feature) { return m_features & feature; }
|
||||
static inline bool hasFeature(Feature feature) { return m_features & feature; }
|
||||
|
||||
inline const std::vector<uint32_t> &nodeset() const { return m_nodeset; }
|
||||
inline hwloc_topology_t topology() const { return m_topology; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue