Add UPX Support

This commit is contained in:
uPlexa 2018-12-01 23:50:38 -08:00
parent 2b0b71b9f6
commit 7aa17ae7bf
13 changed files with 129 additions and 5 deletions

View file

@ -3,6 +3,7 @@ project(xmrig)
option(WITH_LIBCPUID "Use Libcpuid" ON)
option(WITH_AEON "CryptoNight-Lite support" ON)
option(WITH_UPLEXA "CryptoNight-UPX support" ON)
option(WITH_SUMO "CryptoNight-Heavy support" ON)
option(WITH_HTTPD "HTTP REST API" ON)
option(WITH_DEBUG_LOG "Enable debug log output" OFF)
@ -208,6 +209,10 @@ if (NOT WITH_AEON)
add_definitions(/DXMRIG_NO_AEON)
endif()
if (NOT WITH_UPLEXA)
add_definitions(/DXMRIG_NO_UPLEXA)
endif()
if (NOT WITH_SUMO)
add_definitions(/DXMRIG_NO_SUMO)
endif()

View file

@ -38,6 +38,7 @@ Originally based on cpuminer-multi with heavy optimizations/rewrites and removin
* keepalived support.
* Command line options compatible with cpuminer.
* CryptoNight-Lite support for AEON.
* Cryptonight-UPX Support for uPlexa
* Smart automatic [CPU configuration](https://github.com/xmrig/xmrig/wiki/Threads).
* Nicehash support
* It's open source software.
@ -55,6 +56,7 @@ Use [config.xmrig.com](https://config.xmrig.com/xmrig) to generate, edit or shar
-a, --algo=ALGO specify the algorithm to use
cryptonight
cryptonight-lite
cryptonite-upx
cryptonight-heavy
-o, --url=URL URL of mining server
-O, --userpass=U:P username:password pair for mining server

View file

@ -45,6 +45,10 @@ MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count)
info.size += info.size % cn_select_memory<CRYPTONIGHT>();
# endif
# ifndef XMRIG_NO_UPX
info.size += info.size % cn_select_memory<CRYPTONIGHT>();
# endif
info.pages = info.size / cn_select_memory<CRYPTONIGHT>();
allocate(info, m_enabled);
@ -68,4 +72,3 @@ void Mem::release(cryptonight_ctx **ctx, size_t count, MemInfo &info)
_mm_free(ctx[i]);
}
}

View file

@ -70,6 +70,10 @@ static AlgoData const algorithms[] = {
{ "cryptonight-lite/1", "cn-lite/1", xmrig::CRYPTONIGHT_LITE, xmrig::VARIANT_1 },
# endif
# ifndef XMRIG_NO_UPLEXA
{ "cryptonight-upx", "cn-upx", xmrig::CRYPTONIGHT_UPX, xmrig::VARIANT_1 },
# endif
# ifndef XMRIG_NO_SUMO
{ "cryptonight-heavy", "cn-heavy", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_AUTO },
{ "cryptonight-heavy/0", "cn-heavy/0", xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 },

View file

@ -237,6 +237,9 @@ xmrig::Variant Job::variant() const
case CRYPTONIGHT_LITE:
return VARIANT_1;
case CRYPTONIGHT_UPX:
return VARIANT_1;
case CRYPTONIGHT_HEAVY:
return VARIANT_0;

View file

@ -355,6 +355,11 @@ void Pool::adjustVariant(const xmrig::Variant variantHint)
valid = m_algorithm.algo() == CRYPTONIGHT_LITE;
m_algorithm.setVariant(VARIANT_1);
}
else if (m_host.contains("upx.pool")) {
valid = m_algorithm.algo() == CRYPTONIGHT_UPX;
m_algorithm.setVariant(VARIANT_1);
}
if (!valid) {
m_algorithm.setAlgo(INVALID_ALGO);
@ -378,6 +383,9 @@ void Pool::adjustVariant(const xmrig::Variant variantHint)
else if (m_algorithm.algo() == CRYPTONIGHT_LITE) {
m_algorithm.setVariant(VARIANT_1);
}
else if (m_algorithm.algo() == CRYPTONIGHT_UPX) {
m_algorithm.setVariant(VARIANT_1);
}
# endif
}

View file

@ -33,6 +33,7 @@ enum Algo {
INVALID_ALGO = -1,
CRYPTONIGHT, /* CryptoNight (Monero) */
CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */
CRYPTONIGHT_UPX, /* CryptoNight-UPX (uPlexa) */
CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (RYO) */
};

View file

@ -165,7 +165,7 @@ bool xmrig::Config::finalize()
return true;
}
const AlgoVariant av = getAlgoVariant();
const AlgoVariant av = getAlgoVariant();
m_threads.mode = m_threads.count ? Simple : Automatic;
const size_t size = CpuThread::multiway(av) * cn_select_memory(m_algorithm.algo()) / 1024;
@ -354,6 +354,12 @@ xmrig::AlgoVariant xmrig::Config::getAlgoVariant() const
}
# endif
# ifndef XMRIG_NO_UPLEXA
if (m_algorithm.algo() == xmrig::CRYPTONIGHT_UPX) {
return getAlgoVariantUPX();
}
# endif
if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) {
return Cpu::info()->hasAES() ? AV_SINGLE : AV_SINGLE_SOFT;
}
@ -380,3 +386,19 @@ xmrig::AlgoVariant xmrig::Config::getAlgoVariantLite() const
return m_algoVariant;
}
#endif
#ifndef XMRIG_NO_UPLEXA
xmrig::AlgoVariant xmrig::Config::getAlgoVariantUPX() const
{
if (m_algoVariant <= AV_AUTO || m_algoVariant >= AV_MAX) {
return Cpu::info()->hasAES() ? AV_DOUBLE : AV_DOUBLE_SOFT;
}
if (m_safe && !Cpu::info()->hasAES() && m_algoVariant <= AV_DOUBLE) {
return static_cast<AlgoVariant>(m_algoVariant + 2);
}
return m_algoVariant;
}
#endif

View file

@ -102,6 +102,9 @@ private:
AlgoVariant getAlgoVariantLite() const;
# endif
# ifndef XMRIG_NO_UPLEXA
AlgoVariant getAlgoVariantUPX() const;
# endif
struct Threads
{

View file

@ -49,6 +49,10 @@ Options:\n\
"\
cryptonight-lite\n"
#endif
#ifndef XMRIG_NO_UPLEXA
"\
cryptonight-upx\n"
#endif
#ifndef XMRIG_NO_SUMO
"\
cryptonight-heavy\n"

View file

@ -45,6 +45,11 @@ constexpr const size_t CRYPTONIGHT_LITE_MEMORY = 1 * 1024 * 1024;
constexpr const uint32_t CRYPTONIGHT_LITE_MASK = 0xFFFF0;
constexpr const uint32_t CRYPTONIGHT_LITE_ITER = 0x40000;
constexpr const size_t CRYPTONIGHT_UPX_MEMORY = 1 * 1024 * 1024;
constexpr const uint32_t CRYPTONIGHT_UPX_MASK = 0xFFFF0;
constexpr const uint32_t CRYPTONIGHT_UPX_ITER = 0x20000;
constexpr const size_t CRYPTONIGHT_HEAVY_MEMORY = 4 * 1024 * 1024;
constexpr const uint32_t CRYPTONIGHT_HEAVY_MASK = 0x3FFFF0;
constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000;
@ -53,6 +58,7 @@ constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000;
template<Algo ALGO> inline constexpr size_t cn_select_memory() { return 0; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT>() { return CRYPTONIGHT_MEMORY; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_MEMORY; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_UPX>() { return CRYPTONIGHT_UPX_MEMORY; }
template<> inline constexpr size_t cn_select_memory<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_MEMORY; }
@ -66,6 +72,9 @@ inline size_t cn_select_memory(Algo algorithm)
case CRYPTONIGHT_LITE:
return CRYPTONIGHT_LITE_MEMORY;
case CRYPTONIGHT_UPX:
return CRYPTONIGHT_UPX_MEMORY;
case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_MEMORY;
@ -80,6 +89,7 @@ inline size_t cn_select_memory(Algo algorithm)
template<Algo ALGO> inline constexpr uint32_t cn_select_mask() { return 0; }
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT>() { return CRYPTONIGHT_MASK; }
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_LITE>() { return CRYPTONIGHT_LITE_MASK; }
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_UPX>() { return CRYPTONIGHT_UPX_MASK; }
template<> inline constexpr uint32_t cn_select_mask<CRYPTONIGHT_HEAVY>() { return CRYPTONIGHT_HEAVY_MASK; }
@ -91,7 +101,10 @@ inline uint32_t cn_select_mask(Algo algorithm)
return CRYPTONIGHT_MASK;
case CRYPTONIGHT_LITE:
return CRYPTONIGHT_LITE_MASK;
return CRYPTONIGHT_LITE_MASK
case CRYPTONIGHT_UPX:
return CRYPTONIGHT_UPX_MASK;
case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_MASK;
@ -114,6 +127,7 @@ template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_XAO>()
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT, VARIANT_RTO>() { return CRYPTONIGHT_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE, VARIANT_0>() { return CRYPTONIGHT_LITE_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_LITE, VARIANT_1>() { return CRYPTONIGHT_LITE_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_UPX, VARIANT_1>() { return CRYPTONIGHT_UPX_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY, VARIANT_0>() { return CRYPTONIGHT_HEAVY_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY, VARIANT_XHV>() { return CRYPTONIGHT_HEAVY_ITER; }
template<> inline constexpr uint32_t cn_select_iter<CRYPTONIGHT_HEAVY, VARIANT_TUBE>() { return CRYPTONIGHT_HEAVY_ITER; }
@ -140,6 +154,9 @@ inline uint32_t cn_select_iter(Algo algorithm, Variant variant)
case CRYPTONIGHT_LITE:
return CRYPTONIGHT_LITE_ITER;
case CRYPTONIGHT_UPX:
return CRYPTONIGHT_UPX_ITER;
case CRYPTONIGHT_HEAVY:
return CRYPTONIGHT_HEAVY_ITER;

View file

@ -64,9 +64,9 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
assert(variant >= VARIANT_0 && variant < VARIANT_MAX);
# ifndef XMRIG_NO_ASM
constexpr const size_t count = VARIANT_MAX * 10 * 3 + 3;
constexpr const size_t count = VARIANT_MAX * 10 * 4 + 3;
# else
constexpr const size_t count = VARIANT_MAX * 10 * 3;
constexpr const size_t count = VARIANT_MAX * 10 * 4;
# endif
static const cn_hash_fun func_table[count] = {
@ -193,6 +193,50 @@ xmrig::CpuThread::cn_hash_fun xmrig::CpuThread::fn(Algo algorithm, AlgoVariant a
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
# endif
# ifndef XMRIG_NO_UPLEXA
cryptonight_single_hash<CRYPTONIGHT_UPX, false, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT_UPX, false, VARIANT_0>,
cryptonight_single_hash<CRYPTONIGHT_UPX, true, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT_UPX, true, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT_UPX, false, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT_UPX, false, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT_UPX, false, VARIANT_0>,
cryptonight_triple_hash<CRYPTONIGHT_UPX, true, VARIANT_0>,
cryptonight_quad_hash<CRYPTONIGHT_UPX, true, VARIANT_0>,
cryptonight_penta_hash<CRYPTONIGHT_UPX, true, VARIANT_0>,
cryptonight_single_hash<CRYPTONIGHT_UPX, false, VARIANT_1>,
cryptonight_double_hash<CRYPTONIGHT_UPX, false, VARIANT_1>,
cryptonight_single_hash<CRYPTONIGHT_UPX, true, VARIANT_1>,
cryptonight_double_hash<CRYPTONIGHT_UPX, true, VARIANT_1>,
cryptonight_triple_hash<CRYPTONIGHT_UPX, false, VARIANT_1>,
cryptonight_quad_hash<CRYPTONIGHT_UPX, false, VARIANT_1>,
cryptonight_penta_hash<CRYPTONIGHT_UPX, false, VARIANT_1>,
cryptonight_triple_hash<CRYPTONIGHT_UPX, true, VARIANT_1>,
cryptonight_quad_hash<CRYPTONIGHT_UPX, true, VARIANT_1>,
cryptonight_penta_hash<CRYPTONIGHT_UPX, true, VARIANT_1>,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_TUBE
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XTL
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_MSR
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XHV
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_XAO
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_RTO
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, // VARIANT_2
# else
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
# endif
# ifndef XMRIG_NO_SUMO
cryptonight_single_hash<CRYPTONIGHT_HEAVY, false, VARIANT_0>,
cryptonight_double_hash<CRYPTONIGHT_HEAVY, false, VARIANT_0>,

View file

@ -70,6 +70,14 @@ bool MultiWorker<N>::selfTest()
}
# endif
# ifndef XMRIG_NO_UPLEXA
if (m_thread->algorithm() == CRYPTONIGHT_UPX) {
//return verify(VARIANT_1, test_output_v1_upx);
return TRUE;
}
# endif
# ifndef XMRIG_NO_SUMO
if (m_thread->algorithm() == CRYPTONIGHT_HEAVY) {
return verify(VARIANT_0, test_output_v0_heavy) &&