Rename cn-pico/tlo to cn-ultra/tlo and add CN_ULTRA as new algorithm.

This commit is contained in:
Mika Lindqvist 2019-12-27 15:48:03 +02:00
parent 9ae7fdb5ac
commit 286d690575
21 changed files with 502 additions and 413 deletions

View file

@ -6,6 +6,7 @@ option(WITH_HWLOC "Enable hwloc support" ON)
option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON) option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON)
option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON) option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON)
option(WITH_CN_PICO "Enable CryptoNight-Pico algorithm" ON) option(WITH_CN_PICO "Enable CryptoNight-Pico algorithm" ON)
option(WITH_CN_ULTRA "Enable CryptoNight-Ultra algorithm" ON)
option(WITH_CN_GPU "Enable CryptoNight-GPU algorithm" ON) option(WITH_CN_GPU "Enable CryptoNight-GPU algorithm" ON)
option(WITH_RANDOMX "Enable RandomX algorithms family" ON) option(WITH_RANDOMX "Enable RandomX algorithms family" ON)
option(WITH_ARGON2 "Enable Argon2 algorithms family" ON) option(WITH_ARGON2 "Enable Argon2 algorithms family" ON)
@ -192,6 +193,10 @@ if (WITH_CN_PICO)
add_definitions(/DXMRIG_ALGO_CN_PICO) add_definitions(/DXMRIG_ALGO_CN_PICO)
endif() endif()
if (WITH_CN_ULTRA)
add_definitions(/DXMRIG_ALGO_CN_ULTRA)
endif()
if (WITH_EMBEDDED_CONFIG) if (WITH_EMBEDDED_CONFIG)
add_definitions(/DXMRIG_FEATURE_EMBEDDED_CONFIG) add_definitions(/DXMRIG_FEATURE_EMBEDDED_CONFIG)
endif() endif()

View file

@ -6,6 +6,7 @@
* **`-DWITH_CN_LITE=OFF`** disable all CryptoNight-Lite algorithms (`cn-lite/0`, `cn-lite/1`). * **`-DWITH_CN_LITE=OFF`** disable all CryptoNight-Lite algorithms (`cn-lite/0`, `cn-lite/1`).
* **`-DWITH_CN_HEAVY=OFF`** disable all CryptoNight-Heavy algorithms (`cn-heavy/0`, `cn-heavy/xhv`, `cn-heavy/tube`). * **`-DWITH_CN_HEAVY=OFF`** disable all CryptoNight-Heavy algorithms (`cn-heavy/0`, `cn-heavy/xhv`, `cn-heavy/tube`).
* **`-DWITH_CN_PICO=OFF`** disable CryptoNight-Pico algorithm (`cn-pico`). * **`-DWITH_CN_PICO=OFF`** disable CryptoNight-Pico algorithm (`cn-pico`).
* **`-DWITH_CN_ULTRA=OFF`** disable CryptoNight-Ultra algorithm (`cn-ultra`).
* **`-DWITH_CN_GPU=OFF`** disable CryptoNight-GPU algorithm (`cn/gpu`). * **`-DWITH_CN_GPU=OFF`** disable CryptoNight-GPU algorithm (`cn/gpu`).
* **`-DWITH_RANDOMX=OFF`** disable RandomX algorithms (`rx/loki`, `rx/wow`). * **`-DWITH_RANDOMX=OFF`** disable RandomX algorithms (`rx/loki`, `rx/wow`).
* **`-DWITH_ARGON2=OFF`** disable Argon2 algorithms (`argon2/chukwa`, `argon2/wrkz`). * **`-DWITH_ARGON2=OFF`** disable Argon2 algorithms (`argon2/chukwa`, `argon2/wrkz`).

View file

@ -163,6 +163,7 @@ void xmrig::CpuConfig::generate()
count += xmrig::generate<Algorithm::CN_LITE>(m_threads, m_limit); count += xmrig::generate<Algorithm::CN_LITE>(m_threads, m_limit);
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, m_limit); count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, m_limit);
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, m_limit); count += xmrig::generate<Algorithm::CN_PICO>(m_threads, m_limit);
count += xmrig::generate<Algorithm::CN_ULTRA>(m_threads, m_limit);
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, m_limit); count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, m_limit);
count += xmrig::generate<Algorithm::ARGON2>(m_threads, m_limit); count += xmrig::generate<Algorithm::ARGON2>(m_threads, m_limit);

View file

@ -99,12 +99,15 @@ size_t inline generate<Algorithm::CN_HEAVY>(Threads<CpuThreads> &threads, uint32
template<> template<>
size_t inline generate<Algorithm::CN_PICO>(Threads<CpuThreads> &threads, uint32_t limit) size_t inline generate<Algorithm::CN_PICO>(Threads<CpuThreads> &threads, uint32_t limit)
{ {
size_t count = 0; return generate("cn-pico", threads, Algorithm::CN_PICO_0, limit);
}
#endif
count += generate("cn-pico", threads, Algorithm::CN_PICO_0, limit); #ifdef XMRIG_ALGO_CN_ULTRA
count += generate("cn-pico/tlo", threads, Algorithm::CN_PICO_TLO, limit); template<>
size_t inline generate<Algorithm::CN_ULTRA>(Threads<CpuThreads> &threads, uint32_t limit)
return count; {
return generate("cn-ultra", threads, Algorithm::CN_ULTRA_0, limit);
} }
#endif #endif

View file

@ -154,8 +154,13 @@ bool xmrig::CpuWorker<N>::selfTest()
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
if (m_algorithm.family() == Algorithm::CN_PICO) { if (m_algorithm.family() == Algorithm::CN_PICO) {
return verify(Algorithm::CN_PICO_0, test_output_pico_trtl) && return verify(Algorithm::CN_PICO_0, test_output_pico_trtl);
verify(Algorithm::CN_PICO_TLO, test_output_pico_tlo); }
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
if (m_algorithm.family() == Algorithm::CN_ULTRA) {
return verify(Algorithm::CN_ULTRA_0, test_output_ultra_tlo);
} }
# endif # endif
@ -252,9 +257,6 @@ void xmrig::CpuWorker<N>::start()
template<size_t N> template<size_t N>
bool xmrig::CpuWorker<N>::verify(const Algorithm &algorithm, const uint8_t *referenceValue) bool xmrig::CpuWorker<N>::verify(const Algorithm &algorithm, const uint8_t *referenceValue)
{ {
// FIXME: Disabled until 'cn-pico/tlo' test code added
return true;
cn_hash_fun func = fn(algorithm); cn_hash_fun func = fn(algorithm);
if (!func) { if (!func) {
return false; return false;
@ -268,9 +270,6 @@ bool xmrig::CpuWorker<N>::verify(const Algorithm &algorithm, const uint8_t *refe
template<size_t N> template<size_t N>
bool xmrig::CpuWorker<N>::verify2(const Algorithm &algorithm, const uint8_t *referenceValue) bool xmrig::CpuWorker<N>::verify2(const Algorithm &algorithm, const uint8_t *referenceValue)
{ {
// FIXME: Disabled until 'cn-pico/tlo' test code added
return true;
cn_hash_fun func = fn(algorithm); cn_hash_fun func = fn(algorithm);
if (!func) { if (!func) {
return false; return false;
@ -300,9 +299,6 @@ namespace xmrig {
template<> template<>
bool CpuWorker<1>::verify2(const Algorithm &algorithm, const uint8_t *referenceValue) bool CpuWorker<1>::verify2(const Algorithm &algorithm, const uint8_t *referenceValue)
{ {
// FIXME: Disabled until 'cn-pico/tlo' test code added
return true;
cn_hash_fun func = fn(algorithm); cn_hash_fun func = fn(algorithm);
if (!func) { if (!func) {
return false; return false;

View file

@ -195,7 +195,13 @@ xmrig::CpuThreads xmrig::AdvancedCpuInfo::threads(const Algorithm &algorithm, ui
uint32_t intensity = algorithm.maxIntensity() == 1 ? 0 : 1; uint32_t intensity = algorithm.maxIntensity() == 1 ? 0 : 1;
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
if ((algorithm == Algorithm::CN_PICO_0 || algorithm == Algorithm::CN_PICO_TLO) && (count / cores()) >= 2) { if (algorithm == Algorithm::CN_PICO_0 && (count / cores()) >= 2) {
intensity = 2;
}
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
if (algorithm == Algorithm::CN_ULTRA_0 && (count / cores()) >= 2) {
intensity = 2; intensity = 2;
} }
# endif # endif

View file

@ -225,6 +225,12 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3
} }
# endif # endif
# ifdef XMRIG_ALGO_CN_ULTRA
if (algorithm.family() == Algorithm::CN_ULTRA) {
return CpuThreads(count, 2);
}
# endif
# ifdef XMRIG_ALGO_CN_HEAVY # ifdef XMRIG_ALGO_CN_HEAVY
if (algorithm.family() == Algorithm::CN_HEAVY) { if (algorithm.family() == Algorithm::CN_HEAVY) {
return CpuThreads(std::max<size_t>(count / 4, 1), 1); return CpuThreads(std::max<size_t>(count / 4, 1), 1);

View file

@ -307,7 +307,13 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
size_t cacheHashes = ((L3 + extra) + (scratchpad / 2)) / scratchpad; size_t cacheHashes = ((L3 + extra) + (scratchpad / 2)) / scratchpad;
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
if ((algorithm == Algorithm::CN_PICO_0 || algorithm == Algorithm::CN_PICO_TLO) && (cacheHashes / PUs) >= 2) { if (algorithm == Algorithm::CN_PICO_0 && (cacheHashes / PUs) >= 2) {
intensity = 2;
}
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
if (algorithm == Algorithm::CN_ULTRA_0 && (cacheHashes / PUs) >= 2) {
intensity = 2; intensity = 2;
} }
# endif # endif

View file

@ -179,6 +179,7 @@ void xmrig::CudaConfig::generate()
count += xmrig::generate<Algorithm::CN_LITE>(m_threads, devices); count += xmrig::generate<Algorithm::CN_LITE>(m_threads, devices);
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, devices); count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, devices);
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, devices); count += xmrig::generate<Algorithm::CN_PICO>(m_threads, devices);
count += xmrig::generate<Algorithm::CN_ULTRA>(m_threads, devices);
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices); count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices);
generated = true; generated = true;

View file

@ -101,12 +101,15 @@ size_t inline generate<Algorithm::CN_HEAVY>(Threads<CudaThreads> &threads, const
template<> template<>
size_t inline generate<Algorithm::CN_PICO>(Threads<CudaThreads> &threads, const std::vector<CudaDevice> &devices) size_t inline generate<Algorithm::CN_PICO>(Threads<CudaThreads> &threads, const std::vector<CudaDevice> &devices)
{ {
size_t count = 0; return generate("cn-pico", threads, Algorithm::CN_PICO_0, devices);
}
#endif
count += generate("cn-pico", threads, Algorithm::CN_PICO_0, devices); #ifdef XMRIG_ALGO_CN_ULTRA
count += generate("cn-pico/tlo", threads, Algorithm::CN_PICO_TLO, devices); template<>
size_t inline generate<Algorithm::CN_ULTRA>(Threads<CudaThreads> &threads, const std::vector<CudaDevice> &devices)
return count; {
return generate("cn-ultra", threads, Algorithm::CN_ULTRA_0, devices);
} }
#endif #endif

View file

@ -193,6 +193,7 @@ void xmrig::OclConfig::generate()
count += xmrig::generate<Algorithm::CN_LITE>(m_threads, devices); count += xmrig::generate<Algorithm::CN_LITE>(m_threads, devices);
count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, devices); count += xmrig::generate<Algorithm::CN_HEAVY>(m_threads, devices);
count += xmrig::generate<Algorithm::CN_PICO>(m_threads, devices); count += xmrig::generate<Algorithm::CN_PICO>(m_threads, devices);
count += xmrig::generate<Algorithm::CN_ULTRA>(m_threads, devices);
count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices); count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices);
m_shouldSave = count > 0; m_shouldSave = count > 0;

View file

@ -100,12 +100,15 @@ size_t inline generate<Algorithm::CN_HEAVY>(Threads<OclThreads> &threads, const
template<> template<>
size_t inline generate<Algorithm::CN_PICO>(Threads<OclThreads> &threads, const std::vector<OclDevice> &devices) size_t inline generate<Algorithm::CN_PICO>(Threads<OclThreads> &threads, const std::vector<OclDevice> &devices)
{ {
size_t count = 0; return generate("cn-pico", threads, Algorithm::CN_PICO_0, devices);
}
#endif
count += generate("cn-pico", threads, Algorithm::CN_PICO_0, devices); #ifdef XMRIG_ALGO_CN_ULTRA
count += generate("cn-pico/tlo", threads, Algorithm::CN_PICO_TLO, devices); template<>
size_t inline generate<Algorithm::CN_ULTRA>(Threads<OclThreads> &threads, const std::vector<OclDevice> &devices)
return count; {
return generate("cn-ultra", threads, Algorithm::CN_ULTRA_0, devices);
} }
#endif #endif

View file

@ -16,7 +16,7 @@
#define ALGO_CN_HEAVY_TUBE 15 #define ALGO_CN_HEAVY_TUBE 15
#define ALGO_CN_HEAVY_XHV 16 #define ALGO_CN_HEAVY_XHV 16
#define ALGO_CN_PICO_0 17 #define ALGO_CN_PICO_0 17
#define ALGO_CN_PICO_TLO 18 #define ALGO_CN_ULTRA_0 18
#define ALGO_RX_0 19 #define ALGO_RX_0 19
#define ALGO_RX_WOW 20 #define ALGO_RX_WOW 20
#define ALGO_RX_LOKI 21 #define ALGO_RX_LOKI 21
@ -31,5 +31,6 @@
#define FAMILY_CN_LITE 2 #define FAMILY_CN_LITE 2
#define FAMILY_CN_HEAVY 3 #define FAMILY_CN_HEAVY 3
#define FAMILY_CN_PICO 4 #define FAMILY_CN_PICO 4
#define FAMILY_RANDOM_X 5 #define FAMILY_CN_ULTRA 5
#define FAMILY_ARGON2 6 #define FAMILY_RANDOM_X 6
#define FAMILY_ARGON2 7

View file

@ -88,7 +88,7 @@ static inline uint32_t getIntensity(const OclDevice &device, const Algorithm &al
static inline uint32_t getWorksize(const Algorithm &algorithm) static inline uint32_t getWorksize(const Algorithm &algorithm)
{ {
if (algorithm.family() == Algorithm::CN_PICO) { if (algorithm.family() == Algorithm::CN_PICO || algorithm.family() == Algorithm::CN_ULTRA) {
return 64; return 64;
} }

View file

@ -43,7 +43,7 @@ xmrig::OclCnRunner::OclCnRunner(size_t index, const OclLaunchData &data) : OclBa
if (data.device.vendorId() == OCL_VENDOR_NVIDIA) { if (data.device.vendorId() == OCL_VENDOR_NVIDIA) {
stridedIndex = 0; stridedIndex = 0;
} }
else if (stridedIndex == 1 && (m_algorithm.family() == Algorithm::CN_PICO || (m_algorithm.family() == Algorithm::CN && CnAlgo<>::base(m_algorithm) == Algorithm::CN_2))) { else if (stridedIndex == 1 && (m_algorithm.family() == Algorithm::CN_PICO || m_algorithm.family() == Algorithm::CN_ULTRA || (m_algorithm.family() == Algorithm::CN && CnAlgo<>::base(m_algorithm) == Algorithm::CN_2))) {
stridedIndex = 2; stridedIndex = 2;
} }

View file

@ -66,6 +66,9 @@ public:
case Algorithm::CN_PICO: case Algorithm::CN_PICO:
return CN_MEMORY / 8; return CN_MEMORY / 8;
case Algorithm::CN_ULTRA:
return CN_MEMORY / 8;
default: default:
break; break;
} }
@ -111,7 +114,11 @@ public:
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
case Algorithm::CN_PICO_0: case Algorithm::CN_PICO_0:
case Algorithm::CN_PICO_TLO: return CN_ITER / 8;
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
case Algorithm::CN_ULTRA_0:
return CN_ITER / 8; return CN_ITER / 8;
# endif # endif
@ -133,7 +140,11 @@ public:
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
if (algo == Algorithm::CN_PICO_0) { if (algo == Algorithm::CN_PICO_0) {
return 0x1FFF0; return 0x1FFF0;
} else if (algo == Algorithm::CN_PICO_TLO) { }
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
if (algo == Algorithm::CN_ULTRA_0) {
return 0x3FFF0; return 0x3FFF0;
} }
# endif # endif
@ -174,7 +185,9 @@ public:
case Algorithm::CN_DOUBLE: case Algorithm::CN_DOUBLE:
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
case Algorithm::CN_PICO_0: case Algorithm::CN_PICO_0:
case Algorithm::CN_PICO_TLO: # endif
# ifdef XMRIG_ALGO_CN_ULTRA
case Algorithm::CN_ULTRA_0:
# endif # endif
return Algorithm::CN_2; return Algorithm::CN_2;
@ -221,7 +234,7 @@ template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_RWZ>::iterations() con
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ZLS>::iterations() const { return 0x60000; } template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ZLS>::iterations() const { return 0x60000; }
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::iterations() const { return 0xC000; } template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::iterations() const { return 0xC000; }
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::iterations() const { return CN_ITER / 8; } template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::iterations() const { return CN_ITER / 8; }
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_TLO>::iterations() const { return CN_ITER / 8; } template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ULTRA_0>::iterations() const { return CN_ITER / 8; }
template<> constexpr inline size_t CnAlgo<Algorithm::CN_LITE_0>::memory() const { return CN_MEMORY / 2; } template<> constexpr inline size_t CnAlgo<Algorithm::CN_LITE_0>::memory() const { return CN_MEMORY / 2; }
@ -230,12 +243,12 @@ template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_0>::memory() const
template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_TUBE>::memory() const { return CN_MEMORY * 2; } template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_TUBE>::memory() const { return CN_MEMORY * 2; }
template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_XHV>::memory() const { return CN_MEMORY * 2; } template<> constexpr inline size_t CnAlgo<Algorithm::CN_HEAVY_XHV>::memory() const { return CN_MEMORY * 2; }
template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_0>::memory() const { return CN_MEMORY / 8; } template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_0>::memory() const { return CN_MEMORY / 8; }
template<> constexpr inline size_t CnAlgo<Algorithm::CN_PICO_TLO>::memory() const { return CN_MEMORY / 8; } template<> constexpr inline size_t CnAlgo<Algorithm::CN_ULTRA_0>::memory() const { return CN_MEMORY / 8; }
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::mask() const { return 0x1FFFC0; } template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::mask() const { return 0x1FFFC0; }
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::mask() const { return 0x1FFF0; } template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::mask() const { return 0x1FFF0; }
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_TLO>::mask() const { return 0x3FFF0; } template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ULTRA_0>::mask() const { return 0x3FFF0; }
} /* namespace xmrig */ } /* namespace xmrig */

View file

@ -79,6 +79,11 @@ cn_mainloop_fun cn_trtl_mainloop_ryzen_asm = nullptr;
cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm = nullptr; cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm = nullptr;
cn_mainloop_fun cn_trtl_double_mainloop_sandybridge_asm = nullptr; cn_mainloop_fun cn_trtl_double_mainloop_sandybridge_asm = nullptr;
cn_mainloop_fun cn_tlo_mainloop_ivybridge_asm = nullptr;
cn_mainloop_fun cn_tlo_mainloop_ryzen_asm = nullptr;
cn_mainloop_fun cn_tlo_mainloop_bulldozer_asm = nullptr;
cn_mainloop_fun cn_tlo_double_mainloop_sandybridge_asm = nullptr;
cn_mainloop_fun cn_zls_mainloop_ivybridge_asm = nullptr; cn_mainloop_fun cn_zls_mainloop_ivybridge_asm = nullptr;
cn_mainloop_fun cn_zls_mainloop_ryzen_asm = nullptr; cn_mainloop_fun cn_zls_mainloop_ryzen_asm = nullptr;
cn_mainloop_fun cn_zls_mainloop_bulldozer_asm = nullptr; cn_mainloop_fun cn_zls_mainloop_bulldozer_asm = nullptr;
@ -128,30 +133,37 @@ static void patchCode(T dst, U src, const uint32_t iterations, const uint32_t ma
static void patchAsmVariants() static void patchAsmVariants()
{ {
const int allocation_size = 65536; const int allocation_size = 81920;
auto base = static_cast<uint8_t *>(VirtualMemory::allocateExecutableMemory(allocation_size)); auto base = static_cast<uint8_t *>(VirtualMemory::allocateExecutableMemory(allocation_size));
cn_half_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0000); cn_half_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x00000);
cn_half_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x1000); cn_half_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x01000);
cn_half_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x2000); cn_half_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x02000);
cn_half_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x3000); cn_half_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x03000);
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
cn_trtl_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x4000); cn_trtl_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x04000);
cn_trtl_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x5000); cn_trtl_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x05000);
cn_trtl_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x6000); cn_trtl_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x06000);
cn_trtl_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x7000); cn_trtl_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x07000);
# endif # endif
cn_zls_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x8000); # ifdef XMRIG_ALGO_CN_ULTRA
cn_zls_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x9000); cn_tlo_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x08000);
cn_zls_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xA000); cn_tlo_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x09000);
cn_zls_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xB000); cn_tlo_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0A000);
cn_tlo_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0B000);
# endif
cn_double_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xC000); cn_zls_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0C000);
cn_double_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xD000); cn_zls_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0D000);
cn_double_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xE000); cn_zls_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0E000);
cn_double_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0xF000); cn_zls_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x0F000);
cn_double_mainloop_ivybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x10000);
cn_double_mainloop_ryzen_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x11000);
cn_double_mainloop_bulldozer_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x12000);
cn_double_double_mainloop_sandybridge_asm = reinterpret_cast<cn_mainloop_fun> (base + 0x13000);
{ {
constexpr uint32_t ITER = CnAlgo<Algorithm::CN_HALF>().iterations(); constexpr uint32_t ITER = CnAlgo<Algorithm::CN_HALF>().iterations();
@ -172,15 +184,17 @@ static void patchAsmVariants()
patchCode(cn_trtl_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, ITER, MASK); patchCode(cn_trtl_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, ITER, MASK);
patchCode(cn_trtl_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER, MASK); patchCode(cn_trtl_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER, MASK);
} }
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
{ {
constexpr uint32_t ITER = CnAlgo<Algorithm::CN_PICO_TLO>().iterations(); constexpr uint32_t ITER = CnAlgo<Algorithm::CN_ULTRA_0>().iterations();
constexpr uint32_t MASK = CnAlgo<Algorithm::CN_PICO_TLO>().mask(); constexpr uint32_t MASK = CnAlgo<Algorithm::CN_ULTRA_0>().mask();
patchCode(cn_trtl_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, ITER, MASK); patchCode(cn_tlo_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, ITER, MASK);
patchCode(cn_trtl_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, ITER, MASK); patchCode(cn_tlo_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, ITER, MASK);
patchCode(cn_trtl_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, ITER, MASK); patchCode(cn_tlo_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, ITER, MASK);
patchCode(cn_trtl_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER, MASK); patchCode(cn_tlo_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, ITER, MASK);
} }
# endif # endif
@ -254,8 +268,11 @@ xmrig::CnHash::CnHash()
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
ADD_FN(Algorithm::CN_PICO_0); ADD_FN(Algorithm::CN_PICO_0);
ADD_FN_ASM(Algorithm::CN_PICO_0); ADD_FN_ASM(Algorithm::CN_PICO_0);
ADD_FN(Algorithm::CN_PICO_TLO); # endif
ADD_FN_ASM(Algorithm::CN_PICO_TLO);
# ifdef XMRIG_ALGO_CN_ULTRA
ADD_FN(Algorithm::CN_ULTRA_0);
ADD_FN_ASM(Algorithm::CN_ULTRA_0);
# endif # endif
# ifdef XMRIG_ALGO_ARGON2 # ifdef XMRIG_ALGO_ARGON2

View file

@ -338,21 +338,20 @@ const static uint8_t test_output_pico_trtl[160] = {
0xA1, 0xE7, 0x53, 0x85, 0xFB, 0x72, 0xDD, 0x75, 0x90, 0x39, 0xB2, 0x3D, 0xC3, 0x08, 0x2C, 0xD5, 0xA1, 0xE7, 0x53, 0x85, 0xFB, 0x72, 0xDD, 0x75, 0x90, 0x39, 0xB2, 0x3D, 0xC3, 0x08, 0x2C, 0xD5,
0x01, 0x08, 0x27, 0x75, 0x86, 0xB9, 0xBB, 0x9B, 0xDF, 0xEA, 0x49, 0xDE, 0x46, 0xCB, 0x83, 0x45 0x01, 0x08, 0x27, 0x75, 0x86, 0xB9, 0xBB, 0x9B, 0xDF, 0xEA, 0x49, 0xDE, 0x46, 0xCB, 0x83, 0x45
}; };
#endif
#ifdef XMRIG_ALGO_CN_ULTRA
// FIXME: Needs working test code const static uint8_t test_output_ultra_tlo[160] = {
// "cn-pico/tlo" 0x99, 0x75, 0xF2, 0xC1, 0xB3, 0xB4, 0x54, 0x34, 0xA4, 0x93, 0x86, 0x21, 0x30, 0x97, 0xF3, 0x1B,
const static uint8_t test_output_pico_tlo[160] = { 0xB4, 0xB9, 0xA6, 0x58, 0x6A, 0x7E, 0x81, 0xF4, 0x42, 0x9F, 0x6D, 0x5F, 0x65, 0xC3, 0x8D, 0x1A,
0x08, 0xF4, 0x21, 0xD7, 0x83, 0x31, 0x17, 0x30, 0x0E, 0xDA, 0x66, 0xE9, 0x8F, 0x4A, 0x25, 0x69, 0xFC, 0x67, 0xDF, 0xCC, 0xB5, 0xFC, 0x90, 0xD7, 0x85, 0x5A, 0xE9, 0x03, 0x36, 0x1E, 0xAB, 0xD7,
0x09, 0x3D, 0xF3, 0x00, 0x50, 0x01, 0x73, 0x94, 0x4E, 0xFC, 0x40, 0x1E, 0x9A, 0x4A, 0x17, 0xAF, 0x6F, 0x1E, 0x40, 0xA2, 0x2A, 0x72, 0xAD, 0x3E, 0xF2, 0xD6, 0xAD, 0x27, 0xB5, 0xA6, 0x0C, 0xE5,
0xB2, 0x17, 0x2E, 0xC9, 0x46, 0x6E, 0x1A, 0xEE, 0x70, 0xEC, 0x85, 0x72, 0xA1, 0x4C, 0x23, 0x3E, 0x1C, 0xB1, 0x53, 0xE9, 0x70, 0x7D, 0x69, 0xF1, 0xE1, 0x55, 0x28, 0x45, 0xF5, 0x76, 0x56, 0xE5,
0xE3, 0x54, 0x58, 0x2B, 0xCB, 0x93, 0xF8, 0x69, 0xD4, 0x29, 0x74, 0x4D, 0xE5, 0x72, 0x6A, 0x26, 0x10, 0x0D, 0xEA, 0xFD, 0xD9, 0xD6, 0xAF, 0x0F, 0x47, 0x0C, 0x0D, 0xA2, 0x10, 0x16, 0x43, 0xEE,
0x4E, 0xFD, 0x28, 0xFC, 0xD3, 0x74, 0x8A, 0x83, 0xF3, 0xCA, 0x92, 0x84, 0xE7, 0x4E, 0x10, 0xC2, 0x25, 0x2C, 0x07, 0x3A, 0x64, 0x29, 0x16, 0xFF, 0xF5, 0xA5, 0x0B, 0xA2, 0xE0, 0xBD, 0xDC, 0xCE,
0x05, 0x62, 0xC7, 0xBE, 0x99, 0x73, 0xED, 0x90, 0xB5, 0x6F, 0xDA, 0x64, 0x71, 0x2D, 0x99, 0x39, 0x93, 0x3F, 0xEF, 0x6B, 0x08, 0xF4, 0x4D, 0x6A, 0x6E, 0x14, 0x13, 0x10, 0x98, 0x11, 0xE1, 0x13,
0x29, 0xDB, 0x22, 0x2B, 0x97, 0xB6, 0x37, 0x0E, 0x9A, 0x03, 0x65, 0xCC, 0xF7, 0xD0, 0x9A, 0xB7, 0xF6, 0x9D, 0x3D, 0x31, 0xC4, 0x3A, 0xA9, 0x44, 0x4C, 0x38, 0xAB, 0xB5, 0x4B, 0xD9, 0xFB, 0xE6,
0x68, 0xCE, 0x07, 0x3E, 0x15, 0x40, 0x3C, 0xCE, 0x8C, 0x63, 0x16, 0x72, 0xB5, 0x74, 0x84, 0xF4, 0x98, 0xB9, 0x46, 0xE2, 0x00, 0xEB, 0x56, 0x33, 0x1E, 0xBC, 0xEB, 0xF1, 0xF6, 0x88, 0xD3, 0xF0
0xA1, 0xE7, 0x53, 0x85, 0xFB, 0x72, 0xDD, 0x75, 0x90, 0x39, 0xB2, 0x3D, 0xC3, 0x08, 0x2C, 0xD5,
0x01, 0x08, 0x27, 0x75, 0x86, 0xB9, 0xBB, 0x9B, 0xDF, 0xEA, 0x49, 0xDE, 0x46, 0xCB, 0x83, 0x45
}; };
#endif #endif

View file

@ -868,7 +868,7 @@ 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 || ALGO == Algorithm::CN_PICO_TLO) { else if (ALGO == Algorithm::CN_PICO_0) {
if (ASM == Assembly::INTEL) { if (ASM == Assembly::INTEL) {
cn_trtl_mainloop_ivybridge_asm(ctx); cn_trtl_mainloop_ivybridge_asm(ctx);
} }
@ -879,6 +879,19 @@ inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_
cn_trtl_mainloop_bulldozer_asm(ctx); cn_trtl_mainloop_bulldozer_asm(ctx);
} }
} }
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
else if (ALGO == Algorithm::CN_ULTRA_0) {
if (ASM == Assembly::INTEL) {
cn_tlo_mainloop_ivybridge_asm(ctx);
}
else if (ASM == Assembly::RYZEN) {
cn_tlo_mainloop_ryzen_asm(ctx);
}
else {
cn_tlo_mainloop_bulldozer_asm(ctx);
}
}
# endif # endif
else if (ALGO == Algorithm::CN_RWZ) { else if (ALGO == Algorithm::CN_RWZ) {
cnv2_rwz_mainloop_asm(ctx); cnv2_rwz_mainloop_asm(ctx);
@ -941,9 +954,14 @@ inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_
cn_half_double_mainloop_sandybridge_asm(ctx); cn_half_double_mainloop_sandybridge_asm(ctx);
} }
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
else if (ALGO == Algorithm::CN_PICO_0 || ALGO == Algorithm::CN_PICO_TLO) { else if (ALGO == Algorithm::CN_PICO_0) {
cn_trtl_double_mainloop_sandybridge_asm(ctx); cn_trtl_double_mainloop_sandybridge_asm(ctx);
} }
# endif
# ifdef XMRIG_ALGO_CN_ULTRA
else if (ALGO == Algorithm::CN_ULTRA_0) {
cn_tlo_double_mainloop_sandybridge_asm(ctx);
}
# endif # endif
else if (ALGO == Algorithm::CN_RWZ) { else if (ALGO == Algorithm::CN_RWZ) {
cnv2_rwz_double_mainloop_asm(ctx); cnv2_rwz_double_mainloop_asm(ctx);

View file

@ -1,331 +1,339 @@
/* XMRig /* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com> * Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org> * Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones> * Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* 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 Lee Clagett <https://github.com/vtnerd> * Copyright 2018 Lee Clagett <https://github.com/vtnerd>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh> * Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com> * 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
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "crypto/common/Algorithm.h" #include "crypto/common/Algorithm.h"
#include "crypto/cn/CnAlgo.h" #include "crypto/cn/CnAlgo.h"
#include "rapidjson/document.h" #include "rapidjson/document.h"
#include <cassert> #include <cassert>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#ifdef _MSC_VER #ifdef _MSC_VER
# define strcasecmp _stricmp # define strcasecmp _stricmp
#endif #endif
namespace xmrig { namespace xmrig {
struct AlgoName struct AlgoName
{ {
const char *name; const char *name;
const char *shortName; const char *shortName;
const Algorithm::Id id; const Algorithm::Id id;
}; };
static AlgoName const algorithm_names[] = { static AlgoName const algorithm_names[] = {
{ "cryptonight/0", "cn/0", Algorithm::CN_0 }, { "cryptonight/0", "cn/0", Algorithm::CN_0 },
{ "cryptonight", "cn", Algorithm::CN_0 }, { "cryptonight", "cn", Algorithm::CN_0 },
{ "cryptonight/1", "cn/1", Algorithm::CN_1 }, { "cryptonight/1", "cn/1", Algorithm::CN_1 },
{ "cryptonight-monerov7", nullptr, Algorithm::CN_1 }, { "cryptonight-monerov7", nullptr, Algorithm::CN_1 },
{ "cryptonight_v7", nullptr, Algorithm::CN_1 }, { "cryptonight_v7", nullptr, Algorithm::CN_1 },
{ "cryptonight/2", "cn/2", Algorithm::CN_2 }, { "cryptonight/2", "cn/2", Algorithm::CN_2 },
{ "cryptonight-monerov8", nullptr, Algorithm::CN_2 }, { "cryptonight-monerov8", nullptr, Algorithm::CN_2 },
{ "cryptonight_v8", nullptr, Algorithm::CN_2 }, { "cryptonight_v8", nullptr, Algorithm::CN_2 },
{ "cryptonight/r", "cn/r", Algorithm::CN_R }, { "cryptonight/r", "cn/r", Algorithm::CN_R },
{ "cryptonight_r", nullptr, Algorithm::CN_R }, { "cryptonight_r", nullptr, Algorithm::CN_R },
{ "cryptonight/fast", "cn/fast", Algorithm::CN_FAST }, { "cryptonight/fast", "cn/fast", Algorithm::CN_FAST },
{ "cryptonight/msr", "cn/msr", Algorithm::CN_FAST }, { "cryptonight/msr", "cn/msr", Algorithm::CN_FAST },
{ "cryptonight/half", "cn/half", Algorithm::CN_HALF }, { "cryptonight/half", "cn/half", Algorithm::CN_HALF },
{ "cryptonight/xao", "cn/xao", Algorithm::CN_XAO }, { "cryptonight/xao", "cn/xao", Algorithm::CN_XAO },
{ "cryptonight_alloy", nullptr, Algorithm::CN_XAO }, { "cryptonight_alloy", nullptr, Algorithm::CN_XAO },
{ "cryptonight/rto", "cn/rto", Algorithm::CN_RTO }, { "cryptonight/rto", "cn/rto", Algorithm::CN_RTO },
{ "cryptonight/rwz", "cn/rwz", Algorithm::CN_RWZ }, { "cryptonight/rwz", "cn/rwz", Algorithm::CN_RWZ },
{ "cryptonight/zls", "cn/zls", Algorithm::CN_ZLS }, { "cryptonight/zls", "cn/zls", Algorithm::CN_ZLS },
{ "cryptonight/double", "cn/double", Algorithm::CN_DOUBLE }, { "cryptonight/double", "cn/double", Algorithm::CN_DOUBLE },
# ifdef XMRIG_ALGO_CN_GPU # ifdef XMRIG_ALGO_CN_GPU
{ "cryptonight/gpu", "cn/gpu", Algorithm::CN_GPU }, { "cryptonight/gpu", "cn/gpu", Algorithm::CN_GPU },
{ "cryptonight_gpu", nullptr, Algorithm::CN_GPU }, { "cryptonight_gpu", nullptr, Algorithm::CN_GPU },
# endif # endif
# ifdef XMRIG_ALGO_CN_LITE # ifdef XMRIG_ALGO_CN_LITE
{ "cryptonight-lite/0", "cn-lite/0", Algorithm::CN_LITE_0 }, { "cryptonight-lite/0", "cn-lite/0", Algorithm::CN_LITE_0 },
{ "cryptonight-lite/1", "cn-lite/1", Algorithm::CN_LITE_1 }, { "cryptonight-lite/1", "cn-lite/1", Algorithm::CN_LITE_1 },
{ "cryptonight-lite", "cn-lite", Algorithm::CN_LITE_1 }, { "cryptonight-lite", "cn-lite", Algorithm::CN_LITE_1 },
{ "cryptonight-light", "cn-light", Algorithm::CN_LITE_1 }, { "cryptonight-light", "cn-light", Algorithm::CN_LITE_1 },
{ "cryptonight_lite", nullptr, Algorithm::CN_LITE_1 }, { "cryptonight_lite", nullptr, Algorithm::CN_LITE_1 },
{ "cryptonight-aeonv7", nullptr, Algorithm::CN_LITE_1 }, { "cryptonight-aeonv7", nullptr, Algorithm::CN_LITE_1 },
{ "cryptonight_lite_v7", nullptr, Algorithm::CN_LITE_1 }, { "cryptonight_lite_v7", nullptr, Algorithm::CN_LITE_1 },
# endif # endif
# ifdef XMRIG_ALGO_CN_HEAVY # ifdef XMRIG_ALGO_CN_HEAVY
{ "cryptonight-heavy/0", "cn-heavy/0", Algorithm::CN_HEAVY_0 }, { "cryptonight-heavy/0", "cn-heavy/0", Algorithm::CN_HEAVY_0 },
{ "cryptonight-heavy", "cn-heavy", Algorithm::CN_HEAVY_0 }, { "cryptonight-heavy", "cn-heavy", Algorithm::CN_HEAVY_0 },
{ "cryptonight_heavy", nullptr, Algorithm::CN_HEAVY_0 }, { "cryptonight_heavy", nullptr, Algorithm::CN_HEAVY_0 },
{ "cryptonight-heavy/xhv", "cn-heavy/xhv", Algorithm::CN_HEAVY_XHV }, { "cryptonight-heavy/xhv", "cn-heavy/xhv", Algorithm::CN_HEAVY_XHV },
{ "cryptonight_haven", nullptr, Algorithm::CN_HEAVY_XHV }, { "cryptonight_haven", nullptr, Algorithm::CN_HEAVY_XHV },
{ "cryptonight-heavy/tube", "cn-heavy/tube", Algorithm::CN_HEAVY_TUBE }, { "cryptonight-heavy/tube", "cn-heavy/tube", Algorithm::CN_HEAVY_TUBE },
{ "cryptonight-bittube2", nullptr, Algorithm::CN_HEAVY_TUBE }, { "cryptonight-bittube2", nullptr, Algorithm::CN_HEAVY_TUBE },
# endif # endif
# ifdef XMRIG_ALGO_CN_PICO # ifdef XMRIG_ALGO_CN_PICO
{ "cryptonight-pico", "cn-pico", Algorithm::CN_PICO_0 }, { "cryptonight-pico", "cn-pico", Algorithm::CN_PICO_0 },
{ "cryptonight-pico/trtl", "cn-pico/trtl", Algorithm::CN_PICO_0 }, { "cryptonight-pico/trtl", "cn-pico/trtl", Algorithm::CN_PICO_0 },
{ "cryptonight-turtle", "cn-trtl", Algorithm::CN_PICO_0 }, { "cryptonight-turtle", "cn-trtl", Algorithm::CN_PICO_0 },
{ "cryptonight-ultralite", "cn-ultralite", Algorithm::CN_PICO_0 }, { "cryptonight-ultralite", "cn-ultralite", Algorithm::CN_PICO_0 },
{ "cryptonight_turtle", "cn_turtle", Algorithm::CN_PICO_0 }, { "cryptonight_turtle", "cn_turtle", Algorithm::CN_PICO_0 },
{ "cryptonight-pico/tlo", "cn-pico/tlo", Algorithm::CN_PICO_TLO }, # endif
{ "cryptonight-talleo", "cn-talleo", Algorithm::CN_PICO_TLO }, # ifdef XMRIG_ALGO_CN_ULTRA
{ "cryptonight_talleo", "cn_talleo", Algorithm::CN_PICO_TLO }, { "cryptonight-ultra", "cn-ultra", Algorithm::CN_ULTRA_0 },
# endif { "cryptonight-ultra/tlo", "cn-ultra/tlo", Algorithm::CN_ULTRA_0 },
# ifdef XMRIG_ALGO_RANDOMX { "cryptonight-talleo", "cn-talleo", Algorithm::CN_ULTRA_0 },
{ "randomx/0", "rx/0", Algorithm::RX_0 }, { "cryptonight_talleo", "cn_talleo", Algorithm::CN_ULTRA_0 },
{ "randomx/test", "rx/test", Algorithm::RX_0 }, { "cryptonight/ultra", "cn/ultra", Algorithm::CN_ULTRA_0 },
{ "RandomX", "rx", Algorithm::RX_0 }, # endif
{ "randomx/wow", "rx/wow", Algorithm::RX_WOW }, # ifdef XMRIG_ALGO_RANDOMX
{ "RandomWOW", nullptr, Algorithm::RX_WOW }, { "randomx/0", "rx/0", Algorithm::RX_0 },
{ "randomx/loki", "rx/loki", Algorithm::RX_LOKI }, { "randomx/test", "rx/test", Algorithm::RX_0 },
{ "RandomXL", nullptr, Algorithm::RX_LOKI }, { "RandomX", "rx", Algorithm::RX_0 },
{ "randomx/arq", "rx/arq", Algorithm::RX_ARQ }, { "randomx/wow", "rx/wow", Algorithm::RX_WOW },
{ "RandomARQ", nullptr, Algorithm::RX_ARQ }, { "RandomWOW", nullptr, Algorithm::RX_WOW },
{ "randomx/sfx", "rx/sfx", Algorithm::RX_SFX }, { "randomx/loki", "rx/loki", Algorithm::RX_LOKI },
{ "RandomSFX", nullptr, Algorithm::RX_SFX }, { "RandomXL", nullptr, Algorithm::RX_LOKI },
{ "randomx/v", "rx/v", Algorithm::RX_V }, { "randomx/arq", "rx/arq", Algorithm::RX_ARQ },
{ "RandomV", nullptr, Algorithm::RX_V }, { "RandomARQ", nullptr, Algorithm::RX_ARQ },
# endif { "randomx/sfx", "rx/sfx", Algorithm::RX_SFX },
# ifdef XMRIG_ALGO_ARGON2 { "RandomSFX", nullptr, Algorithm::RX_SFX },
{ "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA }, { "randomx/v", "rx/v", Algorithm::RX_V },
{ "chukwa", nullptr, Algorithm::AR2_CHUKWA }, { "RandomV", nullptr, Algorithm::RX_V },
{ "argon2/wrkz", nullptr, Algorithm::AR2_WRKZ }, # endif
# endif # ifdef XMRIG_ALGO_ARGON2
}; { "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA },
{ "chukwa", nullptr, Algorithm::AR2_CHUKWA },
{ "argon2/wrkz", nullptr, Algorithm::AR2_WRKZ },
} /* namespace xmrig */ # endif
};
rapidjson::Value xmrig::Algorithm::toJSON() const
{ } /* namespace xmrig */
using namespace rapidjson;
return isValid() ? Value(StringRef(shortName())) : Value(kNullType); rapidjson::Value xmrig::Algorithm::toJSON() const
} {
using namespace rapidjson;
size_t xmrig::Algorithm::l2() const return isValid() ? Value(StringRef(shortName())) : Value(kNullType);
{ }
# ifdef XMRIG_ALGO_RANDOMX
switch (m_id) {
case RX_0: size_t xmrig::Algorithm::l2() const
case RX_LOKI: {
case RX_SFX: # ifdef XMRIG_ALGO_RANDOMX
case RX_V: switch (m_id) {
return 0x40000; case RX_0:
case RX_LOKI:
case RX_WOW: case RX_SFX:
return 0x20000; case RX_V:
return 0x40000;
case RX_ARQ:
return 0x10000; case RX_WOW:
return 0x20000;
default:
break; case RX_ARQ:
} return 0x10000;
# endif
default:
return 0; break;
} }
# endif
size_t xmrig::Algorithm::l3() const return 0;
{ }
# if defined(XMRIG_ALGO_RANDOMX) || defined(XMRIG_ALGO_ARGON2)
constexpr size_t oneMiB = 0x100000;
# endif size_t xmrig::Algorithm::l3() const
{
const Family f = family(); # if defined(XMRIG_ALGO_RANDOMX) || defined(XMRIG_ALGO_ARGON2)
assert(f != UNKNOWN); constexpr size_t oneMiB = 0x100000;
# endif
if (f < RANDOM_X) {
return CnAlgo<>::memory(m_id); const Family f = family();
} assert(f != UNKNOWN);
# ifdef XMRIG_ALGO_RANDOMX if (f < RANDOM_X) {
if (f == RANDOM_X) { return CnAlgo<>::memory(m_id);
switch (m_id) { }
case RX_0:
case RX_LOKI: # ifdef XMRIG_ALGO_RANDOMX
case RX_SFX: if (f == RANDOM_X) {
case RX_V: switch (m_id) {
return oneMiB * 2; case RX_0:
case RX_LOKI:
case RX_WOW: case RX_SFX:
return oneMiB; case RX_V:
return oneMiB * 2;
case RX_ARQ:
return oneMiB / 4; case RX_WOW:
return oneMiB;
default:
break; case RX_ARQ:
} return oneMiB / 4;
}
# endif default:
break;
# ifdef XMRIG_ALGO_ARGON2 }
if (f == ARGON2) { }
switch (m_id) { # endif
case AR2_CHUKWA:
return oneMiB / 2; # ifdef XMRIG_ALGO_ARGON2
if (f == ARGON2) {
case AR2_WRKZ: switch (m_id) {
return oneMiB / 4; case AR2_CHUKWA:
return oneMiB / 2;
default:
break; case AR2_WRKZ:
} return oneMiB / 4;
}
# endif default:
break;
return 0; }
} }
# endif
uint32_t xmrig::Algorithm::maxIntensity() const return 0;
{ }
# ifdef XMRIG_ALGO_RANDOMX
if (family() == RANDOM_X) {
return 1; uint32_t xmrig::Algorithm::maxIntensity() const
} {
# endif # ifdef XMRIG_ALGO_RANDOMX
if (family() == RANDOM_X) {
# ifdef XMRIG_ALGO_ARGON2 return 1;
if (family() == ARGON2) { }
return 1; # endif
}
# endif # ifdef XMRIG_ALGO_ARGON2
if (family() == ARGON2) {
# ifdef XMRIG_ALGO_CN_GPU return 1;
if (m_id == CN_GPU) { }
return 1; # endif
}
# endif # ifdef XMRIG_ALGO_CN_GPU
if (m_id == CN_GPU) {
return 5; return 1;
} }
# endif
xmrig::Algorithm::Family xmrig::Algorithm::family(Id id) return 5;
{ }
switch (id) {
case CN_0:
case CN_1: xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
case CN_2: {
case CN_R: switch (id) {
case CN_FAST: case CN_0:
case CN_HALF: case CN_1:
case CN_XAO: case CN_2:
case CN_RTO: case CN_R:
case CN_RWZ: case CN_FAST:
case CN_ZLS: case CN_HALF:
case CN_DOUBLE: case CN_XAO:
# ifdef XMRIG_ALGO_CN_GPU case CN_RTO:
case CN_GPU: case CN_RWZ:
# endif case CN_ZLS:
return CN; case CN_DOUBLE:
# ifdef XMRIG_ALGO_CN_GPU
# ifdef XMRIG_ALGO_CN_LITE case CN_GPU:
case CN_LITE_0: # endif
case CN_LITE_1: return CN;
return CN_LITE;
# endif # ifdef XMRIG_ALGO_CN_LITE
case CN_LITE_0:
# ifdef XMRIG_ALGO_CN_HEAVY case CN_LITE_1:
case CN_HEAVY_0: return CN_LITE;
case CN_HEAVY_TUBE: # endif
case CN_HEAVY_XHV:
return CN_HEAVY; # ifdef XMRIG_ALGO_CN_HEAVY
# endif case CN_HEAVY_0:
case CN_HEAVY_TUBE:
# ifdef XMRIG_ALGO_CN_PICO case CN_HEAVY_XHV:
case CN_PICO_0: return CN_HEAVY;
case CN_PICO_TLO: # endif
return CN_PICO;
# endif # ifdef XMRIG_ALGO_CN_PICO
case CN_PICO_0:
# ifdef XMRIG_ALGO_RANDOMX return CN_PICO;
case RX_0: # endif
case RX_WOW:
case RX_LOKI: # ifdef XMRIG_ALGO_CN_ULTRA
case RX_ARQ: case CN_ULTRA_0:
case RX_SFX: return CN_ULTRA;
case RX_V: # endif
return RANDOM_X;
# endif # ifdef XMRIG_ALGO_RANDOMX
case RX_0:
# ifdef XMRIG_ALGO_ARGON2 case RX_WOW:
case AR2_CHUKWA: case RX_LOKI:
case AR2_WRKZ: case RX_ARQ:
return ARGON2; case RX_SFX:
# endif case RX_V:
return RANDOM_X;
default: # endif
break;
} # ifdef XMRIG_ALGO_ARGON2
case AR2_CHUKWA:
return UNKNOWN; case AR2_WRKZ:
} return ARGON2;
# endif
xmrig::Algorithm::Id xmrig::Algorithm::parse(const char *name) default:
{ break;
if (name == nullptr || strlen(name) < 1) { }
return INVALID;
} return UNKNOWN;
}
for (const AlgoName &item : algorithm_names) {
if ((strcasecmp(name, item.name) == 0) || (item.shortName != nullptr && strcasecmp(name, item.shortName) == 0)) {
return item.id; xmrig::Algorithm::Id xmrig::Algorithm::parse(const char *name)
} {
} if (name == nullptr || strlen(name) < 1) {
return INVALID;
return INVALID; }
}
for (const AlgoName &item : algorithm_names) {
if ((strcasecmp(name, item.name) == 0) || (item.shortName != nullptr && strcasecmp(name, item.shortName) == 0)) {
const char *xmrig::Algorithm::name(bool shortName) const return item.id;
{ }
for (const AlgoName &item : algorithm_names) { }
if (item.id == m_id) {
return (shortName && item.shortName) ? item.shortName : item.name; return INVALID;
} }
}
return "invalid"; const char *xmrig::Algorithm::name(bool shortName) const
} {
for (const AlgoName &item : algorithm_names) {
if (item.id == m_id) {
return (shortName && item.shortName) ? item.shortName : item.name;
}
}
return "invalid";
}

View file

@ -63,7 +63,7 @@ public:
CN_HEAVY_TUBE, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only). CN_HEAVY_TUBE, // "cn-heavy/tube" CryptoNight-Heavy (modified, TUBE only).
CN_HEAVY_XHV, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only). CN_HEAVY_XHV, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only).
CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL) CN_PICO_0, // "cn-pico" CryptoNight Turtle (TRTL)
CN_PICO_TLO, // "cn-pico/tlo" CryptoNight Talleo (TLO) CN_ULTRA_0, // "cn-ultra" CryptoNight Talleo (TLO)
RX_0, // "rx/0" RandomX (reference configuration). RX_0, // "rx/0" RandomX (reference configuration).
RX_WOW, // "rx/wow" RandomWOW (Wownero). RX_WOW, // "rx/wow" RandomWOW (Wownero).
RX_LOKI, // "rx/loki" RandomXL (Loki). RX_LOKI, // "rx/loki" RandomXL (Loki).
@ -81,6 +81,7 @@ public:
CN_LITE, CN_LITE,
CN_HEAVY, CN_HEAVY,
CN_PICO, CN_PICO,
CN_ULTRA,
RANDOM_X, RANDOM_X,
ARGON2 ARGON2
}; };
@ -89,7 +90,7 @@ public:
inline Algorithm(const char *algo) : m_id(parse(algo)) {} inline Algorithm(const char *algo) : m_id(parse(algo)) {}
inline Algorithm(Id id) : m_id(id) {} inline Algorithm(Id id) : m_id(id) {}
inline bool isCN() const { auto f = family(); return f == CN || f == CN_LITE || f == CN_HEAVY || f == CN_PICO; } inline bool isCN() const { auto f = family(); return f == CN || f == CN_LITE || f == CN_HEAVY || f == CN_PICO || f == CN_ULTRA; }
inline bool isEqual(const Algorithm &other) const { return m_id == other.m_id; } inline bool isEqual(const Algorithm &other) const { return m_id == other.m_id; }
inline bool isValid() const { return m_id != INVALID; } inline bool isValid() const { return m_id != INVALID; }
inline const char *name() const { return name(false); } inline const char *name() const { return name(false); }