![support@xmrig.com](/assets/img/avatar_default.png)
18 changed files with 871 additions and 7 deletions
@ -0,0 +1,217 @@ |
|||
/* 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 <mutex> |
|||
#include <string> |
|||
|
|||
|
|||
#include "backend/cuda/CudaBackend.h" |
|||
#include "backend/common/Hashrate.h" |
|||
#include "backend/common/interfaces/IWorker.h" |
|||
#include "backend/common/Tags.h" |
|||
#include "backend/common/Workers.h" |
|||
#include "base/io/log/Log.h" |
|||
#include "base/net/stratum/Job.h" |
|||
#include "base/tools/Chrono.h" |
|||
#include "base/tools/String.h" |
|||
#include "core/config/Config.h" |
|||
#include "core/Controller.h" |
|||
#include "rapidjson/document.h" |
|||
|
|||
|
|||
#ifdef XMRIG_FEATURE_API |
|||
# include "base/api/interfaces/IApiRequest.h" |
|||
#endif |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
extern template class Threads<OclThreads>; |
|||
|
|||
|
|||
constexpr const size_t oneMiB = 1024u * 1024u; |
|||
static const char *tag = MAGENTA_BG_BOLD(WHITE_BOLD_S " nv "); |
|||
static const String kType = "cuda"; |
|||
static std::mutex mutex; |
|||
|
|||
|
|||
|
|||
class CudaBackendPrivate |
|||
{ |
|||
public: |
|||
inline CudaBackendPrivate(Controller *controller) : |
|||
controller(controller) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void init(const OclConfig &cl) |
|||
{ |
|||
} |
|||
|
|||
|
|||
inline void start(const Job &job) |
|||
{ |
|||
} |
|||
|
|||
|
|||
Algorithm algo; |
|||
Controller *controller; |
|||
String profileName; |
|||
}; |
|||
|
|||
|
|||
} // namespace xmrig
|
|||
|
|||
|
|||
const char *xmrig::cuda_tag() |
|||
{ |
|||
return tag; |
|||
} |
|||
|
|||
|
|||
xmrig::CudaBackend::CudaBackend(Controller *controller) : |
|||
d_ptr(new CudaBackendPrivate(controller)) |
|||
{ |
|||
} |
|||
|
|||
|
|||
xmrig::CudaBackend::~CudaBackend() |
|||
{ |
|||
delete d_ptr; |
|||
} |
|||
|
|||
|
|||
bool xmrig::CudaBackend::isEnabled() const |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
|
|||
bool xmrig::CudaBackend::isEnabled(const Algorithm &algorithm) const |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
|
|||
const xmrig::Hashrate *xmrig::CudaBackend::hashrate() const |
|||
{ |
|||
return nullptr; |
|||
// return d_ptr->workers.hashrate();
|
|||
} |
|||
|
|||
|
|||
const xmrig::String &xmrig::CudaBackend::profileName() const |
|||
{ |
|||
return d_ptr->profileName; |
|||
} |
|||
|
|||
|
|||
const xmrig::String &xmrig::CudaBackend::type() const |
|||
{ |
|||
return kType; |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaBackend::prepare(const Job &) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaBackend::printHashrate(bool details) |
|||
{ |
|||
if (!details || !hashrate()) { |
|||
return; |
|||
} |
|||
|
|||
char num[8 * 3] = { 0 }; |
|||
|
|||
Log::print(WHITE_BOLD_S "| CUDA # | AFFINITY | 10s H/s | 60s H/s | 15m H/s |"); |
|||
|
|||
// size_t i = 0;
|
|||
// for (const OclLaunchData &data : d_ptr->threads) {
|
|||
// Log::print("| %8zu | %8" PRId64 " | %7s | %7s | %7s |" CYAN_BOLD(" #%u") YELLOW(" %s") " %s",
|
|||
// i,
|
|||
// data.affinity,
|
|||
// Hashrate::format(hashrate()->calc(i, Hashrate::ShortInterval), num, sizeof num / 3),
|
|||
// Hashrate::format(hashrate()->calc(i, Hashrate::MediumInterval), num + 8, sizeof num / 3),
|
|||
// Hashrate::format(hashrate()->calc(i, Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3),
|
|||
// data.device.index(),
|
|||
// data.device.topology().toString().data(),
|
|||
// data.device.printableName().data()
|
|||
// );
|
|||
|
|||
// i++;
|
|||
// }
|
|||
|
|||
Log::print(WHITE_BOLD_S "| - | - | %7s | %7s | %7s |", |
|||
Hashrate::format(hashrate()->calc(Hashrate::ShortInterval), num, sizeof num / 3), |
|||
Hashrate::format(hashrate()->calc(Hashrate::MediumInterval), num + 8, sizeof num / 3), |
|||
Hashrate::format(hashrate()->calc(Hashrate::LargeInterval), num + 8 * 2, sizeof num / 3) |
|||
); |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaBackend::setJob(const Job &job) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaBackend::start(IWorker *worker, bool ready) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaBackend::stop() |
|||
{ |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaBackend::tick(uint64_t ticks) |
|||
{ |
|||
} |
|||
|
|||
|
|||
#ifdef XMRIG_FEATURE_API |
|||
rapidjson::Value xmrig::CudaBackend::toJSON(rapidjson::Document &doc) const |
|||
{ |
|||
using namespace rapidjson; |
|||
auto &allocator = doc.GetAllocator(); |
|||
|
|||
Value out(kObjectType); |
|||
out.AddMember("type", type().toJSON(), allocator); |
|||
out.AddMember("enabled", isEnabled(), allocator); |
|||
out.AddMember("algo", d_ptr->algo.toJSON(), allocator); |
|||
out.AddMember("profile", profileName().toJSON(), allocator); |
|||
|
|||
return out; |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaBackend::handleRequest(IApiRequest &) |
|||
{ |
|||
} |
|||
#endif |
@ -0,0 +1,79 @@ |
|||
/* 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_CUDABACKEND_H |
|||
#define XMRIG_CUDABACKEND_H |
|||
|
|||
|
|||
#include <utility> |
|||
|
|||
|
|||
#include "backend/common/interfaces/IBackend.h" |
|||
#include "base/tools/Object.h" |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
class Controller; |
|||
class CudaBackendPrivate; |
|||
class Miner; |
|||
|
|||
|
|||
class CudaBackend : public IBackend |
|||
{ |
|||
public: |
|||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(CudaBackend) |
|||
|
|||
CudaBackend(Controller *controller); |
|||
|
|||
~CudaBackend() override; |
|||
|
|||
protected: |
|||
bool isEnabled() const override; |
|||
bool isEnabled(const Algorithm &algorithm) const override; |
|||
const Hashrate *hashrate() const override; |
|||
const String &profileName() const override; |
|||
const String &type() const override; |
|||
void prepare(const Job &nextJob) override; |
|||
void printHashrate(bool details) override; |
|||
void setJob(const Job &job) override; |
|||
void start(IWorker *worker, bool ready) override; |
|||
void stop() override; |
|||
void tick(uint64_t ticks) override; |
|||
|
|||
# ifdef XMRIG_FEATURE_API |
|||
rapidjson::Value toJSON(rapidjson::Document &doc) const override; |
|||
void handleRequest(IApiRequest &request) override; |
|||
# endif |
|||
|
|||
private: |
|||
CudaBackendPrivate *d_ptr; |
|||
}; |
|||
|
|||
|
|||
} /* namespace xmrig */ |
|||
|
|||
|
|||
#endif /* XMRIG_CUDABACKEND_H */ |
@ -0,0 +1,115 @@ |
|||
/* 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/CudaConfig.h" |
|||
#include "backend/cuda/CudaConfig_gen.h" |
|||
#include "base/io/json/Json.h" |
|||
#include "base/io/log/Log.h" |
|||
#include "rapidjson/document.h" |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
static const char *kDevicesHint = "devices-hint"; |
|||
static const char *kEnabled = "enabled"; |
|||
|
|||
|
|||
extern template class Threads<CudaThreads>; |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
rapidjson::Value xmrig::CudaConfig::toJSON(rapidjson::Document &doc) const |
|||
{ |
|||
using namespace rapidjson; |
|||
auto &allocator = doc.GetAllocator(); |
|||
|
|||
Value obj(kObjectType); |
|||
|
|||
obj.AddMember(StringRef(kEnabled), m_enabled, allocator); |
|||
|
|||
m_threads.toJSON(obj, doc); |
|||
|
|||
return obj; |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaConfig::read(const rapidjson::Value &value) |
|||
{ |
|||
if (value.IsObject()) { |
|||
m_enabled = Json::getBool(value, kEnabled, m_enabled); |
|||
|
|||
setDevicesHint(Json::getString(value, kDevicesHint)); |
|||
|
|||
m_threads.read(value); |
|||
|
|||
generate(); |
|||
} |
|||
else if (value.IsBool()) { |
|||
m_enabled = value.GetBool(); |
|||
|
|||
generate(); |
|||
} |
|||
else { |
|||
m_shouldSave = true; |
|||
|
|||
generate(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaConfig::generate() |
|||
{ |
|||
if (!isEnabled() || m_threads.has("*")) { |
|||
return; |
|||
} |
|||
|
|||
size_t count = 0; |
|||
|
|||
// count += xmrig::generate<Algorithm::CN>(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_PICO>(m_threads, devices);
|
|||
// count += xmrig::generate<Algorithm::RANDOM_X>(m_threads, devices);
|
|||
|
|||
m_shouldSave = count > 0; |
|||
} |
|||
|
|||
|
|||
void xmrig::CudaConfig::setDevicesHint(const char *devicesHint) |
|||
{ |
|||
if (devicesHint == nullptr) { |
|||
return; |
|||
} |
|||
|
|||
const auto indexes = String(devicesHint).split(','); |
|||
m_devicesHint.reserve(indexes.size()); |
|||
|
|||
for (const auto &index : indexes) { |
|||
m_devicesHint.push_back(strtoul(index, nullptr, 10)); |
|||
} |
|||
} |
@ -0,0 +1,62 @@ |
|||
/* 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_CUDACONFIG_H |
|||
#define XMRIG_CUDACONFIG_H |
|||
|
|||
|
|||
#include "backend/common/Threads.h" |
|||
#include "backend/cuda/CudaThreads.h" |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
class CudaConfig |
|||
{ |
|||
public: |
|||
CudaConfig() = default; |
|||
|
|||
rapidjson::Value toJSON(rapidjson::Document &doc) const; |
|||
void read(const rapidjson::Value &value); |
|||
|
|||
inline bool isEnabled() const { return m_enabled; } |
|||
inline bool isShouldSave() const { return m_shouldSave; } |
|||
inline const Threads<CudaThreads> &threads() const { return m_threads; } |
|||
|
|||
private: |
|||
void generate(); |
|||
void setDevicesHint(const char *devicesHint); |
|||
|
|||
bool m_enabled = false; |
|||
bool m_shouldSave = false; |
|||
std::vector<uint32_t> m_devicesHint; |
|||
Threads<CudaThreads> m_threads; |
|||
}; |
|||
|
|||
|
|||
} /* namespace xmrig */ |
|||
|
|||
|
|||
#endif /* XMRIG_CUDACONFIG_H */ |
@ -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/>.
|
|||
*/ |
|||
|
|||
#ifndef XMRIG_OCLCONFIG_GEN_H |
|||
#define XMRIG_OCLCONFIG_GEN_H |
|||
|
|||
|
|||
#include "backend/common/Threads.h" |
|||
#include "backend/cuda/CudaThreads.h" |
|||
|
|||
|
|||
#include <algorithm> |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
} /* namespace xmrig */ |
|||
|
|||
|
|||
#endif /* XMRIG_OCLCONFIG_GEN_H */ |
@ -0,0 +1,63 @@ |
|||
/* 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/CudaThread.h" |
|||
|
|||
#include "base/io/json/Json.h" |
|||
#include "rapidjson/document.h" |
|||
|
|||
|
|||
#include <algorithm> |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
} // namespace xmrig
|
|||
|
|||
|
|||
xmrig::CudaThread::CudaThread(const rapidjson::Value &value) |
|||
{ |
|||
if (!value.IsObject()) { |
|||
return; |
|||
} |
|||
} |
|||
|
|||
|
|||
bool xmrig::CudaThread::isEqual(const CudaThread &other) const |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
|
|||
rapidjson::Value xmrig::CudaThread::toJSON(rapidjson::Document &doc) const |
|||
{ |
|||
using namespace rapidjson; |
|||
auto &allocator = doc.GetAllocator(); |
|||
|
|||
Value out(kObjectType); |
|||
|
|||
return out; |
|||
} |
@ -0,0 +1,62 @@ |
|||
/* 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_CUDATHREAD_H |
|||
#define XMRIG_CUDATHREAD_H |
|||
|
|||
|
|||
#include "crypto/common/Algorithm.h" |
|||
#include "rapidjson/fwd.h" |
|||
|
|||
|
|||
#include <bitset> |
|||
#include <vector> |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
class CudaThread |
|||
{ |
|||
public: |
|||
CudaThread() = delete; |
|||
|
|||
CudaThread(const rapidjson::Value &value); |
|||
|
|||
inline bool isValid() const { return false; } |
|||
|
|||
inline bool operator!=(const CudaThread &other) const { return !isEqual(other); } |
|||
inline bool operator==(const CudaThread &other) const { return isEqual(other); } |
|||
|
|||
bool isEqual(const CudaThread &other) const; |
|||
rapidjson::Value toJSON(rapidjson::Document &doc) const; |
|||
|
|||
private: |
|||
}; |
|||
|
|||
|
|||
} /* namespace xmrig */ |
|||
|
|||
|
|||
#endif /* XMRIG_CUDATHREAD_H */ |
@ -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/>.
|
|||
*/ |
|||
|
|||
|
|||
#include "backend/cuda/CudaThreads.h" |
|||
#include "base/io/json/Json.h" |
|||
#include "rapidjson/document.h" |
|||
|
|||
|
|||
#include <algorithm> |
|||
|
|||
|
|||
xmrig::CudaThreads::CudaThreads(const rapidjson::Value &value) |
|||
{ |
|||
if (value.IsArray()) { |
|||
for (auto &v : value.GetArray()) { |
|||
CudaThread thread(v); |
|||
if (thread.isValid()) { |
|||
add(std::move(thread)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
bool xmrig::CudaThreads::isEqual(const CudaThreads &other) const |
|||
{ |
|||
if (isEmpty() && other.isEmpty()) { |
|||
return true; |
|||
} |
|||
|
|||
return count() == other.count() && std::equal(m_data.begin(), m_data.end(), other.m_data.begin()); |
|||
} |
|||
|
|||
|
|||
rapidjson::Value xmrig::CudaThreads::toJSON(rapidjson::Document &doc) const |
|||
{ |
|||
using namespace rapidjson; |
|||
auto &allocator = doc.GetAllocator(); |
|||
|
|||
Value out(kArrayType); |
|||
|
|||
out.SetArray(); |
|||
|
|||
for (const CudaThread &thread : m_data) { |
|||
out.PushBack(thread.toJSON(doc), allocator); |
|||
} |
|||
|
|||
return out; |
|||
} |
@ -0,0 +1,64 @@ |
|||
/* 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_CUDATHREADS_H |
|||
#define XMRIG_CUDATHREADS_H |
|||
|
|||
|
|||
#include <vector> |
|||
|
|||
|
|||
#include "backend/cuda/CudaThread.h" |
|||
|
|||
|
|||
namespace xmrig { |
|||
|
|||
|
|||
class CudaThreads |
|||
{ |
|||
public: |
|||
CudaThreads() = default; |
|||
CudaThreads(const rapidjson::Value &value); |
|||
|
|||
inline bool isEmpty() const { return m_data.empty(); } |
|||
inline const std::vector<CudaThread> &data() const { return m_data; } |
|||
inline size_t count() const { return m_data.size(); } |
|||
inline void add(CudaThread &&thread) { m_data.push_back(thread); } |
|||
inline void reserve(size_t capacity) { m_data.reserve(capacity); } |
|||
|
|||
inline bool operator!=(const CudaThreads &other) const { return !isEqual(other); } |
|||
inline bool operator==(const CudaThreads &other) const { return isEqual(other); } |
|||
|
|||
bool isEqual(const CudaThreads &other) const; |
|||
rapidjson::Value toJSON(rapidjson::Document &doc) const; |
|||
|
|||
private: |
|||
std::vector<CudaThread> m_data; |
|||
}; |
|||
|
|||
|
|||
} /* namespace xmrig */ |
|||
|
|||
|
|||
#endif /* XMRIG_CUDATHREADS_H */ |
@ -0,0 +1,23 @@ |
|||
if (WITH_CUDA) |
|||
add_definitions(/DXMRIG_FEATURE_CUDA) |
|||
|
|||
set(HEADERS_BACKEND_CUDA |
|||
src/backend/cuda/CudaBackend.h |
|||
src/backend/cuda/CudaConfig.h |
|||
src/backend/cuda/CudaConfig_gen.h |
|||
src/backend/cuda/CudaThread.h |
|||
src/backend/cuda/CudaThreads.h |
|||
) |
|||
|
|||
set(SOURCES_BACKEND_CUDA |
|||
src/backend/cuda/CudaBackend.cpp |
|||
src/backend/cuda/CudaConfig.cpp |
|||
src/backend/cuda/CudaThread.cpp |
|||
src/backend/cuda/CudaThreads.cpp |
|||
) |
|||
else() |
|||
remove_definitions(/DXMRIG_FEATURE_CUDA) |
|||
|
|||
set(HEADERS_BACKEND_CUDA "") |
|||
set(SOURCES_BACKEND_CUDA "") |
|||
endif() |
Loading…
Reference in new issue