diff --git a/Makefile.am b/Makefile.am
index 1bc4663..3a3caa2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,7 @@ ccminer_SOURCES = elist.h miner.h compat.h \
compat/inttypes.h compat/stdbool.h compat/unistd.h \
compat/sys/time.h compat/getopt/getopt.h \
cpu-miner.c util.c crc32.c hefty1.c scrypt.c \
- hashlog.cpp \
+ hashlog.cpp stats.cpp cuda.cu \
heavy/heavy.cu \
heavy/cuda_blake512.cu heavy/cuda_blake512.h \
heavy/cuda_combine.cu heavy/cuda_combine.h \
diff --git a/README.txt b/README.txt
index bea7d7c..caac95d 100644
--- a/README.txt
+++ b/README.txt
@@ -155,6 +155,7 @@ features.
>>> RELEASE HISTORY <<<
Nov. 11th 2014 v1.4.7
+ Average hashrate (based on the 50 last scans)
Rewrite blake algo
Add the -i (gpu threads/intensity parameter)
Add some X11 optimisations based on sp_ commits
diff --git a/ccminer.vcxproj b/ccminer.vcxproj
index 8eb0499..554b88f 100644
--- a/ccminer.vcxproj
+++ b/ccminer.vcxproj
@@ -239,6 +239,7 @@
+
@@ -317,6 +318,7 @@
+
true
@@ -599,4 +601,4 @@
-
\ No newline at end of file
+
diff --git a/ccminer.vcxproj.filters b/ccminer.vcxproj.filters
index 334ca64..95543a5 100644
--- a/ccminer.vcxproj.filters
+++ b/ccminer.vcxproj.filters
@@ -189,6 +189,9 @@
Source Files
+
+ Source Files
+
@@ -307,6 +310,9 @@
+
+ Source Files\CUDA
+
Source Files\CUDA
@@ -473,4 +479,4 @@
Source Files\CUDA\x11
-
\ No newline at end of file
+
diff --git a/cpu-miner.c b/cpu-miner.c
index 8d3f632..e4c6d1a 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -391,11 +391,20 @@ static struct work _ALIGN(64) g_work;
static time_t g_work_time;
static pthread_mutex_t g_work_lock;
-
+/**
+ * Exit app
+ */
void proper_exit(int reason)
{
cuda_devicereset();
+
hashlog_purge_all();
+ stats_purge_all();
+
+#ifdef WIN32
+ timeEndPeriod(1); // else never executed
+#endif
+
exit(reason);
}
@@ -487,12 +496,14 @@ static void calc_diff(struct work *work, int known)
static int share_result(int result, const char *reason)
{
char s[345];
- double hashrate;
+ double hashrate = 0.;
- hashrate = 0.;
pthread_mutex_lock(&stats_lock);
- for (int i = 0; i < opt_n_threads; i++)
- hashrate += thr_hashrates[i];
+ hashrate = stats_get_speed(-1);
+ if (hashrate == 0.) {
+ for (int i = 0; i < opt_n_threads; i++)
+ hashrate += thr_hashrates[i];
+ }
result ? accepted_count++ : rejected_count++;
pthread_mutex_unlock(&stats_lock);
@@ -1297,6 +1308,7 @@ continue_scan:
thr_hashrates[thr_id] = hashes_done / (diff.tv_sec + 1e-6 * diff.tv_usec);
if (rc > 1)
thr_hashrates[thr_id] = (rc * hashes_done) / (diff.tv_sec + 1e-6 * diff.tv_usec);
+ stats_remember_speed(thr_id, hashes_done, thr_hashrates[thr_id]);
}
pthread_mutex_unlock(&stats_lock);
}
@@ -1307,15 +1319,18 @@ continue_scan:
device_map[thr_id], device_name[device_map[thr_id]], s);
}
if (thr_id == opt_n_threads - 1) {
- double hashrate = 0.;
- for (int i = 0; i < opt_n_threads && thr_hashrates[i]; i++)
- hashrate += thr_hashrates[i];
-
- global_hashrate = llround(hashrate);
+ double hashrate = stats_get_speed(-1);
+ if (hashrate == 0.) {
+ for (int i = 0; i < opt_n_threads && thr_hashrates[i]; i++)
+ hashrate += thr_hashrates[i];
+ }
if (opt_benchmark) {
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", hashrate / 1000.);
applog(LOG_NOTICE, "Total: %s kH/s", s);
}
+
+ // X-Mining-Hashrate
+ global_hashrate = llround(hashrate);
}
if (rc) {
@@ -1520,6 +1535,7 @@ static void *stratum_thread(void *userdata)
stratum.bloc_height);
restart_threads();
hashlog_purge_old();
+ stats_purge_old();
} else if (opt_debug && !opt_quiet) {
applog(LOG_BLUE, "%s asks job %d for block %d", short_url,
strtoul(stratum.job.job_id, NULL, 16), stratum.bloc_height);
@@ -2096,5 +2112,7 @@ int main(int argc, char *argv[])
applog(LOG_INFO, "workio thread dead, exiting.");
+ proper_exit(0);
+
return 0;
}
diff --git a/cuda.cu b/cuda.cu
new file mode 100644
index 0000000..3758335
--- /dev/null
+++ b/cuda.cu
@@ -0,0 +1,141 @@
+#include
+#include
+#include
+
+#include