mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-11 05:14:40 +00:00
Implemented cryptonight mining.
This commit is contained in:
parent
bb2cc0deb7
commit
c9f7cbae09
15 changed files with 486 additions and 29 deletions
|
@ -39,8 +39,9 @@ xmrig::CudaLaunchData::CudaLaunchData(const Miner *miner, const Algorithm &algor
|
|||
|
||||
bool xmrig::CudaLaunchData::isEqual(const CudaLaunchData &other) const
|
||||
{
|
||||
return (other.algorithm == algorithm &&
|
||||
other.thread == thread);
|
||||
return (other.algorithm.family() == algorithm.family() &&
|
||||
other.algorithm.l3() == algorithm.l3() &&
|
||||
other.thread == thread);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "backend/cuda/CudaWorker.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "backend/cuda/runners/CudaCnRunner.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "core/Miner.h"
|
||||
|
@ -33,6 +34,11 @@
|
|||
#include "net/JobResults.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_RANDOMX
|
||||
# include "backend/cuda/runners/CudaRxRunner.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <thread>
|
||||
|
||||
|
@ -64,25 +70,42 @@ xmrig::CudaWorker::CudaWorker(size_t id, const CudaLaunchData &data) :
|
|||
m_miner(data.miner),
|
||||
m_intensity(data.thread.threads() * data.thread.blocks())
|
||||
{
|
||||
switch (m_algorithm.family()) {
|
||||
case Algorithm::RANDOM_X:
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
m_runner = new CudaRxRunner(id, data);
|
||||
# endif
|
||||
break;
|
||||
|
||||
case Algorithm::ARGON2:
|
||||
break;
|
||||
|
||||
default:
|
||||
m_runner = new CudaCnRunner(id, data);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!m_runner || !m_runner->init()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::CudaWorker::~CudaWorker()
|
||||
{
|
||||
// delete m_runner;
|
||||
delete m_runner;
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaWorker::selfTest()
|
||||
{
|
||||
return false; // FIXME
|
||||
return m_runner != nullptr;
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::CudaWorker::intensity() const
|
||||
{
|
||||
return 0; // FIXME;
|
||||
// return m_runner ? m_runner->intensity() : 0;
|
||||
return m_runner ? m_runner->intensity() : 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,18 +128,16 @@ void xmrig::CudaWorker::start()
|
|||
}
|
||||
|
||||
while (!Nonce::isOutdated(Nonce::CUDA, m_job.sequence())) {
|
||||
// try {
|
||||
// m_runner->run(*m_job.nonce(), results);
|
||||
// }
|
||||
// catch (std::exception &ex) {
|
||||
// printError(id(), ex.what());
|
||||
uint32_t foundNonce[10] = { 0 };
|
||||
uint32_t foundCount = 0;
|
||||
|
||||
// return;
|
||||
// }
|
||||
if (!m_runner->run(*m_job.nonce(), &foundCount, foundNonce)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (results[0xFF] > 0) {
|
||||
// JobResults::submit(m_job.currentJob(), results, results[0xFF]);
|
||||
// }
|
||||
if (foundCount) {
|
||||
JobResults::submit(m_job.currentJob(), foundNonce, foundCount);
|
||||
}
|
||||
|
||||
m_job.nextRound(roundSize(m_intensity), m_intensity);
|
||||
|
||||
|
@ -139,16 +160,7 @@ bool xmrig::CudaWorker::consumeJob()
|
|||
|
||||
m_job.add(m_miner->job(), Nonce::sequence(Nonce::CUDA), roundSize(m_intensity) * m_intensity);
|
||||
|
||||
// try {
|
||||
// m_runner->set(m_job.currentJob(), m_job.blob());
|
||||
// }
|
||||
// catch (std::exception &ex) {
|
||||
// printError(id(), ex.what());
|
||||
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
return m_runner->set(m_job.currentJob(), m_job.blob());;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
class ICudaRunner;
|
||||
|
||||
|
||||
class CudaWorker : public Worker
|
||||
{
|
||||
public:
|
||||
|
@ -60,6 +63,7 @@ private:
|
|||
const Algorithm m_algorithm;
|
||||
const Miner *m_miner;
|
||||
const uint32_t m_intensity;
|
||||
ICudaRunner *m_runner = nullptr;
|
||||
WorkerJob<1> m_job;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ if (WITH_CUDA)
|
|||
src/backend/cuda/CudaThread.h
|
||||
src/backend/cuda/CudaThreads.h
|
||||
src/backend/cuda/CudaWorker.h
|
||||
src/backend/cuda/interfaces/ICudaRunner.h
|
||||
src/backend/cuda/runners/CudaBaseRunner.h
|
||||
src/backend/cuda/runners/CudaCnRunner.h
|
||||
src/backend/cuda/runners/CudaRxRunner.h
|
||||
src/backend/cuda/wrappers/CudaDevice.h
|
||||
src/backend/cuda/wrappers/CudaLib.h
|
||||
)
|
||||
|
@ -20,6 +24,9 @@ if (WITH_CUDA)
|
|||
src/backend/cuda/CudaThread.cpp
|
||||
src/backend/cuda/CudaThreads.cpp
|
||||
src/backend/cuda/CudaWorker.cpp
|
||||
src/backend/cuda/runners/CudaBaseRunner.cpp
|
||||
src/backend/cuda/runners/CudaCnRunner.cpp
|
||||
src/backend/cuda/runners/CudaRxRunner.cpp
|
||||
src/backend/cuda/wrappers/CudaDevice.cpp
|
||||
src/backend/cuda/wrappers/CudaLib.cpp
|
||||
)
|
||||
|
|
71
src/backend/cuda/interfaces/ICudaRunner.h
Normal file
71
src/backend/cuda/interfaces/ICudaRunner.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* 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-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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_ICUDARUNNER_H
|
||||
#define XMRIG_ICUDARUNNER_H
|
||||
|
||||
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Job;
|
||||
|
||||
|
||||
class ICudaRunner
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(ICudaRunner)
|
||||
|
||||
ICudaRunner() = default;
|
||||
virtual ~ICudaRunner() = default;
|
||||
|
||||
// virtual cl_context ctx() const = 0;
|
||||
// virtual const Algorithm &algorithm() const = 0;
|
||||
// virtual const char *buildOptions() const = 0;
|
||||
// virtual const char *deviceKey() const = 0;
|
||||
// virtual const char *source() const = 0;
|
||||
// virtual const OclLaunchData &data() const = 0;
|
||||
virtual size_t intensity() const = 0;
|
||||
// virtual size_t threadId() const = 0;
|
||||
// virtual uint32_t deviceIndex() const = 0;
|
||||
// virtual void build() = 0;
|
||||
virtual bool init() = 0;
|
||||
virtual bool run(uint32_t startNonce, uint32_t *rescount, uint32_t *resnonce) = 0;
|
||||
virtual bool set(const Job &job, uint8_t *blob) = 0;
|
||||
|
||||
protected:
|
||||
// virtual size_t bufferSize() const = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_ICUDARUNNER_H
|
76
src/backend/cuda/runners/CudaBaseRunner.cpp
Normal file
76
src/backend/cuda/runners/CudaBaseRunner.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
/* 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-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/cuda/runners/CudaBaseRunner.h"
|
||||
#include "backend/cuda/wrappers/CudaLib.h"
|
||||
#include "backend/cuda/CudaLaunchData.h"
|
||||
//#include "backend/opencl/cl/OclSource.h"
|
||||
//#include "backend/opencl/OclCache.h"
|
||||
//#include "backend/opencl/OclLaunchData.h"
|
||||
//#include "backend/opencl/runners/tools/OclSharedState.h"
|
||||
//#include "backend/opencl/wrappers/OclError.h"
|
||||
//#include "backend/opencl/wrappers/OclLib.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
//#include "crypto/common/VirtualMemory.h"
|
||||
|
||||
|
||||
xmrig::CudaBaseRunner::CudaBaseRunner(size_t id, const CudaLaunchData &data) :
|
||||
m_data(data),
|
||||
m_threadId(id)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::CudaBaseRunner::~CudaBaseRunner()
|
||||
{
|
||||
CudaLib::release(m_ctx);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaBaseRunner::init()
|
||||
{
|
||||
m_ctx = CudaLib::alloc(m_data.thread.index(), m_data.thread.bfactor(), m_data.thread.bsleep());
|
||||
if (CudaLib::deviceInfo(m_ctx, m_data.thread.blocks(), m_data.thread.threads(), m_data.algorithm) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return CudaLib::deviceInit(m_ctx);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaBaseRunner::set(const Job &job, uint8_t *blob)
|
||||
{
|
||||
m_height = job.height();
|
||||
m_target = job.target();
|
||||
|
||||
return CudaLib::setJob(m_ctx, blob, job.size(), job.algorithm());
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::CudaBaseRunner::intensity() const
|
||||
{
|
||||
return m_data.thread.threads() * m_data.thread.blocks();
|
||||
}
|
66
src/backend/cuda/runners/CudaBaseRunner.h
Normal file
66
src/backend/cuda/runners/CudaBaseRunner.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* 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-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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CUDABASERUNNER_H
|
||||
#define XMRIG_CUDABASERUNNER_H
|
||||
|
||||
|
||||
#include "backend/cuda/interfaces/ICudaRunner.h"
|
||||
|
||||
|
||||
using nvid_ctx = struct nvid_ctx;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class CudaLaunchData;
|
||||
|
||||
|
||||
class CudaBaseRunner : public ICudaRunner
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(CudaBaseRunner)
|
||||
|
||||
CudaBaseRunner(size_t id, const CudaLaunchData &data);
|
||||
~CudaBaseRunner() override;
|
||||
|
||||
protected:
|
||||
bool init() override;
|
||||
bool set(const Job &job, uint8_t *blob) override;
|
||||
size_t intensity() const override;
|
||||
|
||||
protected:
|
||||
const CudaLaunchData &m_data;
|
||||
const size_t m_threadId;
|
||||
nvid_ctx *m_ctx = nullptr;
|
||||
uint64_t m_height = 0;
|
||||
uint64_t m_target = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_CUDABASERUNNER_H
|
38
src/backend/cuda/runners/CudaCnRunner.cpp
Normal file
38
src/backend/cuda/runners/CudaCnRunner.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* 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-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/cuda/runners/CudaCnRunner.h"
|
||||
#include "backend/cuda/wrappers/CudaLib.h"
|
||||
|
||||
|
||||
xmrig::CudaCnRunner::CudaCnRunner(size_t index, const CudaLaunchData &data) : CudaBaseRunner(index, data)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaCnRunner::run(uint32_t startNonce, uint32_t *rescount, uint32_t *resnonce)
|
||||
{
|
||||
return CudaLib::cnHash(m_ctx, startNonce, m_height, m_target, rescount, resnonce);
|
||||
}
|
48
src/backend/cuda/runners/CudaCnRunner.h
Normal file
48
src/backend/cuda/runners/CudaCnRunner.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* 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-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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CUDACNRUNNER_H
|
||||
#define XMRIG_CUDACNRUNNER_H
|
||||
|
||||
|
||||
#include "backend/cuda/runners/CudaBaseRunner.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class CudaCnRunner : public CudaBaseRunner
|
||||
{
|
||||
public:
|
||||
CudaCnRunner(size_t index, const CudaLaunchData &data);
|
||||
|
||||
protected:
|
||||
bool run(uint32_t startNonce, uint32_t *rescount, uint32_t *resnonce) override;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_CUDACNRUNNER_H
|
42
src/backend/cuda/runners/CudaRxRunner.cpp
Normal file
42
src/backend/cuda/runners/CudaRxRunner.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* 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-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/cuda/runners/CudaRxRunner.h"
|
||||
|
||||
|
||||
xmrig::CudaRxRunner::CudaRxRunner(size_t index, const CudaLaunchData &data) : CudaBaseRunner(index, data)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
xmrig::CudaRxRunner::~CudaRxRunner()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaRxRunner::run(uint32_t startNonce, uint32_t *rescount, uint32_t *resnonce)
|
||||
{
|
||||
return false;
|
||||
}
|
53
src/backend/cuda/runners/CudaRxRunner.h
Normal file
53
src/backend/cuda/runners/CudaRxRunner.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* 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-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/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CUDARXRUNNER_H
|
||||
#define XMRIG_CUDARXRUNNER_H
|
||||
|
||||
|
||||
#include "backend/cuda/runners/CudaBaseRunner.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class CudaRxRunner : public CudaBaseRunner
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(CudaRxRunner)
|
||||
|
||||
CudaRxRunner(size_t index, const CudaLaunchData &data);
|
||||
~CudaRxRunner() override;
|
||||
|
||||
protected:
|
||||
bool run(uint32_t startNonce, uint32_t *rescount, uint32_t *resnonce) override;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_CUDARXRUNNER_H
|
|
@ -46,39 +46,51 @@ static uv_lib_t cudaLib;
|
|||
|
||||
|
||||
static const char *kAlloc = "alloc";
|
||||
static const char *kCnHash = "cnHash";
|
||||
static const char *kDeviceCount = "deviceCount";
|
||||
static const char *kDeviceInfo = "deviceInfo";
|
||||
static const char *kDeviceInit = "deviceInit";
|
||||
static const char *kDeviceInt = "deviceInt";
|
||||
static const char *kDeviceName = "deviceName";
|
||||
static const char *kDeviceUint = "deviceUint";
|
||||
static const char *kDeviceUlong = "deviceUlong";
|
||||
static const char *kInit = "init";
|
||||
static const char *kPluginVersion = "pluginVersion";
|
||||
static const char *kRelease = "release";
|
||||
static const char *kSetJob = "setJob";
|
||||
static const char *kSymbolNotFound = "symbol not found";
|
||||
static const char *kVersion = "version";
|
||||
|
||||
|
||||
using alloc_t = nvid_ctx * (*)(uint32_t, int32_t, int32_t);
|
||||
using cnHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint64_t, uint32_t *, uint32_t *);
|
||||
using deviceCount_t = uint32_t (*)();
|
||||
using deviceInfo_t = int32_t (*)(nvid_ctx *, int32_t, int32_t, int32_t);
|
||||
using deviceInit_t = bool (*)(nvid_ctx *);
|
||||
using deviceInt_t = int32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
|
||||
using deviceName_t = const char * (*)(nvid_ctx *);
|
||||
using deviceUint_t = uint32_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
|
||||
using deviceUlong_t = uint64_t (*)(nvid_ctx *, CudaLib::DeviceProperty);
|
||||
using init_t = void (*)();
|
||||
using pluginVersion_t = const char * (*)();
|
||||
using release_t = void (*)(nvid_ctx *);
|
||||
using setJob_t = bool (*)(nvid_ctx *, const void *, size_t, int32_t);
|
||||
using version_t = uint32_t (*)(Version);
|
||||
|
||||
|
||||
static alloc_t pAlloc = nullptr;
|
||||
static cnHash_t pCnHash = nullptr;
|
||||
static deviceCount_t pDeviceCount = nullptr;
|
||||
static deviceInfo_t pDeviceInfo = nullptr;
|
||||
static deviceInit_t pDeviceInit = nullptr;
|
||||
static deviceInt_t pDeviceInt = nullptr;
|
||||
static deviceName_t pDeviceName = nullptr;
|
||||
static deviceUint_t pDeviceUint = nullptr;
|
||||
static deviceUlong_t pDeviceUlong = nullptr;
|
||||
static init_t pInit = nullptr;
|
||||
static pluginVersion_t pPluginVersion = nullptr;
|
||||
static release_t pRelease = nullptr;
|
||||
static setJob_t pSetJob = nullptr;
|
||||
static version_t pVersion = nullptr;
|
||||
|
||||
|
||||
|
@ -117,6 +129,24 @@ void xmrig::CudaLib::close()
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::CudaLib::cnHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t height, uint64_t target, uint32_t *rescount, uint32_t *resnonce)
|
||||
{
|
||||
return pCnHash(ctx, startNonce, height, target, rescount, resnonce);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaLib::deviceInit(nvid_ctx *ctx) noexcept
|
||||
{
|
||||
return pDeviceInit(ctx);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::CudaLib::setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept
|
||||
{
|
||||
return pSetJob(ctx, data, size, algorithm);
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::CudaLib::deviceName(nvid_ctx *ctx) noexcept
|
||||
{
|
||||
return pDeviceName(ctx);
|
||||
|
@ -216,19 +246,25 @@ bool xmrig::CudaLib::load()
|
|||
|
||||
try {
|
||||
DLSYM(Alloc);
|
||||
DLSYM(CnHash);
|
||||
DLSYM(DeviceCount);
|
||||
DLSYM(DeviceInfo);
|
||||
DLSYM(DeviceInit);
|
||||
DLSYM(DeviceInt);
|
||||
DLSYM(DeviceName);
|
||||
DLSYM(DeviceUint);
|
||||
DLSYM(DeviceUlong);
|
||||
DLSYM(Init);
|
||||
DLSYM(PluginVersion);
|
||||
DLSYM(Release);
|
||||
DLSYM(SetJob);
|
||||
DLSYM(Version);
|
||||
} catch (std::exception &ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pInit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ public:
|
|||
static inline bool isInitialized() { return m_initialized; }
|
||||
static inline const String &loader() { return m_loader; }
|
||||
|
||||
static bool cnHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t height, uint64_t target, uint32_t *rescount, uint32_t *resnonce);
|
||||
static bool deviceInit(nvid_ctx *ctx) noexcept;
|
||||
static bool setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept;
|
||||
static const char *deviceName(nvid_ctx *ctx) noexcept;
|
||||
static const char *pluginVersion() noexcept;
|
||||
static int deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm) noexcept;
|
||||
|
|
|
@ -39,8 +39,8 @@ constexpr size_t oneGiB = 1024 * 1024 * 1024;
|
|||
|
||||
|
||||
xmrig::OclBaseRunner::OclBaseRunner(size_t id, const OclLaunchData &data) :
|
||||
m_algorithm(data.algorithm),
|
||||
m_ctx(data.ctx),
|
||||
m_algorithm(data.algorithm),
|
||||
m_source(OclSource::get(data.algorithm)),
|
||||
m_data(data),
|
||||
m_align(OclLib::getUint(data.device.id(), CL_DEVICE_MEM_BASE_ADDR_ALIGN)),
|
||||
|
|
|
@ -70,21 +70,21 @@ protected:
|
|||
void enqueueWriteBuffer(cl_mem buffer, cl_bool blocking_write, size_t offset, size_t size, const void *ptr);
|
||||
void finalize(uint32_t *hashOutput);
|
||||
|
||||
Algorithm m_algorithm;
|
||||
cl_command_queue m_queue = nullptr;
|
||||
cl_context m_ctx;
|
||||
cl_mem m_buffer = nullptr;
|
||||
cl_mem m_input = nullptr;
|
||||
cl_mem m_output = nullptr;
|
||||
cl_program m_program = nullptr;
|
||||
const Algorithm m_algorithm;
|
||||
const char *m_source;
|
||||
const OclLaunchData &m_data;
|
||||
const size_t m_align;
|
||||
const size_t m_threadId;
|
||||
const uint32_t m_intensity;
|
||||
size_t m_offset = 0;
|
||||
std::string m_deviceKey;
|
||||
std::string m_options;
|
||||
uint32_t m_intensity;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue