mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-22 19:49:36 +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()
|
endif()
|
||||||
|
|
||||||
add_library(${XMRIG_ASM_LIBRARY} STATIC ${XMRIG_ASM_FILES})
|
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)
|
set_property(TARGET ${XMRIG_ASM_LIBRARY} PROPERTY LINKER_LANGUAGE C)
|
||||||
|
|
||||||
add_definitions(/DXMRIG_FEATURE_ASM)
|
add_definitions(/DXMRIG_FEATURE_ASM)
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "common/cpu/Cpu.h"
|
#include "common/cpu/Cpu.h"
|
||||||
#include "core/config/Config.h"
|
#include "core/config/Config.h"
|
||||||
#include "core/Controller.h"
|
#include "core/Controller.h"
|
||||||
#include "crypto/cn/Asm.h"
|
#include "crypto/common/Assembly.h"
|
||||||
#include "Mem.h"
|
#include "Mem.h"
|
||||||
#include "Summary.h"
|
#include "Summary.h"
|
||||||
#include "version.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];
|
return coloredAsmNames[assembly];
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ static void print_threads(xmrig::Config *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# ifdef XMRIG_FEATURE_ASM
|
||||||
if (config->assembly() == xmrig::ASM_AUTO) {
|
if (config->assembly() == xmrig::Assembly::AUTO) {
|
||||||
const xmrig::Assembly assembly = xmrig::Cpu::info()->assembly();
|
const xmrig::Assembly assembly = xmrig::Cpu::info()->assembly();
|
||||||
|
|
||||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13sauto:%s"), "ASSEMBLY", asmName(assembly));
|
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13sauto:%s"), "ASSEMBLY", asmName(assembly));
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override;
|
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 hasAES() const override { return m_aes; }
|
||||||
inline bool hasAVX2() const override { return m_avx2; }
|
inline bool hasAVX2() const override { return m_avx2; }
|
||||||
inline bool isSupported() const override { return true; }
|
inline bool isSupported() const override { return true; }
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
#include "common/xmrig.h"
|
#include "crypto/common/Assembly.h"
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
@ -39,7 +39,7 @@ namespace xmrig {
|
||||||
class ICpuInfo
|
class ICpuInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ICpuInfo() {}
|
virtual ~ICpuInfo() = default;
|
||||||
|
|
||||||
virtual bool hasAES() const = 0;
|
virtual bool hasAES() const = 0;
|
||||||
virtual bool hasAVX2() const = 0;
|
virtual bool hasAVX2() const = 0;
|
||||||
|
@ -53,7 +53,7 @@ public:
|
||||||
virtual int32_t sockets() const = 0;
|
virtual int32_t sockets() const = 0;
|
||||||
virtual int32_t threads() const = 0;
|
virtual int32_t threads() const = 0;
|
||||||
virtual size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) 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 */
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "base/kernel/interfaces/IJsonReader.h"
|
#include "base/kernel/interfaces/IJsonReader.h"
|
||||||
#include "common/cpu/Cpu.h"
|
#include "common/cpu/Cpu.h"
|
||||||
#include "core/config/Config.h"
|
#include "core/config/Config.h"
|
||||||
#include "crypto/cn/Asm.h"
|
#include "crypto/common/Assembly.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
#include "rapidjson/filewritestream.h"
|
#include "rapidjson/filewritestream.h"
|
||||||
#include "rapidjson/prettywriter.h"
|
#include "rapidjson/prettywriter.h"
|
||||||
|
@ -45,7 +45,6 @@ static char affinity_tmp[20] = { 0 };
|
||||||
xmrig::Config::Config() :
|
xmrig::Config::Config() :
|
||||||
m_aesMode(AES_AUTO),
|
m_aesMode(AES_AUTO),
|
||||||
m_algoVariant(AV_AUTO),
|
m_algoVariant(AV_AUTO),
|
||||||
m_assembly(ASM_AUTO),
|
|
||||||
m_hugePages(true),
|
m_hugePages(true),
|
||||||
m_safe(false),
|
m_safe(false),
|
||||||
m_shouldSave(false),
|
m_shouldSave(false),
|
||||||
|
@ -99,7 +98,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
doc.AddMember("http", m_http.toJSON(doc), allocator);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# ifdef XMRIG_FEATURE_ASM
|
||||||
doc.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
doc.AddMember("asm", m_assembly.toJSON(), allocator);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
doc.AddMember("autosave", isAutoSave(), allocator);
|
doc.AddMember("autosave", isAutoSave(), allocator);
|
||||||
|
@ -285,6 +284,6 @@ xmrig::AlgoVariant xmrig::Config::getAlgoVariantLite() const
|
||||||
#ifdef XMRIG_FEATURE_ASM
|
#ifdef XMRIG_FEATURE_ASM
|
||||||
void xmrig::Config::setAssembly(const rapidjson::Value &assembly)
|
void xmrig::Config::setAssembly(const rapidjson::Value &assembly)
|
||||||
{
|
{
|
||||||
m_assembly = Asm::parse(assembly);
|
m_assembly = assembly;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
|
|
||||||
xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
||||||
m_assembly(ASM_NONE),
|
|
||||||
m_aes(false),
|
m_aes(false),
|
||||||
m_avx2(false),
|
m_avx2(false),
|
||||||
m_L2_exclusive(false),
|
m_L2_exclusive(false),
|
||||||
|
@ -78,10 +77,10 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
|
||||||
m_aes = true;
|
m_aes = true;
|
||||||
|
|
||||||
if (data.vendor == VENDOR_AMD) {
|
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) {
|
else if (data.vendor == VENDOR_INTEL) {
|
||||||
m_assembly = ASM_INTEL;
|
m_assembly = Assembly::INTEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override;
|
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 hasAES() const override { return m_aes; }
|
||||||
inline bool hasAVX2() const override { return m_avx2; }
|
inline bool hasAVX2() const override { return m_avx2; }
|
||||||
inline bool isSupported() const override { return true; }
|
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) \
|
#define ADD_FN(algo) \
|
||||||
m_map[algo][AV_SINGLE][ASM_NONE] = cryptonight_single_hash<algo, false>; \
|
m_map[algo][AV_SINGLE][Assembly::NONE] = cryptonight_single_hash<algo, false>; \
|
||||||
m_map[algo][AV_SINGLE_SOFT][ASM_NONE] = cryptonight_single_hash<algo, true>; \
|
m_map[algo][AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash<algo, true>; \
|
||||||
m_map[algo][AV_DOUBLE][ASM_NONE] = cryptonight_double_hash<algo, false>; \
|
m_map[algo][AV_DOUBLE][Assembly::NONE] = cryptonight_double_hash<algo, false>; \
|
||||||
m_map[algo][AV_DOUBLE_SOFT][ASM_NONE] = cryptonight_double_hash<algo, true>; \
|
m_map[algo][AV_DOUBLE_SOFT][Assembly::NONE] = cryptonight_double_hash<algo, true>; \
|
||||||
m_map[algo][AV_TRIPLE][ASM_NONE] = cryptonight_triple_hash<algo, false>; \
|
m_map[algo][AV_TRIPLE][Assembly::NONE] = cryptonight_triple_hash<algo, false>; \
|
||||||
m_map[algo][AV_TRIPLE_SOFT][ASM_NONE] = cryptonight_triple_hash<algo, true>; \
|
m_map[algo][AV_TRIPLE_SOFT][Assembly::NONE] = cryptonight_triple_hash<algo, true>; \
|
||||||
m_map[algo][AV_QUAD][ASM_NONE] = cryptonight_quad_hash<algo, false>; \
|
m_map[algo][AV_QUAD][Assembly::NONE] = cryptonight_quad_hash<algo, false>; \
|
||||||
m_map[algo][AV_QUAD_SOFT][ASM_NONE] = cryptonight_quad_hash<algo, true>; \
|
m_map[algo][AV_QUAD_SOFT][Assembly::NONE] = cryptonight_quad_hash<algo, true>; \
|
||||||
m_map[algo][AV_PENTA][ASM_NONE] = cryptonight_penta_hash<algo, false>; \
|
m_map[algo][AV_PENTA][Assembly::NONE] = cryptonight_penta_hash<algo, false>; \
|
||||||
m_map[algo][AV_PENTA_SOFT][ASM_NONE] = cryptonight_penta_hash<algo, true>;
|
m_map[algo][AV_PENTA_SOFT][Assembly::NONE] = cryptonight_penta_hash<algo, true>;
|
||||||
|
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_ASM
|
#ifdef XMRIG_FEATURE_ASM
|
||||||
# define ADD_FN_ASM(algo) \
|
# define ADD_FN_ASM(algo) \
|
||||||
m_map[algo][AV_SINGLE][ASM_INTEL] = cryptonight_single_hash_asm<algo, ASM_INTEL>; \
|
m_map[algo][AV_SINGLE][Assembly::INTEL] = cryptonight_single_hash_asm<algo, Assembly::INTEL>; \
|
||||||
m_map[algo][AV_SINGLE][ASM_RYZEN] = cryptonight_single_hash_asm<algo, ASM_RYZEN>; \
|
m_map[algo][AV_SINGLE][Assembly::RYZEN] = cryptonight_single_hash_asm<algo, Assembly::RYZEN>; \
|
||||||
m_map[algo][AV_SINGLE][ASM_BULLDOZER] = cryptonight_single_hash_asm<algo, ASM_BULLDOZER>; \
|
m_map[algo][AV_SINGLE][Assembly::BULLDOZER] = cryptonight_single_hash_asm<algo, Assembly::BULLDOZER>; \
|
||||||
m_map[algo][AV_DOUBLE][ASM_INTEL] = cryptonight_double_hash_asm<algo, ASM_INTEL>; \
|
m_map[algo][AV_DOUBLE][Assembly::INTEL] = cryptonight_double_hash_asm<algo, Assembly::INTEL>; \
|
||||||
m_map[algo][AV_DOUBLE][ASM_RYZEN] = cryptonight_double_hash_asm<algo, ASM_RYZEN>; \
|
m_map[algo][AV_DOUBLE][Assembly::RYZEN] = cryptonight_double_hash_asm<algo, Assembly::RYZEN>; \
|
||||||
m_map[algo][AV_DOUBLE][ASM_BULLDOZER] = cryptonight_double_hash_asm<algo, ASM_BULLDOZER>;
|
m_map[algo][AV_DOUBLE][Assembly::BULLDOZER] = cryptonight_double_hash_asm<algo, Assembly::BULLDOZER>;
|
||||||
|
|
||||||
|
|
||||||
extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx **ctx);
|
extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx **ctx);
|
||||||
|
@ -226,8 +226,8 @@ xmrig::CnHash::CnHash()
|
||||||
ADD_FN_ASM(Algorithm::CN_DOUBLE);
|
ADD_FN_ASM(Algorithm::CN_DOUBLE);
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_GPU
|
# 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][Assembly::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_SOFT][Assembly::NONE] = cryptonight_single_hash_gpu<Algorithm::CN_GPU, true>;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_LITE
|
# 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()) {
|
if (!algorithm.isValid()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# 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) {
|
if (fun) {
|
||||||
return fun;
|
return fun;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return m_map[algorithm][av][ASM_NONE];
|
return m_map[algorithm][av][Assembly::NONE];
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "common/xmrig.h"
|
#include "common/xmrig.h"
|
||||||
#include "crypto/cn/CnAlgo.h"
|
#include "crypto/cn/CnAlgo.h"
|
||||||
|
#include "crypto/common/Assembly.h"
|
||||||
|
|
||||||
|
|
||||||
struct cryptonight_ctx;
|
struct cryptonight_ctx;
|
||||||
|
@ -50,10 +51,10 @@ class CnHash
|
||||||
public:
|
public:
|
||||||
CnHash();
|
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:
|
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);
|
const int code_size = v4_random_math_init<ALGO>(code, height);
|
||||||
|
|
||||||
if (ALGO == Algorithm::CN_WOW) {
|
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) {
|
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 };
|
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 {
|
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)
|
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;
|
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));
|
cn_explode_scratchpad<ALGO, false>(reinterpret_cast<const __m128i*>(ctx[0]->state), reinterpret_cast<__m128i*>(ctx[0]->memory));
|
||||||
|
|
||||||
if (ALGO == Algorithm::CN_2) {
|
if (ALGO == Algorithm::CN_2) {
|
||||||
if (ASM == ASM_INTEL) {
|
if (ASM == Assembly::INTEL) {
|
||||||
cnv2_mainloop_ivybridge_asm(ctx);
|
cnv2_mainloop_ivybridge_asm(ctx);
|
||||||
}
|
}
|
||||||
else if (ASM == ASM_RYZEN) {
|
else if (ASM == Assembly::RYZEN) {
|
||||||
cnv2_mainloop_ryzen_asm(ctx);
|
cnv2_mainloop_ryzen_asm(ctx);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -877,10 +877,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ALGO == Algorithm::CN_HALF) {
|
else if (ALGO == Algorithm::CN_HALF) {
|
||||||
if (ASM == ASM_INTEL) {
|
if (ASM == Assembly::INTEL) {
|
||||||
cn_half_mainloop_ivybridge_asm(ctx);
|
cn_half_mainloop_ivybridge_asm(ctx);
|
||||||
}
|
}
|
||||||
else if (ASM == ASM_RYZEN) {
|
else if (ASM == Assembly::RYZEN) {
|
||||||
cn_half_mainloop_ryzen_asm(ctx);
|
cn_half_mainloop_ryzen_asm(ctx);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -889,10 +889,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
||||||
}
|
}
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
else if (ALGO == Algorithm::CN_PICO_0) {
|
else if (ALGO == Algorithm::CN_PICO_0) {
|
||||||
if (ASM == ASM_INTEL) {
|
if (ASM == Assembly::INTEL) {
|
||||||
cn_trtl_mainloop_ivybridge_asm(ctx);
|
cn_trtl_mainloop_ivybridge_asm(ctx);
|
||||||
}
|
}
|
||||||
else if (ASM == ASM_RYZEN) {
|
else if (ASM == Assembly::RYZEN) {
|
||||||
cn_trtl_mainloop_ryzen_asm(ctx);
|
cn_trtl_mainloop_ryzen_asm(ctx);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -904,10 +904,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
||||||
cnv2_rwz_mainloop_asm(ctx);
|
cnv2_rwz_mainloop_asm(ctx);
|
||||||
}
|
}
|
||||||
else if (ALGO == Algorithm::CN_ZLS) {
|
else if (ALGO == Algorithm::CN_ZLS) {
|
||||||
if (ASM == ASM_INTEL) {
|
if (ASM == Assembly::INTEL) {
|
||||||
cn_zls_mainloop_ivybridge_asm(ctx);
|
cn_zls_mainloop_ivybridge_asm(ctx);
|
||||||
}
|
}
|
||||||
else if (ASM == ASM_RYZEN) {
|
else if (ASM == Assembly::RYZEN) {
|
||||||
cn_zls_mainloop_ryzen_asm(ctx);
|
cn_zls_mainloop_ryzen_asm(ctx);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -915,10 +915,10 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ALGO == Algorithm::CN_DOUBLE) {
|
else if (ALGO == Algorithm::CN_DOUBLE) {
|
||||||
if (ASM == ASM_INTEL) {
|
if (ASM == Assembly::INTEL) {
|
||||||
cn_double_mainloop_ivybridge_asm(ctx);
|
cn_double_mainloop_ivybridge_asm(ctx);
|
||||||
}
|
}
|
||||||
else if (ASM == ASM_RYZEN) {
|
else if (ASM == Assembly::RYZEN) {
|
||||||
cn_double_mainloop_ryzen_asm(ctx);
|
cn_double_mainloop_ryzen_asm(ctx);
|
||||||
}
|
}
|
||||||
else {
|
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)
|
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;
|
constexpr CnAlgo<ALGO> props;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
typedef void(*void_func)();
|
typedef void(*void_func)();
|
||||||
|
|
||||||
#include "crypto/cn/asm/CryptonightR_template.h"
|
#include "crypto/cn/asm/CryptonightR_template.h"
|
||||||
|
#include "crypto/common/Assembly.h"
|
||||||
#include "crypto/common/VirtualMemory.h"
|
#include "crypto/common/VirtualMemory.h"
|
||||||
#include "Mem.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);
|
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];
|
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
|
// 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
|
// 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);
|
uint8_t* prefix = reinterpret_cast<uint8_t*>(begin);
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define strncasecmp _strnicmp
|
|
||||||
# define strcasecmp _stricmp
|
# define strcasecmp _stricmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL)
|
CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL)
|
||||||
# endif
|
# endif
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
RX_WOW, // "rx/wow" RandomWOW
|
RX_WOW, // "rx/wow" RandomWOW (Wownero)
|
||||||
# endif
|
# endif
|
||||||
MAX
|
MAX
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018 SChernykh <https://github.com/SChernykh>
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -28,15 +29,17 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define strncasecmp _strnicmp
|
|
||||||
# define strcasecmp _stricmp
|
# define strcasecmp _stricmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "crypto/cn/Asm.h"
|
#include "crypto/common/Assembly.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
static const char *asmNames[] = {
|
static const char *asmNames[] = {
|
||||||
"none",
|
"none",
|
||||||
"auto",
|
"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]);
|
constexpr size_t const size = sizeof(asmNames) / sizeof((asmNames)[0]);
|
||||||
assert(assembly != nullptr);
|
static_assert(size == MAX, "asmNames size mismatch");
|
||||||
assert(ASM_MAX == size);
|
|
||||||
|
|
||||||
if (assembly == nullptr) {
|
if (assembly == nullptr) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
@ -58,7 +63,7 @@ xmrig::Assembly xmrig::Asm::parse(const char *assembly, Assembly defaultValue)
|
||||||
|
|
||||||
for (size_t i = 0; i < size; i++) {
|
for (size_t i = 0; i < size; i++) {
|
||||||
if (strcasecmp(assembly, asmNames[i]) == 0) {
|
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()) {
|
if (value.IsBool()) {
|
||||||
return parse(value.GetBool());
|
return value.GetBool() ? AUTO : NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.IsString()) {
|
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;
|
using namespace rapidjson;
|
||||||
|
|
||||||
if (assembly == ASM_NONE) {
|
if (m_id == NONE) {
|
||||||
return Value(false);
|
return Value(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assembly == ASM_AUTO) {
|
if (m_id == AUTO) {
|
||||||
return Value(true);
|
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 "base/io/log/Log.h"
|
||||||
#include "common/cpu/Cpu.h"
|
#include "common/cpu/Cpu.h"
|
||||||
#include "crypto/cn/Asm.h"
|
|
||||||
#include "crypto/cn/CnHash.h"
|
#include "crypto/cn/CnHash.h"
|
||||||
|
#include "crypto/common/Assembly.h"
|
||||||
#include "crypto/common/VirtualMemory.h"
|
#include "crypto/common/VirtualMemory.h"
|
||||||
#include "Mem.h"
|
#include "Mem.h"
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
@ -36,8 +36,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const xmrig::CnHash cnHash;
|
static const xmrig::CnHash cnHash;
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +134,7 @@ xmrig::CpuThread::Data xmrig::CpuThread::parse(const rapidjson::Value &object)
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# ifdef XMRIG_FEATURE_ASM
|
||||||
data.assembly = Asm::parse(object["asm"]);
|
data.assembly = object["asm"];
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
@ -181,7 +179,7 @@ void xmrig::CpuThread::print() const
|
||||||
index(), static_cast<int>(multiway()), static_cast<int>(m_av));
|
index(), static_cast<int>(multiway()), static_cast<int>(m_av));
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# 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
|
# else
|
||||||
LOG_DEBUG(" affine_to_cpu: %" PRId64, affinity());
|
LOG_DEBUG(" affine_to_cpu: %" PRId64, affinity());
|
||||||
# endif
|
# 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);
|
obj.AddMember("affine_to_cpu", affinity() == -1L ? Value(kFalseType) : Value(affinity()), allocator);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_ASM
|
# ifdef XMRIG_FEATURE_ASM
|
||||||
obj.AddMember("asm", Asm::toJSON(m_assembly), allocator);
|
obj.AddMember("asm", m_assembly.toJSON(), allocator);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
|
@ -42,7 +42,7 @@ class CpuThread : public IThread
|
||||||
public:
|
public:
|
||||||
struct Data
|
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)
|
inline void setMultiway(int value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue