From 854963e51e119942ca5c5a4c021fdda18cd5d4ab Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 27 Aug 2017 05:49:53 +0300 Subject: [PATCH] Added AEON support [2/2]. --- src/config.json | 1 + src/workers/CudaWorker.cpp | 12 ++++++++++-- src/workers/CudaWorker.h | 1 + src/workers/Handle.cpp | 3 ++- src/workers/Handle.h | 4 +++- src/workers/Workers.cpp | 2 +- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/config.json b/src/config.json index 36c385f..3fea9f4 100644 --- a/src/config.json +++ b/src/config.json @@ -1,4 +1,5 @@ { + "algo": "cryptonight", "background": false, "colors": true, "donate-level": 5, diff --git a/src/workers/CudaWorker.cpp b/src/workers/CudaWorker.cpp index 046fe9e..3f44ada 100644 --- a/src/workers/CudaWorker.cpp +++ b/src/workers/CudaWorker.cpp @@ -33,6 +33,7 @@ CudaWorker::CudaWorker(Handle *handle) : + m_lite(handle->isLite()), m_id(handle->threadId()), m_threads(handle->threads()), m_hashCount(0), @@ -52,7 +53,7 @@ CudaWorker::CudaWorker(Handle *handle) : void CudaWorker::start() { - if (cuda_get_deviceinfo(&m_ctx) != 1 || cryptonight_gpu_init(&m_ctx) != 1) { + if (cuda_get_deviceinfo(&m_ctx) != 1 || (m_lite ? cryptonight_gpu_init_lite(&m_ctx) : cryptonight_gpu_init(&m_ctx)) != 1) { printf("Setup failed for GPU %d. Exitting.\n", (int) m_id); return; } @@ -78,7 +79,14 @@ void CudaWorker::start() uint32_t foundCount; cryptonight_extra_cpu_prepare(&m_ctx, m_nonce); - cryptonight_gpu_hash(&m_ctx); + + if (m_lite) { + cryptonight_gpu_hash_lite(&m_ctx); + } + else { + cryptonight_gpu_hash(&m_ctx); + } + cryptonight_extra_cpu_final(&m_ctx, m_nonce, m_job.target(), &foundCount, foundNonce); for (size_t i = 0; i < foundCount; i++) { diff --git a/src/workers/CudaWorker.h b/src/workers/CudaWorker.h index 179b8e2..31f0a68 100644 --- a/src/workers/CudaWorker.h +++ b/src/workers/CudaWorker.h @@ -53,6 +53,7 @@ private: void save(const Job &job); void storeStats(); + bool m_lite; const int m_id; const int m_threads; Job m_job; diff --git a/src/workers/Handle.cpp b/src/workers/Handle.cpp index f2c7efa..a2b26ce 100644 --- a/src/workers/Handle.cpp +++ b/src/workers/Handle.cpp @@ -25,7 +25,8 @@ #include "workers/Handle.h" -Handle::Handle(int threadId, GpuThread *thread, int threads) : +Handle::Handle(int threadId, GpuThread *thread, int threads, bool lite) : + m_lite(lite), m_threadId(threadId), m_gpuThread(thread), m_threads(threads), diff --git a/src/workers/Handle.h b/src/workers/Handle.h index 1ebfc0a..0a32048 100644 --- a/src/workers/Handle.h +++ b/src/workers/Handle.h @@ -36,10 +36,11 @@ class GpuThread; class Handle { public: - Handle(int threadId, GpuThread *thread, int threads); + Handle(int threadId, GpuThread *thread, int threads, bool lite); void join(); void start(void (*callback) (void *)); + inline bool isLite() const { return m_lite; } inline const GpuThread *gpuThread() const { return m_gpuThread; } inline int threadId() const { return m_threadId; } inline int threads() const { return m_threads; } @@ -47,6 +48,7 @@ public: inline void setWorker(IWorker *worker) { m_worker = worker; } private: + bool m_lite; const int m_threadId; const GpuThread *m_gpuThread; const int m_threads; diff --git a/src/workers/Workers.cpp b/src/workers/Workers.cpp index e6fcac7..810a6c4 100644 --- a/src/workers/Workers.cpp +++ b/src/workers/Workers.cpp @@ -166,7 +166,7 @@ void Workers::start(const std::vector &threads) uv_timer_start(&m_timer, Workers::onTick, 500, 500); for (size_t i = 0; i < count; ++i) { - Handle *handle = new Handle((int) i, threads[i], (int) count); + Handle *handle = new Handle((int) i, threads[i], (int) count, Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE); m_workers.push_back(handle); handle->start(Workers::onReady); }