From 2e6c518a1c21a527bc702a4df1789cdd87fcd1e1 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 4 Apr 2020 17:19:23 +0700 Subject: [PATCH] Code style cleanup --- src/backend/cuda/CudaConfig.cpp | 4 +- src/backend/cuda/CudaConfig.h | 4 +- src/backend/cuda/interfaces/ICudaRunner.h | 26 ++++-------- .../cuda/runners/CudaAstroBWTRunner.cpp | 4 +- src/backend/cuda/wrappers/CudaLib.cpp | 40 +++++++++---------- src/backend/cuda/wrappers/CudaLib.h | 4 +- 6 files changed, 35 insertions(+), 47 deletions(-) diff --git a/src/backend/cuda/CudaConfig.cpp b/src/backend/cuda/CudaConfig.cpp index 072d3ef9e..618aefa90 100644 --- a/src/backend/cuda/CudaConfig.cpp +++ b/src/backend/cuda/CudaConfig.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/backend/cuda/CudaConfig.h b/src/backend/cuda/CudaConfig.h index 3f3957e64..1c2f2e03e 100644 --- a/src/backend/cuda/CudaConfig.h +++ b/src/backend/cuda/CudaConfig.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 diff --git a/src/backend/cuda/interfaces/ICudaRunner.h b/src/backend/cuda/interfaces/ICudaRunner.h index 2e8b000c2..25bf5af0d 100644 --- a/src/backend/cuda/interfaces/ICudaRunner.h +++ b/src/backend/cuda/interfaces/ICudaRunner.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -46,24 +46,12 @@ public: 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 roundSize() const = 0; - virtual size_t processedHashes() const = 0; -// virtual size_t threadId() const = 0; -// virtual uint32_t deviceIndex() const = 0; -// virtual void build() = 0; - virtual bool init() = 0; + virtual size_t intensity() const = 0; + virtual size_t roundSize() const = 0; + virtual size_t processedHashes() const = 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; + virtual bool set(const Job &job, uint8_t *blob) = 0; }; diff --git a/src/backend/cuda/runners/CudaAstroBWTRunner.cpp b/src/backend/cuda/runners/CudaAstroBWTRunner.cpp index 6bb3e42ba..af3f4d77d 100644 --- a/src/backend/cuda/runners/CudaAstroBWTRunner.cpp +++ b/src/backend/cuda/runners/CudaAstroBWTRunner.cpp @@ -50,7 +50,7 @@ xmrig::CudaAstroBWTRunner::CudaAstroBWTRunner(size_t index, const CudaLaunchData bool xmrig::CudaAstroBWTRunner::run(uint32_t startNonce, uint32_t *rescount, uint32_t *resnonce) { - return callWrapper(CudaLib::AstroBWTHash(m_ctx, startNonce, m_target, rescount, resnonce)); + return callWrapper(CudaLib::astroBWTHash(m_ctx, startNonce, m_target, rescount, resnonce)); } @@ -60,7 +60,7 @@ bool xmrig::CudaAstroBWTRunner::set(const Job &job, uint8_t *blob) return false; } - return callWrapper(CudaLib::AstroBWTPrepare(m_ctx, static_cast(m_intensity))); + return callWrapper(CudaLib::astroBWTPrepare(m_ctx, static_cast(m_intensity))); } size_t xmrig::CudaAstroBWTRunner::roundSize() const diff --git a/src/backend/cuda/wrappers/CudaLib.cpp b/src/backend/cuda/wrappers/CudaLib.cpp index 0df51b75b..db1ff9047 100644 --- a/src/backend/cuda/wrappers/CudaLib.cpp +++ b/src/backend/cuda/wrappers/CudaLib.cpp @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , + * Copyright 2018-2020 SChernykh + * Copyright 2016-2020 XMRig , * * 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 @@ -47,6 +47,8 @@ static uv_lib_t cudaLib; static const char *kAlloc = "alloc"; +static const char *kAstroBWTHash = "astroBWTHash"; +static const char *kAstroBWTPrepare = "astroBWTPrepare"; static const char *kCnHash = "cnHash"; static const char *kDeviceCount = "deviceCount"; static const char *kDeviceInfo = "deviceInfo"; @@ -62,8 +64,6 @@ static const char *kPluginVersion = "pluginVersion"; static const char *kRelease = "release"; static const char *kRxHash = "rxHash"; static const char *kRxPrepare = "rxPrepare"; -static const char *kAstroBWTHash = "AstroBWTHash"; -static const char *kAstroBWTPrepare = "AstroBWTPrepare"; static const char *kSetJob = "setJob"; static const char *kSetJob_v2 = "setJob_v2"; static const char *kSymbolNotFound = "symbol not found"; @@ -71,6 +71,8 @@ static const char *kVersion = "version"; using alloc_t = nvid_ctx * (*)(uint32_t, int32_t, int32_t); +using astroBWTHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint32_t *, uint32_t *); +using astroBWTPrepare_t = bool (*)(nvid_ctx *, uint32_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, int32_t); @@ -85,8 +87,6 @@ using lastError_t = const char * (*)(nvid_ using pluginVersion_t = const char * (*)(); using release_t = void (*)(nvid_ctx *); using rxHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint32_t *, uint32_t *); -using AstroBWTHash_t = bool (*)(nvid_ctx *, uint32_t, uint64_t, uint32_t *, uint32_t *); -using AstroBWTPrepare_t = bool (*)(nvid_ctx *, uint32_t); using rxPrepare_t = bool (*)(nvid_ctx *, const void *, size_t, bool, uint32_t); using setJob_t = bool (*)(nvid_ctx *, const void *, size_t, int32_t); using setJob_v2_t = bool (*)(nvid_ctx *, const void *, size_t, const char *); @@ -94,6 +94,8 @@ using version_t = uint32_t (*)(Version); static alloc_t pAlloc = nullptr; +static astroBWTHash_t pAstroBWTHash = nullptr; +static astroBWTPrepare_t pAstroBWTPrepare = nullptr; static cnHash_t pCnHash = nullptr; static deviceCount_t pDeviceCount = nullptr; static deviceInfo_t pDeviceInfo = nullptr; @@ -108,8 +110,6 @@ static lastError_t pLastError = nullptr; static pluginVersion_t pPluginVersion = nullptr; static release_t pRelease = nullptr; static rxHash_t pRxHash = nullptr; -static AstroBWTHash_t pAstroBWTHash = nullptr; -static AstroBWTPrepare_t pAstroBWTPrepare = nullptr; static rxPrepare_t pRxPrepare = nullptr; static setJob_t pSetJob = nullptr; static setJob_v2_t pSetJob_v2 = nullptr; @@ -151,6 +151,18 @@ void xmrig::CudaLib::close() } +bool xmrig::CudaLib::astroBWTHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept +{ + return pAstroBWTHash(ctx, startNonce, target, rescount, resnonce); +} + + +bool xmrig::CudaLib::astroBWTPrepare(nvid_ctx *ctx, uint32_t batchSize) noexcept +{ + return pAstroBWTPrepare(ctx, batchSize); +} + + 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); @@ -187,18 +199,6 @@ bool xmrig::CudaLib::rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datase } -bool xmrig::CudaLib::AstroBWTHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept -{ - return pAstroBWTHash(ctx, startNonce, target, rescount, resnonce); -} - - -bool xmrig::CudaLib::AstroBWTPrepare(nvid_ctx *ctx, uint32_t batchSize) noexcept -{ - return pAstroBWTPrepare(ctx, batchSize); -} - - bool xmrig::CudaLib::setJob(nvid_ctx *ctx, const void *data, size_t size, const Algorithm &algorithm) noexcept { const Algorithm algo = RxAlgo::id(algorithm); diff --git a/src/backend/cuda/wrappers/CudaLib.h b/src/backend/cuda/wrappers/CudaLib.h index 14cb041ae..cd24c94b7 100644 --- a/src/backend/cuda/wrappers/CudaLib.h +++ b/src/backend/cuda/wrappers/CudaLib.h @@ -73,13 +73,13 @@ public: static inline bool isReady() noexcept { return m_ready; } static inline const String &loader() { return m_loader; } + static bool astroBWTHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept; + static bool astroBWTPrepare(nvid_ctx *ctx, uint32_t batchSize) noexcept; static bool cnHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t height, uint64_t target, uint32_t *rescount, uint32_t *resnonce); static bool deviceInfo(nvid_ctx *ctx, int32_t blocks, int32_t threads, const Algorithm &algorithm, int32_t dataset_host = -1) noexcept; static bool deviceInit(nvid_ctx *ctx) noexcept; static bool rxHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept; static bool rxPrepare(nvid_ctx *ctx, const void *dataset, size_t datasetSize, bool dataset_host, uint32_t batchSize) noexcept; - static bool AstroBWTHash(nvid_ctx *ctx, uint32_t startNonce, uint64_t target, uint32_t *rescount, uint32_t *resnonce) noexcept; - static bool AstroBWTPrepare(nvid_ctx *ctx, uint32_t batchSize) 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 *lastError(nvid_ctx *ctx) noexcept;