From 1c0ef1548f1890cb80c5e41d12b42987ed3fb6a1 Mon Sep 17 00:00:00 2001 From: psychocrypt <psychocryptHPC@gmail.com> Date: Sun, 7 Oct 2018 21:30:48 +0200 Subject: [PATCH] fix crash with monero and strided_index Strided index 1 is not allowed for cryptonight_v8 and monero. In the case the dev pool is set to monero and the user tuned there settings for an other currency the miner will crash if strided index or memChunk is not fitting the requirement to mine monero. This PR detects wrong configurations and will set strided index and memChunk to a valid value but only for cryptonight_v8. The user pool settings will only be changed if monero or cryptonight_v8 is selected. --- xmrstak/backend/amd/amd_gpu/gpu.cpp | 32 ++++++++++++++--------------- xmrstak/backend/amd/config.tpl | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/xmrstak/backend/amd/amd_gpu/gpu.cpp b/xmrstak/backend/amd/amd_gpu/gpu.cpp index 2fe0350..7c7aff7 100644 --- a/xmrstak/backend/amd/amd_gpu/gpu.cpp +++ b/xmrstak/backend/amd/amd_gpu/gpu.cpp @@ -396,12 +396,26 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_ int threadMemMask = cn_select_mask(miner_algo[ii]); int hashIterations = cn_select_iter(miner_algo[ii]); + size_t mem_chunk_exp = 1u << ctx->memChunk; + size_t strided_index = ctx->stridedIndex; + /* Adjust the config settings to a valid combination + * this is required if the dev pool is mining monero + * but the user tuned there settings for another currency + */ + if(miner_algo[ii] == cryptonight_monero_v8) + { + if(ctx->memChunk < 2) + mem_chunk_exp = 1u << 2; + if(strided_index == 1) + strided_index = 0; + } + std::string options; options += " -DITERATIONS=" + std::to_string(hashIterations); options += " -DMASK=" + std::to_string(threadMemMask); options += " -DWORKSIZE=" + std::to_string(ctx->workSize); - options += " -DSTRIDED_INDEX=" + std::to_string(ctx->stridedIndex); - options += " -DMEM_CHUNK_EXPONENT=" + std::to_string(1u << ctx->memChunk); + options += " -DSTRIDED_INDEX=" + std::to_string(strided_index); + options += " -DMEM_CHUNK_EXPONENT=" + std::to_string(mem_chunk_exp); options += " -DCOMP_MODE=" + std::to_string(ctx->compMode ? 1u : 0u); options += " -DMEMORY=" + std::to_string(hashMemSize); options += " -DALGO=" + std::to_string(miner_algo[ii]); @@ -931,20 +945,6 @@ size_t InitOpenCL(GpuContext* ctx, size_t num_gpus, size_t platform_idx) printer::inst()->print_msg(L0, "WARNING %s: gpu %d intensity is not a multiple of 'worksize', auto reduce intensity to %d", backendName.c_str(), ctx[i].deviceIdx, int(reduced_intensity)); } - if(useCryptonight_v8) - { - if(ctx[i].stridedIndex == 1) - { - printer::inst()->print_msg(L0, "ERROR %s: gpu %d stridedIndex is not allowed to be `true` or `1` for the selected currency", backendName.c_str(), ctx[i].deviceIdx); - return ERR_STUPID_PARAMS; - } - if(ctx[i].stridedIndex == 2 && ctx[i].memChunk < 2) - { - printer::inst()->print_msg(L0, "ERROR %s: gpu %d memChunk bust be >= 2 for the selected currency", backendName.c_str(), ctx[i].deviceIdx); - return ERR_STUPID_PARAMS; - } - } - if((ret = InitOpenCLGpu(opencl_ctx, &ctx[i], source_code.c_str())) != ERR_SUCCESS) { return ret; diff --git a/xmrstak/backend/amd/config.tpl b/xmrstak/backend/amd/config.tpl index b852a7e..49033c8 100644 --- a/xmrstak/backend/amd/config.tpl +++ b/xmrstak/backend/amd/config.tpl @@ -10,7 +10,7 @@ R"===(// generated by XMRSTAK_VERSION * 2 = chunked memory, chunk size is controlled by 'mem_chunk' * required: intensity must be a multiple of worksize * 1 or true = use 16byte contiguous memory per thread, the next memory block has offset of intensity blocks - * (not allowed for cryptonight_v8 and monero) + * (for cryptonight_v8 and monero it is equal to strided_index = 0) * 0 or false = use a contiguous block of memory per thread * mem_chunk - range 0 to 18: set the number of elements (16byte) per chunk * this value is only used if 'strided_index' == 2 -- GitLab