Skip to content

Commit a5b8fb7

Browse files
authored
Merge pull request #2392 from fireice-uk/dev
release 2.10.4
2 parents 2cd84c8 + c2618d7 commit a5b8fb7

File tree

7 files changed

+71
-47
lines changed

7 files changed

+71
-47
lines changed

xmrstak/backend/amd/minethd.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ void minethd::work_main()
172172
lck.release();
173173
std::this_thread::yield();
174174

175-
uint64_t iCount = 0;
176175
cryptonight_ctx* cpu_ctx;
177176
cpu_ctx = cpu::minethd::minethd_alloc_ctx();
178177

@@ -288,10 +287,7 @@ void minethd::work_main()
288287
executor::inst()->push_event(ex_event("AMD Invalid Result", pGpuCtx->deviceIdx, oWork.iPoolId));
289288
}
290289

291-
iCount += pGpuCtx->rawIntensity;
292-
uint64_t iStamp = get_timestamp_ms();
293-
iHashCount.store(iCount, std::memory_order_relaxed);
294-
iTimestamp.store(iStamp, std::memory_order_relaxed);
290+
updateStats(pGpuCtx->rawIntensity, oWork.iPoolId);
295291

296292
accRuntime += updateTimings(pGpuCtx, t0);
297293

xmrstak/backend/cpu/minethd.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ void minethd::multiway_work_main()
833833

834834
cryptonight_ctx* ctx[MAX_N];
835835
uint64_t iCount = 0;
836+
uint64_t iLastCount = 0;
836837
uint64_t* piHashVal[MAX_N];
837838
uint32_t* piNonce[MAX_N];
838839
uint8_t bHashOut[MAX_N * 32];
@@ -915,9 +916,8 @@ void minethd::multiway_work_main()
915916
{
916917
if((iCount++ & 0x7) == 0) //Store stats every 8*N hashes
917918
{
918-
uint64_t iStamp = get_timestamp_ms();
919-
iHashCount.store(iCount * N, std::memory_order_relaxed);
920-
iTimestamp.store(iStamp, std::memory_order_relaxed);
919+
updateStats((iCount - iLastCount) * N, oWork.iPoolId);
920+
iLastCount = iCount;
921921
}
922922

923923
nonce_ctr -= N;

xmrstak/backend/iBackend.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "xmrstak/backend/globalStates.hpp"
4+
#include "xmrstak/net/msgstruct.hpp"
45

56
#include <atomic>
67
#include <climits>
@@ -46,6 +47,29 @@ struct iBackend
4647
std::atomic<uint64_t> iTimestamp;
4748
uint32_t iThreadNo;
4849
BackendType backendType = UNKNOWN;
50+
uint64_t iLastStamp = get_timestamp_ms();
51+
double avgHashPerMsec = 0.0;
52+
53+
void updateStats(uint64_t numNewHashes, size_t poolId)
54+
{
55+
uint64_t iStamp = get_timestamp_ms();
56+
double timeDiff = static_cast<double>(iStamp - iLastStamp);
57+
iLastStamp = iStamp;
58+
59+
if(poolId == 0)
60+
{
61+
// if dev pool is active interpolate the number of shares (avoid hash rate drops)
62+
numNewHashes = static_cast<uint64_t>(avgHashPerMsec * timeDiff);
63+
}
64+
else
65+
{
66+
const double hashRatePerMs = static_cast<double>(numNewHashes) / timeDiff;
67+
constexpr double averagingBias = 0.1;
68+
avgHashPerMsec = avgHashPerMsec * (1.0 - averagingBias) + hashRatePerMs * averagingBias;
69+
}
70+
iHashCount.fetch_add(numNewHashes, std::memory_order_relaxed);
71+
iTimestamp.store(iStamp, std::memory_order_relaxed);
72+
}
4973

5074
iBackend() :
5175
iHashCount(0),

xmrstak/backend/nvidia/minethd.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ void minethd::work_main()
198198
// wait until all NVIDIA devices are initialized
199199
thread_work_guard.wait();
200200

201-
uint64_t iCount = 0;
202201
cryptonight_ctx* cpu_ctx;
203202
cpu_ctx = cpu::minethd::minethd_alloc_ctx();
204203

@@ -297,13 +296,8 @@ void minethd::work_main()
297296
executor::inst()->push_event(ex_event("NVIDIA Invalid Result", ctx.device_id, oWork.iPoolId));
298297
}
299298

300-
iCount += h_per_round;
301299
iNonce += h_per_round;
302-
303-
using namespace std::chrono;
304-
uint64_t iStamp = get_timestamp_ms();
305-
iHashCount.store(iCount, std::memory_order_relaxed);
306-
iTimestamp.store(iStamp, std::memory_order_relaxed);
300+
updateStats(h_per_round, oWork.iPoolId);
307301
std::this_thread::yield();
308302
}
309303

xmrstak/backend/nvidia/nvcc_code/cuda_cryptonight_r.curt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,10 @@ __global__ void CryptonightR_phase2(
462462
uint64_t bx0 = ((uint64_t*)(d_ctx_b + thread * 16))[sub];
463463
uint64_t bx1 = ((uint64_t*)(d_ctx_b + thread * 16 + 4))[sub];
464464

465-
uint32_t r0 = d_ctx_b[thread * 16 + 4 * 2];
466-
uint32_t r1 = d_ctx_b[thread * 16 + 4 * 2 + 1];
467-
uint32_t r2 = d_ctx_b[thread * 16 + 4 * 2 + 2];
468-
uint32_t r3 = d_ctx_b[thread * 16 + 4 * 2 + 3];
465+
volatile uint32_t r0 = d_ctx_b[thread * 16 + 4 * 2];
466+
volatile uint32_t r1 = d_ctx_b[thread * 16 + 4 * 2 + 1];
467+
volatile uint32_t r2 = d_ctx_b[thread * 16 + 4 * 2 + 2];
468+
volatile uint32_t r3 = d_ctx_b[thread * 16 + 4 * 2 + 3];
469469

470470
const int batchsize = (ITERATIONS * 2) >> ( 1 + bfactor );
471471
const int start = partidx * batchsize;

xmrstak/cli/cli-miner.cpp

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,14 @@ inline void prompt_once(bool& prompted)
195195
}
196196
}
197197

198-
void do_guided_pool_config(const bool use_simple_start)
198+
inline bool use_simple_start()
199+
{
200+
// ask this question only once
201+
static bool simple_start = read_yes_no("\nUse simple setup method? (Y/n)", "Y");
202+
return simple_start;
203+
}
204+
205+
void do_guided_pool_config()
199206
{
200207
using namespace xmrstak;
201208

@@ -261,19 +268,22 @@ void do_guided_pool_config(const bool use_simple_start)
261268
}
262269

263270
auto& rigid = params::inst().poolRigid;
264-
if(!use_simple_start && rigid.empty() && !params::inst().userSetRigid)
271+
if(rigid.empty() && !params::inst().userSetRigid)
265272
{
266-
prompt_once(prompted);
267-
268-
if(!stdin_flushed)
273+
if(!use_simple_start())
269274
{
270-
// clear everything from stdin to allow an empty rigid
271-
std::cin.clear();
272-
std::cin.ignore(INT_MAX, '\n');
273-
}
275+
prompt_once(prompted);
274276

275-
std::cout << "- Rig identifier for pool-side statistics (needs pool support). Can be empty:" << std::endl;
276-
getline(std::cin, rigid);
277+
if(!stdin_flushed)
278+
{
279+
// clear everything from stdin to allow an empty rigid
280+
std::cin.clear();
281+
std::cin.ignore(INT_MAX, '\n');
282+
}
283+
284+
std::cout << "- Rig identifier for pool-side statistics (needs pool support). Can be empty:" << std::endl;
285+
getline(std::cin, rigid);
286+
}
277287
}
278288

279289
bool tls = params::inst().poolUseTls;
@@ -289,15 +299,19 @@ void do_guided_pool_config(const bool use_simple_start)
289299
#endif
290300

291301
bool nicehash = params::inst().nicehashMode;
292-
if(!use_simple_start && !userSetPool)
302+
if(!userSetPool)
293303
{
294-
prompt_once(prompted);
295-
nicehash = read_yes_no("- Do you want to use nicehash on this pool? (y/N)", "N");
304+
if(!use_simple_start())
305+
{
306+
prompt_once(prompted);
307+
nicehash = read_yes_no("- Do you want to use nicehash on this pool? (y/N)", "N");
308+
}
296309
}
297310

298311
bool multipool = false;
299-
if(!use_simple_start && !userSetPool)
300-
multipool = read_yes_no("- Do you want to use multiple pools? (y/N)", "N");
312+
if(!userSetPool)
313+
if(!use_simple_start())
314+
multipool = read_yes_no("- Do you want to use multiple pools? (y/N)", "N");
301315

302316
int64_t pool_weight = 1;
303317
if(multipool)
@@ -335,7 +349,7 @@ void do_guided_pool_config(const bool use_simple_start)
335349
std::cout << "Pool configuration stored in file '" << params::inst().configFilePools << "'" << std::endl;
336350
}
337351

338-
void do_guided_config(const bool use_simple_start)
352+
void do_guided_config()
339353
{
340354
using namespace xmrstak;
341355

@@ -353,7 +367,7 @@ void do_guided_config(const bool use_simple_start)
353367
{
354368
http_port = params::httpd_port_disabled;
355369
#ifndef CONF_NO_HTTPD
356-
if(!use_simple_start)
370+
if(!use_simple_start())
357371
{
358372
prompt_once(prompted);
359373

@@ -737,17 +751,13 @@ int main(int argc, char* argv[])
737751
bool hasConfigFile = configEditor::file_exist(params::inst().configFile);
738752
bool hasPoolConfig = configEditor::file_exist(params::inst().configFilePools);
739753

740-
if(!hasConfigFile || !hasPoolConfig)
741-
{
742-
bool use_simple_start = read_yes_no("\nUse simple setup method? (Y/n)", "Y");
754+
// check if we need a guided start
755+
if(!hasConfigFile)
756+
do_guided_config();
743757

744-
// check if we need a guided start
745-
if(!hasConfigFile)
746-
do_guided_config(use_simple_start);
758+
if(!hasPoolConfig)
759+
do_guided_pool_config();
747760

748-
if(!hasPoolConfig)
749-
do_guided_pool_config(use_simple_start);
750-
}
751761
if(!jconf::inst()->parse_config(params::inst().configFile.c_str(), params::inst().configFilePools.c_str()))
752762
{
753763
win_exit();

xmrstak/version.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#endif
2121

2222
#define XMR_STAK_NAME "xmr-stak"
23-
#define XMR_STAK_VERSION "2.10.3"
23+
#define XMR_STAK_VERSION "2.10.4"
2424

2525
#if defined(_WIN32)
2626
#define OS_TYPE "win"

0 commit comments

Comments
 (0)