diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b046796..a1b58eeb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,8 @@ option(WITH_HWLOC "Enable hwloc support" ON) option(WITH_CN_LITE "Enable CryptoNight-Lite 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_GPU "Enable CryptoNight-GPU algorithm" ON) option(WITH_CN_FEMTO "Enable CryptoNight-UPX2 algorithm" ON) +option(WITH_CN_GPU "Enable CryptoNight-GPU algorithm" ON) option(WITH_RANDOMX "Enable RandomX algorithms family" ON) option(WITH_ARGON2 "Enable Argon2 algorithms family" ON) option(WITH_ASTROBWT "Enable AstroBWT algorithms family" ON) @@ -206,6 +206,7 @@ add_definitions(-D__STDC_FORMAT_MACROS -DUNICODE -D_FILE_OFFSET_BITS=64) find_package(UV REQUIRED) include(cmake/flags.cmake) +include(cmake/cn-gpu.cmake) include(cmake/randomx.cmake) include(cmake/argon2.cmake) include(cmake/astrobwt.cmake) @@ -213,7 +214,6 @@ include(cmake/kawpow.cmake) include(cmake/ghostrider.cmake) include(cmake/OpenSSL.cmake) include(cmake/asm.cmake) -include(cmake/cn-gpu.cmake) if (WITH_CN_LITE) add_definitions(/DXMRIG_ALGO_CN_LITE) diff --git a/src/backend/cpu/CpuConfig_gen.h b/src/backend/cpu/CpuConfig_gen.h index f8ef39dd..89d91187 100644 --- a/src/backend/cpu/CpuConfig_gen.h +++ b/src/backend/cpu/CpuConfig_gen.h @@ -48,16 +48,16 @@ size_t inline generate(Threads &threads, uint32_t lim size_t count = 0; count += generate(Algorithm::kCN, threads, Algorithm::CN_1, limit); + count += generate(Algorithm::kCN_2, threads, Algorithm::CN_2, limit); +# ifdef XMRIG_ALGO_CN_GPU + count += generate(Algorithm::kCN_GPU, threads, Algorithm::CN_GPU, limit); +# endif if (!threads.isExist(Algorithm::CN_0)) { threads.disable(Algorithm::CN_0); ++count; } -# ifdef XMRIG_ALGO_CN_GPU - count += generate(Algorithm::kCN_GPU, threads, Algorithm::CN_GPU, limit); -# endif - return count; } diff --git a/src/backend/cpu/CpuWorker.cpp b/src/backend/cpu/CpuWorker.cpp index f896d2d8..232940f5 100644 --- a/src/backend/cpu/CpuWorker.cpp +++ b/src/backend/cpu/CpuWorker.cpp @@ -181,20 +181,19 @@ bool xmrig::CpuWorker::selfTest() verify(Algorithm::CN_RWZ, test_output_rwz) && verify(Algorithm::CN_ZLS, test_output_zls) && verify(Algorithm::CN_CCX, test_output_ccx) && + verify(Algorithm::CN_DOUBLE, test_output_double) # ifdef XMRIG_ALGO_CN_GPU - verify(Algorithm::CN_GPU, test_output_gpu) && + && + verify(Algorithm::CN_GPU, test_output_gpu) # endif - verify(Algorithm::CN_DOUBLE, test_output_double); + ; # ifdef XMRIG_ALGO_CN_GPU - if (!rc || N > 1) { - return rc; - } - - return verify(Algorithm::CN_GPU, test_output_gpu); -# else - return rc; + if (! (!rc || N > 1)) { + return verify(Algorithm::CN_GPU, test_output_gpu); + } else # endif + return rc; } # ifdef XMRIG_ALGO_CN_LITE diff --git a/src/backend/cpu/platform/BasicCpuInfo.cpp b/src/backend/cpu/platform/BasicCpuInfo.cpp index e11eb175..fd425618 100644 --- a/src/backend/cpu/platform/BasicCpuInfo.cpp +++ b/src/backend/cpu/platform/BasicCpuInfo.cpp @@ -340,6 +340,12 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3 } # endif +# ifdef XMRIG_ALGO_CN_GPU + if (algorithm == Algorithm::CN_GPU) { + return count_limit; + } +# endif + # ifdef XMRIG_ALGO_RANDOMX if (f == Algorithm::RANDOM_X) { if (algorithm == Algorithm::RX_WOW) { @@ -374,12 +380,6 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3 } # endif -# ifdef XMRIG_ALGO_CN_GPU - if (algorithm == Algorithm::CN_GPU) { - return count_limit; - } -# endif - # ifdef XMRIG_ALGO_GHOSTRIDER if (f == Algorithm::GHOSTRIDER) { return CpuThreads(std::max(count / 2, 1), 8); diff --git a/src/backend/cuda/CudaConfig_gen.h b/src/backend/cuda/CudaConfig_gen.h index 57fb8208..6712d9e5 100644 --- a/src/backend/cuda/CudaConfig_gen.h +++ b/src/backend/cuda/CudaConfig_gen.h @@ -52,16 +52,15 @@ size_t inline generate(Threads &threads, const std:: count += generate(Algorithm::kCN, threads, Algorithm::CN_1, devices); count += generate(Algorithm::kCN_2, threads, Algorithm::CN_2, devices); +# ifdef XMRIG_ALGO_CN_GPU + count += generate(Algorithm::kCN_GPU, threads, Algorithm::CN_GPU, devices); +# endif if (!threads.isExist(Algorithm::CN_0)) { threads.disable(Algorithm::CN_0); count++; } -# ifdef XMRIG_ALGO_CN_GPU - count += generate("cn/gpu", threads, Algorithm::CN_GPU, devices); -# endif - return count; } diff --git a/src/backend/opencl/OclConfig_gen.h b/src/backend/opencl/OclConfig_gen.h index f8e59d12..c8c6a2ca 100644 --- a/src/backend/opencl/OclConfig_gen.h +++ b/src/backend/opencl/OclConfig_gen.h @@ -51,16 +51,15 @@ size_t inline generate(Threads &threads, const std::v count += generate(Algorithm::kCN, threads, Algorithm::CN_1, devices); count += generate(Algorithm::kCN_2, threads, Algorithm::CN_2, devices); +# ifdef XMRIG_ALGO_CN_GPU + count += generate(Algorithm::kCN_GPU, threads, Algorithm::CN_GPU, devices); +# endif if (!threads.isExist(Algorithm::CN_0)) { threads.disable(Algorithm::CN_0); count++; } -# ifdef XMRIG_ALGO_CN_GPU - count += generate("cn/gpu", threads, Algorithm::CN_GPU, devices); -# endif - return count; } diff --git a/src/backend/opencl/OclThread.h b/src/backend/opencl/OclThread.h index 74e16b8e..1e51e24e 100644 --- a/src/backend/opencl/OclThread.h +++ b/src/backend/opencl/OclThread.h @@ -45,6 +45,20 @@ public: setIntensity(intensity); } +# ifdef XMRIG_ALGO_CN_GPU + OclThread(uint32_t index, uint32_t intensity, uint32_t worksize, uint32_t threads, uint32_t unrollFactor) : + m_fields(0), + m_threads(threads, -1), + m_index(index), + m_memChunk(0), + m_stridedIndex(0), + m_unrollFactor(unrollFactor), + m_worksize(worksize) + { + setIntensity(intensity); + } +# endif + # ifdef XMRIG_ALGO_RANDOMX OclThread(uint32_t index, uint32_t intensity, uint32_t worksize, uint32_t threads, bool gcnAsm, bool datasetHost, uint32_t bfactor) : m_datasetHost(datasetHost), @@ -89,20 +103,6 @@ public: } # endif -# ifdef XMRIG_ALGO_CN_GPU - OclThread(uint32_t index, uint32_t intensity, uint32_t worksize, uint32_t threads, uint32_t unrollFactor) : - m_fields(0), - m_threads(threads, -1), - m_index(index), - m_memChunk(0), - m_stridedIndex(0), - m_unrollFactor(unrollFactor), - m_worksize(worksize) - { - setIntensity(intensity); - } -# endif - OclThread(const rapidjson::Value &value); inline bool isAsm() const { return m_gcnAsm; } diff --git a/src/backend/opencl/OclWorker.cpp b/src/backend/opencl/OclWorker.cpp index 6a8732c1..71bcaaff 100644 --- a/src/backend/opencl/OclWorker.cpp +++ b/src/backend/opencl/OclWorker.cpp @@ -29,6 +29,10 @@ #include "net/JobResults.h" +#ifdef XMRIG_ALGO_CN_GPU +# include "backend/opencl/runners/OclRyoRunner.h" +#endif + #ifdef XMRIG_ALGO_RANDOMX # include "backend/opencl/runners/OclRxJitRunner.h" # include "backend/opencl/runners/OclRxVmRunner.h" @@ -42,10 +46,6 @@ # include "backend/opencl/runners/OclKawPowRunner.h" #endif -#ifdef XMRIG_ALGO_CN_GPU -# include "backend/opencl/runners/OclRyoRunner.h" -#endif - #include #include diff --git a/src/backend/opencl/cl/OclSource.cpp b/src/backend/opencl/cl/OclSource.cpp index 2b41802e..11fb2fa8 100644 --- a/src/backend/opencl/cl/OclSource.cpp +++ b/src/backend/opencl/cl/OclSource.cpp @@ -28,6 +28,10 @@ #include "base/crypto/Algorithm.h" +#ifdef XMRIG_ALGO_CN_GPU +# include "backend/opencl/cl/cn/cryptonight_gpu_cl.h" +#endif + #ifdef XMRIG_ALGO_RANDOMX # include "backend/opencl/cl/rx/randomx_cl.h" #endif @@ -41,13 +45,15 @@ # include "backend/opencl/cl/kawpow/kawpow_dag_cl.h" #endif -#ifdef XMRIG_ALGO_CN_GPU -# include "backend/opencl/cl/cn/cryptonight_gpu_cl.h" -#endif - const char *xmrig::OclSource::get(const Algorithm &algorithm) { +# ifdef XMRIG_ALGO_CN_GPU + if (algorithm == Algorithm::CN_GPU) { + return cryptonight_gpu_cl; + } +# endif + # ifdef XMRIG_ALGO_RANDOMX if (algorithm.family() == Algorithm::RANDOM_X) { return randomx_cl; @@ -66,11 +72,5 @@ const char *xmrig::OclSource::get(const Algorithm &algorithm) } # endif -# ifdef XMRIG_ALGO_CN_GPU - if (algorithm == Algorithm::CN_GPU) { - return cryptonight_gpu_cl; - } -# endif - return cryptonight_cl; } diff --git a/src/backend/opencl/cl/cn/algorithm.cl b/src/backend/opencl/cl/cn/algorithm.cl index 4bf19d4c..ab063010 100644 --- a/src/backend/opencl/cl/cn/algorithm.cl +++ b/src/backend/opencl/cl/cn/algorithm.cl @@ -18,6 +18,7 @@ #define ALGO_CN_PICO_0 0x63120200 #define ALGO_CN_PICO_TLO 0x63120274 #define ALGO_CN_UPX2 0x63110200 +#define ALGO_CN_GPU 0x63150300 #define ALGO_RX_0 0x72151200 #define ALGO_RX_WOW 0x72141177 #define ALGO_RX_ARQMA 0x72121061 @@ -30,7 +31,6 @@ #define ALGO_ASTROBWT_DERO 0x41000000 #define ALGO_KAWPOW_RVN 0x6b0f0000 -#define ALGO_CN_GPU 0x631500ff #define ALGO_RX_XLA 0x721211ff #define FAMILY_UNKNOWN 0 diff --git a/src/backend/opencl/cl/cn/cryptonight_cl.h b/src/backend/opencl/cl/cn/cryptonight_cl.h index 1d8828d4..4effd1e7 100644 --- a/src/backend/opencl/cl/cn/cryptonight_cl.h +++ b/src/backend/opencl/cl/cn/cryptonight_cl.h @@ -30,19 +30,19 @@ static const char cryptonight_cl[61582] = { 0x30,0x36,0x38,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x50,0x49,0x43,0x4f,0x5f,0x30,0x20,0x30,0x78,0x36,0x33,0x31, 0x32,0x30,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x50,0x49,0x43,0x4f,0x5f,0x54,0x4c,0x4f,0x20,0x30, 0x78,0x36,0x33,0x31,0x32,0x30,0x32,0x37,0x34,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x55,0x50,0x58,0x32,0x20,0x30, - 0x78,0x36,0x33,0x31,0x31,0x30,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x30,0x20,0x30,0x78,0x37,0x32, - 0x31,0x35,0x31,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x57,0x4f,0x57,0x20,0x30,0x78,0x37,0x32,0x31, - 0x34,0x31,0x31,0x37,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x41,0x52,0x51,0x4d,0x41,0x20,0x30,0x78,0x37,0x32, - 0x31,0x32,0x31,0x30,0x36,0x31,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x53,0x46,0x58,0x20,0x30,0x78,0x37,0x32,0x31, - 0x35,0x31,0x32,0x37,0x33,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x4b,0x45,0x56,0x41,0x20,0x30,0x78,0x37,0x32,0x31, - 0x34,0x31,0x31,0x36,0x62,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x47,0x52,0x41,0x46,0x54,0x20,0x30,0x78,0x37,0x32, - 0x31,0x35,0x31,0x32,0x36,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41,0x20,0x30, - 0x78,0x36,0x31,0x31,0x33,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57, - 0x41,0x5f,0x56,0x32,0x20,0x30,0x78,0x36,0x31,0x31,0x34,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32, - 0x5f,0x57,0x52,0x4b,0x5a,0x20,0x30,0x78,0x36,0x31,0x31,0x32,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x53, - 0x54,0x52,0x4f,0x42,0x57,0x54,0x5f,0x44,0x45,0x52,0x4f,0x20,0x30,0x78,0x34,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41, - 0x4c,0x47,0x4f,0x5f,0x4b,0x41,0x57,0x50,0x4f,0x57,0x5f,0x52,0x56,0x4e,0x20,0x30,0x78,0x36,0x62,0x30,0x66,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e, - 0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x47,0x50,0x55,0x20,0x30,0x78,0x36,0x33,0x31,0x35,0x30,0x30,0x66,0x66,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65, + 0x78,0x36,0x33,0x31,0x31,0x30,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x47,0x50,0x55,0x20,0x30,0x78, + 0x36,0x33,0x31,0x35,0x30,0x33,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x30,0x20,0x30,0x78,0x37,0x32,0x31, + 0x35,0x31,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x57,0x4f,0x57,0x20,0x30,0x78,0x37,0x32,0x31,0x34, + 0x31,0x31,0x37,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x41,0x52,0x51,0x4d,0x41,0x20,0x30,0x78,0x37,0x32,0x31, + 0x32,0x31,0x30,0x36,0x31,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x53,0x46,0x58,0x20,0x30,0x78,0x37,0x32,0x31,0x35, + 0x31,0x32,0x37,0x33,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x4b,0x45,0x56,0x41,0x20,0x30,0x78,0x37,0x32,0x31,0x34, + 0x31,0x31,0x36,0x62,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x47,0x52,0x41,0x46,0x54,0x20,0x30,0x78,0x37,0x32,0x31, + 0x35,0x31,0x32,0x36,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41,0x20,0x30,0x78, + 0x36,0x31,0x31,0x33,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41, + 0x5f,0x56,0x32,0x20,0x30,0x78,0x36,0x31,0x31,0x34,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f, + 0x57,0x52,0x4b,0x5a,0x20,0x30,0x78,0x36,0x31,0x31,0x32,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x53,0x54, + 0x52,0x4f,0x42,0x57,0x54,0x5f,0x44,0x45,0x52,0x4f,0x20,0x30,0x78,0x34,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c, + 0x47,0x4f,0x5f,0x4b,0x41,0x57,0x50,0x4f,0x57,0x5f,0x52,0x56,0x4e,0x20,0x30,0x78,0x36,0x62,0x30,0x66,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65, 0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x58,0x4c,0x41,0x20,0x30,0x78,0x37,0x32,0x31,0x32,0x31,0x31,0x66,0x66,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20, 0x46,0x41,0x4d,0x49,0x4c,0x59,0x5f,0x55,0x4e,0x4b,0x4e,0x4f,0x57,0x4e,0x20,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x46,0x41,0x4d,0x49,0x4c,0x59,0x5f, 0x43,0x4e,0x20,0x30,0x78,0x36,0x33,0x31,0x35,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x46,0x41,0x4d,0x49,0x4c,0x59,0x5f,0x43,0x4e,0x5f, diff --git a/src/backend/opencl/cl/rx/randomx_cl.h b/src/backend/opencl/cl/rx/randomx_cl.h index 550729ed..dfcf6a1a 100644 --- a/src/backend/opencl/cl/rx/randomx_cl.h +++ b/src/backend/opencl/cl/rx/randomx_cl.h @@ -23,19 +23,19 @@ static const char randomx_cl[131086] = { 0x36,0x38,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x50,0x49,0x43,0x4f,0x5f,0x30,0x20,0x30,0x78,0x36,0x33,0x31,0x32, 0x30,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x50,0x49,0x43,0x4f,0x5f,0x54,0x4c,0x4f,0x20,0x30,0x78, 0x36,0x33,0x31,0x32,0x30,0x32,0x37,0x34,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x55,0x50,0x58,0x32,0x20,0x30,0x78, - 0x36,0x33,0x31,0x31,0x30,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x30,0x20,0x30,0x78,0x37,0x32,0x31, - 0x35,0x31,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x57,0x4f,0x57,0x20,0x30,0x78,0x37,0x32,0x31,0x34, - 0x31,0x31,0x37,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x41,0x52,0x51,0x4d,0x41,0x20,0x30,0x78,0x37,0x32,0x31, - 0x32,0x31,0x30,0x36,0x31,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x53,0x46,0x58,0x20,0x30,0x78,0x37,0x32,0x31,0x35, - 0x31,0x32,0x37,0x33,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x4b,0x45,0x56,0x41,0x20,0x30,0x78,0x37,0x32,0x31,0x34, - 0x31,0x31,0x36,0x62,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x47,0x52,0x41,0x46,0x54,0x20,0x30,0x78,0x37,0x32,0x31, - 0x35,0x31,0x32,0x36,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41,0x20,0x30,0x78, - 0x36,0x31,0x31,0x33,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41, - 0x5f,0x56,0x32,0x20,0x30,0x78,0x36,0x31,0x31,0x34,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f, - 0x57,0x52,0x4b,0x5a,0x20,0x30,0x78,0x36,0x31,0x31,0x32,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x53,0x54, - 0x52,0x4f,0x42,0x57,0x54,0x5f,0x44,0x45,0x52,0x4f,0x20,0x30,0x78,0x34,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c, - 0x47,0x4f,0x5f,0x4b,0x41,0x57,0x50,0x4f,0x57,0x5f,0x52,0x56,0x4e,0x20,0x30,0x78,0x36,0x62,0x30,0x66,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65, - 0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x47,0x50,0x55,0x20,0x30,0x78,0x36,0x33,0x31,0x35,0x30,0x30,0x66,0x66,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20, + 0x36,0x33,0x31,0x31,0x30,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x47,0x50,0x55,0x20,0x30,0x78,0x36, + 0x33,0x31,0x35,0x30,0x33,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x30,0x20,0x30,0x78,0x37,0x32,0x31,0x35, + 0x31,0x32,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x57,0x4f,0x57,0x20,0x30,0x78,0x37,0x32,0x31,0x34,0x31, + 0x31,0x37,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x41,0x52,0x51,0x4d,0x41,0x20,0x30,0x78,0x37,0x32,0x31,0x32, + 0x31,0x30,0x36,0x31,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x53,0x46,0x58,0x20,0x30,0x78,0x37,0x32,0x31,0x35,0x31, + 0x32,0x37,0x33,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x4b,0x45,0x56,0x41,0x20,0x30,0x78,0x37,0x32,0x31,0x34,0x31, + 0x31,0x36,0x62,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x47,0x52,0x41,0x46,0x54,0x20,0x30,0x78,0x37,0x32,0x31,0x35, + 0x31,0x32,0x36,0x37,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41,0x20,0x30,0x78,0x36, + 0x31,0x31,0x33,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x43,0x48,0x55,0x4b,0x57,0x41,0x5f, + 0x56,0x32,0x20,0x30,0x78,0x36,0x31,0x31,0x34,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x52,0x32,0x5f,0x57, + 0x52,0x4b,0x5a,0x20,0x30,0x78,0x36,0x31,0x31,0x32,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x41,0x53,0x54,0x52, + 0x4f,0x42,0x57,0x54,0x5f,0x44,0x45,0x52,0x4f,0x20,0x30,0x78,0x34,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x41,0x4c,0x47, + 0x4f,0x5f,0x4b,0x41,0x57,0x50,0x4f,0x57,0x5f,0x52,0x56,0x4e,0x20,0x30,0x78,0x36,0x62,0x30,0x66,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20, 0x41,0x4c,0x47,0x4f,0x5f,0x52,0x58,0x5f,0x58,0x4c,0x41,0x20,0x30,0x78,0x37,0x32,0x31,0x32,0x31,0x31,0x66,0x66,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x46, 0x41,0x4d,0x49,0x4c,0x59,0x5f,0x55,0x4e,0x4b,0x4e,0x4f,0x57,0x4e,0x20,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x46,0x41,0x4d,0x49,0x4c,0x59,0x5f,0x43, 0x4e,0x20,0x30,0x78,0x36,0x33,0x31,0x35,0x30,0x30,0x30,0x30,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x46,0x41,0x4d,0x49,0x4c,0x59,0x5f,0x43,0x4e,0x5f,0x4c, diff --git a/src/base/crypto/Algorithm.cpp b/src/base/crypto/Algorithm.cpp index 4194cc8d..e5b0c665 100644 --- a/src/base/crypto/Algorithm.cpp +++ b/src/base/crypto/Algorithm.cpp @@ -74,6 +74,10 @@ const char *Algorithm::kCN_PICO_TLO = "cn-pico/tlo"; const char *Algorithm::kCN_UPX2 = "cn/upx2"; #endif +#ifdef XMRIG_ALGO_CN_GPU +const char *Algorithm::kCN_GPU = "cn/gpu"; +#endif + #ifdef XMRIG_ALGO_RANDOMX const char *Algorithm::kRX = "rx"; const char *Algorithm::kRX_0 = "rx/0"; @@ -106,10 +110,6 @@ const char* Algorithm::kGHOSTRIDER = "ghostrider"; const char* Algorithm::kGHOSTRIDER_RTM = "ghostrider"; #endif - -#ifdef XMRIG_ALGO_CN_GPU -const char *Algorithm::kCN_GPU = "cn/gpu"; -#endif #ifdef XMRIG_ALGO_RANDOMX const char *Algorithm::kRX_XLA = "panthera"; #endif @@ -154,6 +154,10 @@ static const std::map kAlgorithmNames = { ALGO_NAME(CN_UPX2), # endif +# ifdef XMRIG_ALGO_CN_GPU + ALGO_NAME(CN_GPU), +# endif + # ifdef XMRIG_ALGO_RANDOMX ALGO_NAME(RX_0), ALGO_NAME(RX_WOW), @@ -177,10 +181,6 @@ static const std::map kAlgorithmNames = { ALGO_NAME(KAWPOW_RVN), # endif -# ifdef XMRIG_ALGO_CN_GPU - ALGO_NAME(CN_GPU), -# endif - # ifdef XMRIG_ALGO_RANDOMX ALGO_NAME(RX_XLA), # endif @@ -272,6 +272,11 @@ static const std::map kAlgorithmAlias ALGO_ALIAS(CN_UPX2, "cryptonight-upx/2"), # endif +# ifdef XMRIG_ALGO_CN_GPU + ALGO_ALIAS_AUTO(CN_GPU), ALGO_ALIAS(CN_GPU, "cryptonight/gpu"), + ALGO_ALIAS(CN_GPU, "cryptonight_gpu"), +# endif + # ifdef XMRIG_ALGO_RANDOMX ALGO_ALIAS_AUTO(RX_0), ALGO_ALIAS(RX_0, "randomx/0"), ALGO_ALIAS(RX_0, "randomx/test"), @@ -304,10 +309,6 @@ static const std::map kAlgorithmAlias ALGO_ALIAS_AUTO(KAWPOW_RVN), ALGO_ALIAS(KAWPOW_RVN, "kawpow/rvn"), # endif -# ifdef XMRIG_ALGO_CN_GPU - ALGO_ALIAS_AUTO(CN_GPU), ALGO_ALIAS(CN_GPU, "cryptonight/gpu"), -# endif - # ifdef XMRIG_ALGO_RANDOMX ALGO_ALIAS_AUTO(RX_XLA), ALGO_ALIAS(RX_XLA, "Panthera"), # endif @@ -387,8 +388,9 @@ std::vector xmrig::Algorithm::all(const std::function constexpr inline uint32_t CnAlgo::iterations() con template<> constexpr inline uint32_t CnAlgo::iterations() const { return CN_ITER / 8; } template<> constexpr inline uint32_t CnAlgo::iterations() const { return CN_ITER / 8; } template<> constexpr inline uint32_t CnAlgo::iterations() const { return CN_ITER / 2; } -template<> constexpr inline uint32_t CnAlgo::iterations() const { return 0xC000; } template<> constexpr inline uint32_t CnAlgo::iterations() const { return CN_ITER / 32; } +template<> constexpr inline uint32_t CnAlgo::iterations() const { return 0xC000; } template<> constexpr inline uint32_t CnAlgo::mask() const { return 0x1FFF0; } -template<> constexpr inline uint32_t CnAlgo::mask() const { return 0x1FFFC0; } template<> constexpr inline uint32_t CnAlgo::mask() const { return 0x1FFF0; } +template<> constexpr inline uint32_t CnAlgo::mask() const { return 0x1FFFC0; } #ifdef XMRIG_ALGO_GHOSTRIDER template<> constexpr inline uint32_t CnAlgo::iterations() const { return CN_ITER / 4; } diff --git a/src/crypto/cn/CnHash.cpp b/src/crypto/cn/CnHash.cpp index ce1b5738..5a2e3a03 100644 --- a/src/crypto/cn/CnHash.cpp +++ b/src/crypto/cn/CnHash.cpp @@ -290,6 +290,12 @@ xmrig::CnHash::CnHash() ADD_FN_ASM(Algorithm::CN_UPX2); # endif +# ifdef XMRIG_ALGO_CN_GPU + m_map[Algorithm::CN_GPU] = new cn_hash_fun_array{}; + m_map[Algorithm::CN_GPU]->data[AV_SINGLE][Assembly::NONE] = cryptonight_single_hash_gpu; + m_map[Algorithm::CN_GPU]->data[AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash_gpu; +# endif + # ifdef XMRIG_ALGO_ARGON2 m_map[Algorithm::AR2_CHUKWA] = new cn_hash_fun_array{}; m_map[Algorithm::AR2_CHUKWA]->data[AV_SINGLE][Assembly::NONE] = argon2::single_hash; @@ -310,12 +316,6 @@ xmrig::CnHash::CnHash() m_map[Algorithm::ASTROBWT_DERO]->data[AV_SINGLE_SOFT][Assembly::NONE] = astrobwt::single_hash; # endif -# ifdef XMRIG_ALGO_CN_GPU - m_map[Algorithm::CN_GPU] = new cn_hash_fun_array{}; - m_map[Algorithm::CN_GPU]->data[AV_SINGLE][Assembly::NONE] = cryptonight_single_hash_gpu; - m_map[Algorithm::CN_GPU]->data[AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash_gpu; -# endif - # ifdef XMRIG_ALGO_GHOSTRIDER ADD_FN(Algorithm::CN_GR_0); ADD_FN(Algorithm::CN_GR_1); diff --git a/src/crypto/cn/CryptoNight_test.h b/src/crypto/cn/CryptoNight_test.h index 99f7f3a3..0137859f 100644 --- a/src/crypto/cn/CryptoNight_test.h +++ b/src/crypto/cn/CryptoNight_test.h @@ -370,22 +370,6 @@ const static uint8_t test_output_pico_tlo[256] = { #endif -#ifdef XMRIG_ALGO_CN_GPU -// "cn/gpu" -const static uint8_t test_output_gpu[160] = { - 0xE5, 0x5C, 0xB2, 0x3E, 0x51, 0x64, 0x9A, 0x59, 0xB1, 0x27, 0xB9, 0x6B, 0x51, 0x5F, 0x2B, 0xF7, - 0xBF, 0xEA, 0x19, 0x97, 0x41, 0xA0, 0x21, 0x6C, 0xF8, 0x38, 0xDE, 0xD0, 0x6E, 0xFF, 0x82, 0xDF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; -#endif - #ifdef XMRIG_ALGO_CN_FEMTO // "cn/upx2" const static uint8_t test_output_femto_upx2[256] = { @@ -403,6 +387,23 @@ const static uint8_t test_output_femto_upx2[256] = { #endif +#ifdef XMRIG_ALGO_CN_GPU +// "cn/gpu" +const static uint8_t test_output_gpu[160] = { + 0xE5, 0x5C, 0xB2, 0x3E, 0x51, 0x64, 0x9A, 0x59, 0xB1, 0x27, 0xB9, 0x6B, 0x51, 0x5F, 0x2B, 0xF7, + 0xBF, 0xEA, 0x19, 0x97, 0x41, 0xA0, 0x21, 0x6C, 0xF8, 0x38, 0xDE, 0xD0, 0x6E, 0xFF, 0x82, 0xDF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +#endif + + #ifdef XMRIG_ALGO_ARGON2 // "argon2/chukwa" const static uint8_t argon2_chukwa_test_out[256] = { diff --git a/src/crypto/cn/CryptoNight_x86.h b/src/crypto/cn/CryptoNight_x86.h index 3ffae588..c10de177 100644 --- a/src/crypto/cn/CryptoNight_x86.h +++ b/src/crypto/cn/CryptoNight_x86.h @@ -420,7 +420,6 @@ static NOINLINE void cn_implode_scratchpad(cryptonight_ctx *ctx) # else constexpr bool IS_HEAVY = props.isHeavy(); # endif - constexpr size_t N = (props.memory() / sizeof(__m128i)) / (props.half_mem() ? 2 : 1); __m128i xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7; @@ -841,8 +840,11 @@ namespace xmrig { template -void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output) +static NOINLINE void cn_explode_scratchpad_gpu(cryptonight_ctx *ctx) { + const uint8_t* input = reinterpret_cast(ctx->state); + uint8_t* output = reinterpret_cast(ctx->memory); + constexpr size_t hash_size = 200; // 25x8 bytes alignas(16) uint64_t hash[25]; @@ -866,12 +868,12 @@ void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output) template -inline void cryptonight_single_hash_gpu(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t) +inline void cryptonight_single_hash_gpu(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) { constexpr CnAlgo props; keccak(input, size, ctx[0]->state); - cn_explode_scratchpad_gpu(ctx[0]->state, ctx[0]->memory); + cn_explode_scratchpad_gpu(ctx[0]); # ifdef _MSC_VER _control87(RC_NEAR, MCW_RC); diff --git a/src/crypto/cn/CryptoNight_x86_vaes.cpp b/src/crypto/cn/CryptoNight_x86_vaes.cpp index c953591f..b2258b5e 100644 --- a/src/crypto/cn/CryptoNight_x86_vaes.cpp +++ b/src/crypto/cn/CryptoNight_x86_vaes.cpp @@ -518,13 +518,13 @@ void (*vaes_instances[])() = { VAES_Instance, VAES_Instance, VAES_Instance, + VAES_Instance, VAES_Instance, VAES_Instance, VAES_Instance, VAES_Instance, VAES_Instance, VAES_Instance, - VAES_Instance, };