From 65cd430d7687f4769d1bb6f507e428638c82ea06 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Mon, 26 Sep 2016 23:53:56 +0200 Subject: [PATCH] cuda: throughput2intensity function to show default --- cuda.cpp | 15 +++++++++++++++ lbry/lbry.cu | 1 + miner.h | 1 + 3 files changed, 17 insertions(+) diff --git a/cuda.cpp b/cuda.cpp index 4575214..1a6f852 100644 --- a/cuda.cpp +++ b/cuda.cpp @@ -172,6 +172,21 @@ uint32_t cuda_default_throughput(int thr_id, uint32_t defcount) return throughput; } +// since 1.8.3 +double throughput2intensity(uint32_t throughput) +{ + double intensity = 0.; + uint32_t ws = throughput; + uint8_t i = 0; + while (ws > 1 && i++ < 32) + ws = ws >> 1; + intensity = (double) i; + if (i && ((1U << i) < throughput)) { + intensity += ((double) (throughput-(1U << i)) / (1U << i)); + } + return intensity; +} + // if we use 2 threads on the same gpu, we need to reinit the threads void cuda_reset_device(int thr_id, bool *init) { diff --git a/lbry/lbry.cu b/lbry/lbry.cu index 3ca21f1..6aaeb15 100644 --- a/lbry/lbry.cu +++ b/lbry/lbry.cu @@ -116,6 +116,7 @@ extern "C" int scanhash_lbry(int thr_id, struct work *work, uint32_t max_nonce, cudaDeviceSetCacheConfig(cudaFuncCachePreferL1); CUDA_LOG_ERROR(); } + gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput); if(device_sm[dev_id] <= 500) CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 8 * sizeof(uint64_t) * throughput)); diff --git a/miner.h b/miner.h index 5886a2d..2b0ca15 100644 --- a/miner.h +++ b/miner.h @@ -513,6 +513,7 @@ int cuda_available_memory(int thr_id); uint32_t cuda_default_throughput(int thr_id, uint32_t defcount); #define device_intensity(t,f,d) cuda_default_throughput(t,d) +double throughput2intensity(uint32_t throughput); void cuda_log_lasterror(int thr_id, const char* func, int line); void cuda_clear_lasterror();