mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-22 11:39:33 +00:00
Merge Assembly enum and Asm class.
This commit is contained in:
parent
188338c493
commit
66d62de681
19 changed files with 164 additions and 139 deletions
|
@ -36,7 +36,11 @@ if (WITH_ASM AND NOT XMRIG_ARM AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||
endif()
|
||||
|
||||
add_library(${XMRIG_ASM_LIBRARY} STATIC ${XMRIG_ASM_FILES})
|
||||
set(XMRIG_ASM_SOURCES src/crypto/cn/Asm.h src/crypto/cn/Asm.cpp src/crypto/cn/r/CryptonightR_gen.cpp)
|
||||
set(XMRIG_ASM_SOURCES
|
||||
src/crypto/common/Assembly.h
|
||||
src/crypto/common/Assembly.cpp
|
||||
src/crypto/cn/r/CryptonightR_gen.cpp
|
||||
)
|
||||
set_property(TARGET ${XMRIG_ASM_LIBRARY} PROPERTY LINKER_LANGUAGE C)
|
||||
|
||||
add_definitions(/DXMRIG_FEATURE_ASM)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "common/cpu/Cpu.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "crypto/cn/Asm.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
#include "Mem.h"
|
||||
#include "Summary.h"
|
||||
#include "version.h"
|
||||
|
@ -49,7 +49,7 @@ static const char *coloredAsmNames[] = {
|
|||
};
|
||||
|
||||
|
||||
inline static const char *asmName(xmrig::Assembly assembly)
|
||||
inline static const char *asmName(xmrig::Assembly::Id assembly)
|
||||
{
|
||||
return coloredAsmNames[assembly];
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ static void print_threads(xmrig::Config *config)
|
|||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
if (config->assembly() == xmrig::ASM_AUTO) {
|
||||
if (config->assembly() == xmrig::Assembly::AUTO) {
|
||||
const xmrig::Assembly assembly = xmrig::Cpu::info()->assembly();
|
||||
|
||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13sauto:%s"), "ASSEMBLY", asmName(assembly));
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
protected:
|
||||
size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override;
|
||||
|
||||
inline Assembly assembly() const override { return m_assembly; }
|
||||
inline Assembly::Id assembly() const override { return m_assembly; }
|
||||
inline bool hasAES() const override { return m_aes; }
|
||||
inline bool hasAVX2() const override { return m_avx2; }
|
||||
inline bool isSupported() const override { return true; }
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
|
||||
#include "common/xmrig.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -39,7 +39,7 @@ namespace xmrig {
|
|||
class ICpuInfo
|
||||
{
|
||||
public:
|
||||
virtual ~ICpuInfo() {}
|
||||
virtual ~ICpuInfo() = default;
|
||||
|
||||
virtual bool hasAES() const = 0;
|
||||
virtual bool hasAVX2() const = 0;
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
virtual int32_t sockets() const = 0;
|
||||
virtual int32_t threads() const = 0;
|
||||
virtual size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const = 0;
|
||||
virtual xmrig::Assembly assembly() const = 0;
|
||||
virtual Assembly::Id assembly() const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -72,16 +72,6 @@ enum OclVendor {
|
|||
};
|
||||
|
||||
|
||||
enum Assembly {
|
||||
ASM_NONE,
|
||||
ASM_AUTO,
|
||||
ASM_INTEL,
|
||||
ASM_RYZEN,
|
||||
ASM_BULLDOZER,
|
||||
ASM_MAX
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "crypto/cn/Asm.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include "rapidjson/prettywriter.h"
|
||||
|
@ -45,7 +45,6 @@ static char affinity_tmp[20] = { 0 };
|
|||
xmrig::Config::Config() :
|
||||
m_aesMode(AES_AUTO),
|
||||
m_algoVariant(AV_AUTO),
|
||||
m_assembly(ASM_AUTO),
|
||||
m_hugePages(true),
|
||||
m_safe(false),
|
||||
m_shouldSave(false),
|
||||
|
@ -99,7 +98,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
doc.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
||||
doc.AddMember("asm", m_assembly.toJSON(), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||
|
@ -285,6 +284,6 @@ xmrig::AlgoVariant xmrig::Config::getAlgoVariantLite() const
|
|||
#ifdef XMRIG_FEATURE_ASM
|
||||
void xmrig::Config::setAssembly(const rapidjson::Value &assembly)
|
||||
{
|
||||
m_assembly = Asm::parse(assembly);
|
||||
m_assembly = assembly;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
|
||||
xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
||||
m_assembly(ASM_NONE),
|
||||
m_aes(false),
|
||||
m_avx2(false),
|
||||
m_L2_exclusive(false),
|
||||
|
@ -78,10 +77,10 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
|||
m_aes = true;
|
||||
|
||||
if (data.vendor == VENDOR_AMD) {
|
||||
m_assembly = (data.ext_family >= 23) ? ASM_RYZEN : ASM_BULLDOZER;
|
||||
m_assembly = (data.ext_family >= 23) ? Assembly::RYZEN : Assembly::BULLDOZER;
|
||||
}
|
||||
else if (data.vendor == VENDOR_INTEL) {
|
||||
m_assembly = ASM_INTEL;
|
||||
m_assembly = Assembly::INTEL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
protected:
|
||||
size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override;
|
||||
|
||||
inline Assembly assembly() const override { return m_assembly; }
|
||||
inline Assembly::Id assembly() const override { return m_assembly; }
|
||||
inline bool hasAES() const override { return m_aes; }
|
||||
inline bool hasAVX2() const override { return m_avx2; }
|
||||
inline bool isSupported() const override { return true; }
|
||||
|
|
|
@ -1,50 +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 2016-2018 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_ASM_H
|
||||
#define XMRIG_ASM_H
|
||||
|
||||
|
||||
#include "common/xmrig.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Asm
|
||||
{
|
||||
public:
|
||||
static Assembly parse(const char *assembly, Assembly defaultValue = ASM_AUTO);
|
||||
static Assembly parse(const rapidjson::Value &value, Assembly defaultValue = ASM_AUTO);
|
||||
static const char *toString(Assembly assembly);
|
||||
static rapidjson::Value toJSON(Assembly assembly);
|
||||
|
||||
inline static Assembly parse(bool enable) { return enable ? ASM_AUTO : ASM_NONE; }
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_ASM_H */
|
|
@ -39,26 +39,26 @@
|
|||
|
||||
|
||||
#define ADD_FN(algo) \
|
||||
m_map[algo][AV_SINGLE][ASM_NONE] = cryptonight_single_hash<algo, false>; \
|
||||
m_map[algo][AV_SINGLE_SOFT][ASM_NONE] = cryptonight_single_hash<algo, true>; \
|
||||
m_map[algo][AV_DOUBLE][ASM_NONE] = cryptonight_double_hash<algo, false>; \
|
||||
m_map[algo][AV_DOUBLE_SOFT][ASM_NONE] = cryptonight_double_hash<algo, true>; \
|
||||
m_map[algo][AV_TRIPLE][ASM_NONE] = cryptonight_triple_hash<algo, false>; \
|
||||
m_map[algo][AV_TRIPLE_SOFT][ASM_NONE] = cryptonight_triple_hash<algo, true>; \
|
||||
m_map[algo][AV_QUAD][ASM_NONE] = cryptonight_quad_hash<algo, false>; \
|
||||
m_map[algo][AV_QUAD_SOFT][ASM_NONE] = cryptonight_quad_hash<algo, true>; \
|
||||
m_map[algo][AV_PENTA][ASM_NONE] = cryptonight_penta_hash<algo, false>; \
|
||||
m_map[algo][AV_PENTA_SOFT][ASM_NONE] = cryptonight_penta_hash<algo, true>;
|
||||
m_map[algo][AV_SINGLE][Assembly::NONE] = cryptonight_single_hash<algo, false>; \
|
||||
m_map[algo][AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash<algo, true>; \
|
||||
m_map[algo][AV_DOUBLE][Assembly::NONE] = cryptonight_double_hash<algo, false>; \
|
||||
m_map[algo][AV_DOUBLE_SOFT][Assembly::NONE] = cryptonight_double_hash<algo, true>; \
|
||||
m_map[algo][AV_TRIPLE][Assembly::NONE] = cryptonight_triple_hash<algo, false>; \
|
||||
m_map[algo][AV_TRIPLE_SOFT][Assembly::NONE] = cryptonight_triple_hash<algo, true>; \
|
||||
m_map[algo][AV_QUAD][Assembly::NONE] = cryptonight_quad_hash<algo, false>; \
|
||||
m_map[algo][AV_QUAD_SOFT][Assembly::NONE] = cryptonight_quad_hash<algo, true>; \
|
||||
m_map[algo][AV_PENTA][Assembly::NONE] = cryptonight_penta_hash<algo, false>; \
|
||||
m_map[algo][AV_PENTA_SOFT][Assembly::NONE] = cryptonight_penta_hash<algo, true>;
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_ASM
|
||||
# define ADD_FN_ASM(algo) \
|
||||
m_map[algo][AV_SINGLE][ASM_INTEL] = cryptonight_single_hash_asm<algo, ASM_INTEL>; \
|
||||
m_map[algo][AV_SINGLE][ASM_RYZEN] = cryptonight_single_hash_asm<algo, ASM_RYZEN>; \
|
||||
m_map[algo][AV_SINGLE][ASM_BULLDOZER] = cryptonight_single_hash_asm<algo, ASM_BULLDOZER>; \
|
||||
m_map[algo][AV_DOUBLE][ASM_INTEL] = cryptonight_double_hash_asm<algo, ASM_INTEL>; \
|
||||
m_map[algo][AV_DOUBLE][ASM_RYZEN] = cryptonight_double_hash_asm<algo, ASM_RYZEN>; \
|
||||
m_map[algo][AV_DOUBLE][ASM_BULLDOZER] = cryptonight_double_hash_asm<algo, ASM_BULLDOZER>;
|
||||
m_map[algo][AV_SINGLE][Assembly::INTEL] = cryptonight_single_hash_asm<algo, Assembly::INTEL>; \
|
||||
m_map[algo][AV_SINGLE][Assembly::RYZEN] = cryptonight_single_hash_asm<algo, Assembly::RYZEN>; \
|
||||
m_map[algo][AV_SINGLE][Assembly::BULLDOZER] = cryptonight_single_hash_asm<algo, Assembly::BULLDOZER>; \
|
||||
m_map[algo][AV_DOUBLE][Assembly::INTEL] = cryptonight_double_hash_asm<algo, Assembly::INTEL>; \
|
||||
m_map[algo][AV_DOUBLE][Assembly::RYZEN] = cryptonight_double_hash_asm<algo, Assembly::RYZEN>; \
|
||||
m_map[algo][AV_DOUBLE][Assembly::BULLDOZER] = cryptonight_double_hash_asm<algo, Assembly::BULLDOZER>;
|
||||
|
||||
|
||||
extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx **ctx);
|
||||
|
@ -226,8 +226,8 @@ xmrig::CnHash::CnHash()
|
|||
ADD_FN_ASM(Algorithm::CN_DOUBLE);
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
m_map[Algorithm::CN_GPU][AV_SINGLE][ASM_NONE] = cryptonight_single_hash_gpu<Algorithm::CN_GPU, false>;
|
||||
m_map[Algorithm::CN_GPU][AV_SINGLE_SOFT][ASM_NONE] = cryptonight_single_hash_gpu<Algorithm::CN_GPU, true>;
|
||||
m_map[Algorithm::CN_GPU][AV_SINGLE][Assembly::NONE] = cryptonight_single_hash_gpu<Algorithm::CN_GPU, false>;
|
||||
m_map[Algorithm::CN_GPU][AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash_gpu<Algorithm::CN_GPU, true>;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
|
@ -252,18 +252,18 @@ xmrig::CnHash::CnHash()
|
|||
}
|
||||
|
||||
|
||||
xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, Assembly assembly) const
|
||||
xmrig::cn_hash_fun xmrig::CnHash::fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly) const
|
||||
{
|
||||
if (!algorithm.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
cn_hash_fun fun = m_map[algorithm][av][assembly == ASM_AUTO ? Cpu::info()->assembly() : assembly];
|
||||
cn_hash_fun fun = m_map[algorithm][av][assembly == Assembly::AUTO ? Cpu::info()->assembly() : assembly];
|
||||
if (fun) {
|
||||
return fun;
|
||||
}
|
||||
# endif
|
||||
|
||||
return m_map[algorithm][av][ASM_NONE];
|
||||
return m_map[algorithm][av][Assembly::NONE];
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "common/xmrig.h"
|
||||
#include "crypto/cn/CnAlgo.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
|
||||
|
||||
struct cryptonight_ctx;
|
||||
|
@ -50,10 +51,10 @@ class CnHash
|
|||
public:
|
||||
CnHash();
|
||||
|
||||
cn_hash_fun fn(const Algorithm &algorithm, AlgoVariant av, Assembly assembly) const;
|
||||
cn_hash_fun fn(const Algorithm &algorithm, AlgoVariant av, Assembly::Id assembly) const;
|
||||
|
||||
private:
|
||||
cn_hash_fun m_map[Algorithm::MAX][AV_MAX][ASM_MAX] = {};
|
||||
cn_hash_fun m_map[Algorithm::MAX][AV_MAX][Assembly::MAX] = {};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -577,10 +577,10 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
const int code_size = v4_random_math_init<ALGO>(code, height);
|
||||
|
||||
if (ALGO == Algorithm::CN_WOW) {
|
||||
wow_soft_aes_compile_code(code, code_size, reinterpret_cast<void*>(ctx[0]->generated_code), ASM_NONE);
|
||||
wow_soft_aes_compile_code(code, code_size, reinterpret_cast<void*>(ctx[0]->generated_code), Assembly::NONE);
|
||||
}
|
||||
else if (ALGO == Algorithm::CN_R) {
|
||||
v4_soft_aes_compile_code(code, code_size, reinterpret_cast<void*>(ctx[0]->generated_code), ASM_NONE);
|
||||
v4_soft_aes_compile_code(code, code_size, reinterpret_cast<void*>(ctx[0]->generated_code), Assembly::NONE);
|
||||
}
|
||||
|
||||
ctx[0]->generated_code_data = { ALGO, height };
|
||||
|
@ -849,7 +849,7 @@ void cn_r_compile_code_double<xmrig::Algorithm::CN_WOW>(const V4_Instruction* co
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
template<xmrig::Algorithm::Id ALGO, xmrig::Assembly ASM>
|
||||
template<Algorithm::Id ALGO, Assembly::Id ASM>
|
||||
inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height)
|
||||
{
|
||||
constexpr CnAlgo<ALGO> props;
|
||||
|
@ -866,10 +866,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
cn_explode_scratchpad<ALGO, false>(reinterpret_cast<const __m128i*>(ctx[0]->state), reinterpret_cast<__m128i*>(ctx[0]->memory));
|
||||
|
||||
if (ALGO == Algorithm::CN_2) {
|
||||
if (ASM == ASM_INTEL) {
|
||||
if (ASM == Assembly::INTEL) {
|
||||
cnv2_mainloop_ivybridge_asm(ctx);
|
||||
}
|
||||
else if (ASM == ASM_RYZEN) {
|
||||
else if (ASM == Assembly::RYZEN) {
|
||||
cnv2_mainloop_ryzen_asm(ctx);
|
||||
}
|
||||
else {
|
||||
|
@ -877,10 +877,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
}
|
||||
}
|
||||
else if (ALGO == Algorithm::CN_HALF) {
|
||||
if (ASM == ASM_INTEL) {
|
||||
if (ASM == Assembly::INTEL) {
|
||||
cn_half_mainloop_ivybridge_asm(ctx);
|
||||
}
|
||||
else if (ASM == ASM_RYZEN) {
|
||||
else if (ASM == Assembly::RYZEN) {
|
||||
cn_half_mainloop_ryzen_asm(ctx);
|
||||
}
|
||||
else {
|
||||
|
@ -889,10 +889,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
}
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
else if (ALGO == Algorithm::CN_PICO_0) {
|
||||
if (ASM == ASM_INTEL) {
|
||||
if (ASM == Assembly::INTEL) {
|
||||
cn_trtl_mainloop_ivybridge_asm(ctx);
|
||||
}
|
||||
else if (ASM == ASM_RYZEN) {
|
||||
else if (ASM == Assembly::RYZEN) {
|
||||
cn_trtl_mainloop_ryzen_asm(ctx);
|
||||
}
|
||||
else {
|
||||
|
@ -904,10 +904,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
cnv2_rwz_mainloop_asm(ctx);
|
||||
}
|
||||
else if (ALGO == Algorithm::CN_ZLS) {
|
||||
if (ASM == ASM_INTEL) {
|
||||
if (ASM == Assembly::INTEL) {
|
||||
cn_zls_mainloop_ivybridge_asm(ctx);
|
||||
}
|
||||
else if (ASM == ASM_RYZEN) {
|
||||
else if (ASM == Assembly::RYZEN) {
|
||||
cn_zls_mainloop_ryzen_asm(ctx);
|
||||
}
|
||||
else {
|
||||
|
@ -915,10 +915,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
}
|
||||
}
|
||||
else if (ALGO == Algorithm::CN_DOUBLE) {
|
||||
if (ASM == ASM_INTEL) {
|
||||
if (ASM == Assembly::INTEL) {
|
||||
cn_double_mainloop_ivybridge_asm(ctx);
|
||||
}
|
||||
else if (ASM == ASM_RYZEN) {
|
||||
else if (ASM == Assembly::RYZEN) {
|
||||
cn_double_mainloop_ryzen_asm(ctx);
|
||||
}
|
||||
else {
|
||||
|
@ -935,7 +935,7 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
|||
}
|
||||
|
||||
|
||||
template<xmrig::Algorithm::Id ALGO, xmrig::Assembly ASM>
|
||||
template<Algorithm::Id ALGO, Assembly::Id ASM>
|
||||
inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height)
|
||||
{
|
||||
constexpr CnAlgo<ALGO> props;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
typedef void(*void_func)();
|
||||
|
||||
#include "crypto/cn/asm/CryptonightR_template.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
#include "crypto/common/VirtualMemory.h"
|
||||
#include "Mem.h"
|
||||
|
||||
|
@ -42,7 +43,7 @@ static inline void add_code(uint8_t* &p, void (*p1)(), void (*p2)())
|
|||
}
|
||||
}
|
||||
|
||||
static inline void add_random_math(uint8_t* &p, const V4_Instruction* code, int code_size, const void_func* instructions, const void_func* instructions_mov, bool is_64_bit, xmrig::Assembly ASM)
|
||||
static inline void add_random_math(uint8_t* &p, const V4_Instruction* code, int code_size, const void_func* instructions, const void_func* instructions_mov, bool is_64_bit, xmrig::Assembly::Id ASM)
|
||||
{
|
||||
uint32_t prev_rot_src = (uint32_t)(-1);
|
||||
|
||||
|
@ -76,7 +77,7 @@ static inline void add_random_math(uint8_t* &p, const V4_Instruction* code, int
|
|||
|
||||
void_func begin = instructions[c];
|
||||
|
||||
if ((ASM = xmrig::ASM_BULLDOZER) && (inst.opcode == MUL) && !is_64_bit) {
|
||||
if ((ASM = xmrig::Assembly::BULLDOZER) && (inst.opcode == MUL) && !is_64_bit) {
|
||||
// AMD Bulldozer has latency 4 for 32-bit IMUL and 6 for 64-bit IMUL
|
||||
// Always use 32-bit IMUL for AMD Bulldozer in 32-bit mode - skip prefix 0x48 and change 0x49 to 0x41
|
||||
uint8_t* prefix = reinterpret_cast<uint8_t*>(begin);
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define strncasecmp _strnicmp
|
||||
# define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL)
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
RX_WOW, // "rx/wow" RandomWOW
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero)
|
||||
# endif
|
||||
MAX
|
||||
};
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* 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
|
||||
|
@ -28,15 +29,17 @@
|
|||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define strncasecmp _strnicmp
|
||||
# define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
|
||||
#include "crypto/cn/Asm.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const char *asmNames[] = {
|
||||
"none",
|
||||
"auto",
|
||||
|
@ -46,11 +49,13 @@ static const char *asmNames[] = {
|
|||
};
|
||||
|
||||
|
||||
xmrig::Assembly xmrig::Asm::parse(const char *assembly, Assembly defaultValue)
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
xmrig::Assembly::Id xmrig::Assembly::parse(const char *assembly, Id defaultValue)
|
||||
{
|
||||
constexpr size_t const size = sizeof(asmNames) / sizeof((asmNames)[0]);
|
||||
assert(assembly != nullptr);
|
||||
assert(ASM_MAX == size);
|
||||
static_assert(size == MAX, "asmNames size mismatch");
|
||||
|
||||
if (assembly == nullptr) {
|
||||
return defaultValue;
|
||||
|
@ -58,7 +63,7 @@ xmrig::Assembly xmrig::Asm::parse(const char *assembly, Assembly defaultValue)
|
|||
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (strcasecmp(assembly, asmNames[i]) == 0) {
|
||||
return static_cast<Assembly>(i);
|
||||
return static_cast<Id>(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,10 +71,10 @@ xmrig::Assembly xmrig::Asm::parse(const char *assembly, Assembly defaultValue)
|
|||
}
|
||||
|
||||
|
||||
xmrig::Assembly xmrig::Asm::parse(const rapidjson::Value &value, Assembly defaultValue)
|
||||
xmrig::Assembly::Id xmrig::Assembly::parse(const rapidjson::Value &value, Id defaultValue)
|
||||
{
|
||||
if (value.IsBool()) {
|
||||
return parse(value.GetBool());
|
||||
return value.GetBool() ? AUTO : NONE;
|
||||
}
|
||||
|
||||
if (value.IsString()) {
|
||||
|
@ -80,23 +85,23 @@ xmrig::Assembly xmrig::Asm::parse(const rapidjson::Value &value, Assembly defaul
|
|||
}
|
||||
|
||||
|
||||
const char *xmrig::Asm::toString(Assembly assembly)
|
||||
const char *xmrig::Assembly::toString() const
|
||||
{
|
||||
return asmNames[assembly];
|
||||
return asmNames[m_id];
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Asm::toJSON(Assembly assembly)
|
||||
rapidjson::Value xmrig::Assembly::toJSON() const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
if (assembly == ASM_NONE) {
|
||||
if (m_id == NONE) {
|
||||
return Value(false);
|
||||
}
|
||||
|
||||
if (assembly == ASM_AUTO) {
|
||||
if (m_id == AUTO) {
|
||||
return Value(true);
|
||||
}
|
||||
|
||||
return Value(StringRef(toString(assembly)));
|
||||
return Value(StringRef(toString()));
|
||||
}
|
79
src/crypto/common/Assembly.h
Normal file
79
src/crypto/common/Assembly.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/* 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_ASSEMBLY_H
|
||||
#define XMRIG_ASSEMBLY_H
|
||||
|
||||
|
||||
#include "common/xmrig.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Assembly
|
||||
{
|
||||
public:
|
||||
enum Id : int {
|
||||
NONE,
|
||||
AUTO,
|
||||
INTEL,
|
||||
RYZEN,
|
||||
BULLDOZER,
|
||||
MAX
|
||||
};
|
||||
|
||||
|
||||
inline Assembly() {}
|
||||
inline Assembly(Id id) : m_id(id) {}
|
||||
inline Assembly(const char *assembly) : m_id(parse(assembly)) {}
|
||||
inline Assembly(const rapidjson::Value &value) : m_id(parse(value)) {}
|
||||
|
||||
static Id parse(const char *assembly, Id defaultValue = AUTO);
|
||||
static Id parse(const rapidjson::Value &value, Id defaultValue = AUTO);
|
||||
|
||||
const char *toString() const;
|
||||
rapidjson::Value toJSON() const;
|
||||
|
||||
// inline static Assembly parse(bool enable) { return enable ? ASM_AUTO : ASM_NONE; }
|
||||
|
||||
inline bool isEqual(const Assembly &other) const { return m_id == other.m_id; }
|
||||
|
||||
|
||||
inline bool operator!=(const Assembly &other) const { return !isEqual(other); }
|
||||
inline bool operator!=(const Assembly::Id &id) const { return m_id != id; }
|
||||
inline bool operator==(const Assembly &other) const { return isEqual(other); }
|
||||
inline bool operator==(const Assembly::Id &id) const { return m_id == id; }
|
||||
inline operator Assembly::Id() const { return m_id; }
|
||||
|
||||
private:
|
||||
Id m_id = AUTO;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_ASSEMBLY_H */
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
#include "base/io/log/Log.h"
|
||||
#include "common/cpu/Cpu.h"
|
||||
#include "crypto/cn/Asm.h"
|
||||
#include "crypto/cn/CnHash.h"
|
||||
#include "crypto/common/Assembly.h"
|
||||
#include "crypto/common/VirtualMemory.h"
|
||||
#include "Mem.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
@ -36,8 +36,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
static const xmrig::CnHash cnHash;
|
||||
|
||||
|
||||
|
@ -136,7 +134,7 @@ xmrig::CpuThread::Data xmrig::CpuThread::parse(const rapidjson::Value &object)
|
|||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
data.assembly = Asm::parse(object["asm"]);
|
||||
data.assembly = object["asm"];
|
||||
# endif
|
||||
|
||||
return data;
|
||||
|
@ -181,7 +179,7 @@ void xmrig::CpuThread::print() const
|
|||
index(), static_cast<int>(multiway()), static_cast<int>(m_av));
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
LOG_DEBUG(" assembly: %s, affine_to_cpu: %" PRId64, Asm::toString(m_assembly), affinity());
|
||||
LOG_DEBUG(" assembly: %s, affine_to_cpu: %" PRId64, m_assembly.toString(), affinity());
|
||||
# else
|
||||
LOG_DEBUG(" affine_to_cpu: %" PRId64, affinity());
|
||||
# endif
|
||||
|
@ -220,7 +218,7 @@ rapidjson::Value xmrig::CpuThread::toConfig(rapidjson::Document &doc) const
|
|||
obj.AddMember("affine_to_cpu", affinity() == -1L ? Value(kFalseType) : Value(affinity()), allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
obj.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
||||
obj.AddMember("asm", m_assembly.toJSON(), allocator);
|
||||
# endif
|
||||
|
||||
return obj;
|
||||
|
|
|
@ -42,7 +42,7 @@ class CpuThread : public IThread
|
|||
public:
|
||||
struct Data
|
||||
{
|
||||
inline Data() : assembly(ASM_AUTO), valid(false), affinity(-1L), multiway(SingleWay) {}
|
||||
inline Data() : valid(false), affinity(-1L), multiway(SingleWay) {}
|
||||
|
||||
inline void setMultiway(int value)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue