mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-18 10:01:06 +00:00
Added autoconfig stub for RandomX.
This commit is contained in:
parent
ad7141fe21
commit
046eb4d9fd
6 changed files with 137 additions and 36 deletions
|
@ -60,8 +60,8 @@ static const char *kCnPico = "cn-pico";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_RANDOMX
|
#ifdef XMRIG_ALGO_RANDOMX
|
||||||
//static const char *kRx = "rx";
|
static const char *kRx = "rx";
|
||||||
//static const char *kRxWOW = "rx/wow";
|
static const char *kRxWOW = "rx/wow";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_ARGON2
|
#ifdef XMRIG_ALGO_ARGON2
|
||||||
|
@ -72,14 +72,21 @@ static const char *kCnPico = "cn-pico";
|
||||||
extern template class Threads<OclThreads>;
|
extern template class Threads<OclThreads>;
|
||||||
|
|
||||||
|
|
||||||
static OclThreads generate(const Algorithm &algorithm, const std::vector<OclDevice> &devices)
|
static size_t generate(const char *key, Threads<OclThreads> &threads, const Algorithm &algorithm, const std::vector<OclDevice> &devices)
|
||||||
{
|
{
|
||||||
OclThreads threads;
|
if (threads.has(key) || threads.isExist(algorithm)) {
|
||||||
for (const OclDevice &device : devices) {
|
return 0;
|
||||||
device.generate(algorithm, threads);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return threads;
|
OclThreads profile;
|
||||||
|
for (const OclDevice &device : devices) {
|
||||||
|
device.generate(algorithm, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t count = profile.count();
|
||||||
|
threads.move(key, std::move(profile));
|
||||||
|
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +215,9 @@ void xmrig::OclConfig::read(const rapidjson::Value &value)
|
||||||
|
|
||||||
setPlatform(Json::getValue(value, kPlatform));
|
setPlatform(Json::getValue(value, kPlatform));
|
||||||
|
|
||||||
if (isEnabled() && !m_threads.read(value)) {
|
if (isEnabled()) {
|
||||||
|
m_threads.read(value);
|
||||||
|
|
||||||
generate();
|
generate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,33 +241,43 @@ void xmrig::OclConfig::generate()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_shouldSave = true;
|
size_t count = 0;
|
||||||
|
|
||||||
m_threads.disable(Algorithm::CN_0);
|
count += xmrig::generate(kCn, m_threads, Algorithm::CN_0, devices);
|
||||||
m_threads.move(kCn, xmrig::generate(Algorithm::CN_0, devices));
|
count += xmrig::generate(kCn2, m_threads, Algorithm::CN_2, devices);
|
||||||
m_threads.move(kCn2, xmrig::generate(Algorithm::CN_2, devices));
|
|
||||||
|
if (!m_threads.isExist(Algorithm::CN_0)) {
|
||||||
|
m_threads.disable(Algorithm::CN_0);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_GPU
|
# ifdef XMRIG_ALGO_CN_GPU
|
||||||
m_threads.move(kCnGPU, xmrig::generate(Algorithm::CN_GPU, devices));
|
count += xmrig::generate(kCnGPU, m_threads, Algorithm::CN_GPU, devices);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_LITE
|
# ifdef XMRIG_ALGO_CN_LITE
|
||||||
m_threads.disable(Algorithm::CN_LITE_0);
|
count += xmrig::generate(kCnLite, m_threads, Algorithm::CN_LITE_1, devices);
|
||||||
m_threads.move(kCnLite, xmrig::generate(Algorithm::CN_LITE_1, devices));
|
|
||||||
|
if (!m_threads.isExist(Algorithm::CN_LITE_0)) {
|
||||||
|
m_threads.disable(Algorithm::CN_LITE_0);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||||
m_threads.move(kCnHeavy, xmrig::generate(Algorithm::CN_HEAVY_0, devices));
|
count += xmrig::generate(kCnHeavy, m_threads, Algorithm::CN_HEAVY_0, devices);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_CN_PICO
|
# ifdef XMRIG_ALGO_CN_PICO
|
||||||
m_threads.move(kCnPico, xmrig::generate(Algorithm::CN_PICO_0, devices));
|
count += xmrig::generate(kCnPico, m_threads, Algorithm::CN_PICO_0, devices);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
// m_threads.move(kRx, xmrig::generate(Algorithm::RX_0, devices));
|
count += xmrig::generate(kRx, m_threads, Algorithm::RX_0, devices);
|
||||||
// m_threads.move(kRxWOW, xmrig::generate(Algorithm::RX_WOW, devices));
|
count += xmrig::generate(kRxWOW, m_threads, Algorithm::RX_WOW, devices);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
m_shouldSave = count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,13 +58,7 @@ xmrig::OclThread::OclThread(const rapidjson::Value &value)
|
||||||
|
|
||||||
setIntensity(Json::getUint(value, kIntensity));
|
setIntensity(Json::getUint(value, kIntensity));
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
const auto &si = Json::getArray(value, kStridedIndex);
|
||||||
m_bfactor = Json::getUint(value, kBFactor, 6);
|
|
||||||
m_gcnAsm = Json::getBool(value, kGCNAsm, m_gcnAsm);
|
|
||||||
m_datasetHost = Json::getBool(value, kDatasetHost, m_datasetHost);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
const rapidjson::Value &si = Json::getArray(value, kStridedIndex);
|
|
||||||
if (si.IsArray() && si.Size() >= 2) {
|
if (si.IsArray() && si.Size() >= 2) {
|
||||||
m_stridedIndex = std::min(si[0].GetUint(), 2u);
|
m_stridedIndex = std::min(si[0].GetUint(), 2u);
|
||||||
m_memChunk = std::min(si[1].GetUint(), 18u);
|
m_memChunk = std::min(si[1].GetUint(), 18u);
|
||||||
|
@ -75,7 +69,7 @@ xmrig::OclThread::OclThread(const rapidjson::Value &value)
|
||||||
m_fields.set(STRIDED_INDEX_FIELD, false);
|
m_fields.set(STRIDED_INDEX_FIELD, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rapidjson::Value &threads = Json::getArray(value, kThreads);
|
const auto &threads = Json::getArray(value, kThreads);
|
||||||
if (threads.IsArray()) {
|
if (threads.IsArray()) {
|
||||||
m_threads.reserve(threads.Size());
|
m_threads.reserve(threads.Size());
|
||||||
|
|
||||||
|
@ -87,6 +81,17 @@ xmrig::OclThread::OclThread(const rapidjson::Value &value)
|
||||||
if (m_threads.empty()) {
|
if (m_threads.empty()) {
|
||||||
m_threads.emplace_back(-1);
|
m_threads.emplace_back(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
const auto &gcnAsm = Json::getValue(value, kGCNAsm);
|
||||||
|
if (gcnAsm.IsBool()) {
|
||||||
|
m_fields.set(RANDOMX_FIELDS, true);
|
||||||
|
|
||||||
|
m_gcnAsm = gcnAsm.GetBool();
|
||||||
|
m_bfactor = Json::getUint(value, kBFactor, m_bfactor);
|
||||||
|
m_datasetHost = Json::getBool(value, kDatasetHost, m_datasetHost);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,16 +137,18 @@ rapidjson::Value xmrig::OclThread::toJSON(rapidjson::Document &doc) const
|
||||||
threads.PushBack(thread, allocator);
|
threads.PushBack(thread, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.AddMember(StringRef(kThreads), threads, allocator);
|
out.AddMember(StringRef(kThreads), threads, allocator);
|
||||||
out.AddMember(StringRef(kUnroll), unrollFactor(), allocator);
|
|
||||||
|
|
||||||
# ifdef XMRIG_ALGO_RANDOMX
|
if (m_fields.test(RANDOMX_FIELDS)) {
|
||||||
// if (m_datasetHost != -1) {
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
// out.AddMember(StringRef(kBFactor), bfactor(), allocator);
|
out.AddMember(StringRef(kBFactor), bfactor(), allocator);
|
||||||
// out.AddMember(StringRef(kGCNAsm), gcnAsm(), allocator);
|
out.AddMember(StringRef(kGCNAsm), isAsm(), allocator);
|
||||||
// out.AddMember(StringRef(kDatasetHost), isDatasetHost(), allocator);
|
out.AddMember(StringRef(kDatasetHost), isDatasetHost(), allocator);
|
||||||
// }
|
# endif
|
||||||
# endif
|
}
|
||||||
|
else {
|
||||||
|
out.AddMember(StringRef(kUnroll), unrollFactor(), allocator);
|
||||||
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,22 @@ public:
|
||||||
}
|
}
|
||||||
# endif
|
# 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),
|
||||||
|
m_gcnAsm(gcnAsm),
|
||||||
|
m_fields(2),
|
||||||
|
m_threads(threads, -1),
|
||||||
|
m_bfactor(bfactor),
|
||||||
|
m_index(index),
|
||||||
|
m_memChunk(0),
|
||||||
|
m_stridedIndex(0),
|
||||||
|
m_worksize(worksize)
|
||||||
|
{
|
||||||
|
setIntensity(intensity);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
OclThread(const rapidjson::Value &value);
|
OclThread(const rapidjson::Value &value);
|
||||||
|
|
||||||
inline bool isAsm() const { return m_gcnAsm; }
|
inline bool isAsm() const { return m_gcnAsm; }
|
||||||
|
|
51
src/backend/opencl/generators/ocl_generic_rx_generator.cpp
Normal file
51
src/backend/opencl/generators/ocl_generic_rx_generator.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* 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 Lee Clagett <https://github.com/vtnerd>
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "backend/opencl/OclThreads.h"
|
||||||
|
#include "backend/opencl/wrappers/OclDevice.h"
|
||||||
|
#include "crypto/common/Algorithm.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
constexpr const size_t oneMiB = 1024u * 1024u;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool ocl_generic_rx_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads)
|
||||||
|
{
|
||||||
|
if (algorithm.family() != Algorithm::RANDOM_X) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// threads.add(OclThread(device.index(), 500, 8, 1, true, false, 6));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace xmrig
|
|
@ -82,6 +82,7 @@ if (WITH_OPENCL)
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND SOURCES_BACKEND_OPENCL
|
list(APPEND SOURCES_BACKEND_OPENCL
|
||||||
|
src/backend/opencl/generators/ocl_generic_rx_generator.cpp
|
||||||
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
|
src/backend/opencl/kernels/rx/Blake2bHashRegistersKernel.cpp
|
||||||
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
|
src/backend/opencl/kernels/rx/Blake2bInitialHashKernel.cpp
|
||||||
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp
|
src/backend/opencl/kernels/rx/ExecuteVmKernel.cpp
|
||||||
|
|
|
@ -47,6 +47,10 @@ typedef union
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
extern bool ocl_generic_rx_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XMRIG_ALGO_CN_GPU
|
#ifdef XMRIG_ALGO_CN_GPU
|
||||||
extern bool ocl_generic_cn_gpu_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
extern bool ocl_generic_cn_gpu_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,6 +60,9 @@ extern bool ocl_generic_cn_generator(const OclDevice &device, const Algorithm &a
|
||||||
|
|
||||||
|
|
||||||
ocl_gen_config_fun generators[] = {
|
ocl_gen_config_fun generators[] = {
|
||||||
|
# ifdef XMRIG_ALGO_RANDOMX
|
||||||
|
ocl_generic_rx_generator,
|
||||||
|
# endif
|
||||||
# ifdef XMRIG_ALGO_CN_GPU
|
# ifdef XMRIG_ALGO_CN_GPU
|
||||||
ocl_generic_cn_gpu_generator,
|
ocl_generic_cn_gpu_generator,
|
||||||
# endif
|
# endif
|
||||||
|
|
Loading…
Reference in a new issue