Various minor changes - Fixed a type bug on 32bit platform in algo bench - Some re-indenting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
diff --git a/main.c b/main.c
index 35657f7..be0d8b3 100644
--- a/main.c
+++ b/main.c
@@ -408,11 +408,13 @@ static double bench_algo_stage3(
struct timeval end;
struct timeval start;
- uint64_t hashes_done = 0;
- uint32_t max_nonce = (1<<21);
+ uint32_t max_nonce = (1<<22);
+ unsigned long hashes_done = 0;
gettimeofday(&start, 0);
- #ifdef WANT_VIA_PADLOCK
+ #if defined(WANT_VIA_PADLOCK)
+
+ // For some reason, the VIA padlock hasher has a different API ...
if (ALGO_VIA==algo) {
(void)scanhash_via(
0,
@@ -424,20 +426,20 @@ static double bench_algo_stage3(
);
} else
#endif
- {
- sha256_func func = sha256_funcs[algo];
- (*func)(
- 0,
- work.midstate,
- work.data + 64,
- work.hash1,
- work.hash,
- work.target,
- max_nonce,
- &hashes_done,
- work.blk.nonce
- );
- }
+ {
+ sha256_func func = sha256_funcs[algo];
+ (*func)(
+ 0,
+ work.midstate,
+ work.data + 64,
+ work.hash1,
+ work.hash,
+ work.target,
+ max_nonce,
+ &hashes_done,
+ work.blk.nonce
+ );
+ }
gettimeofday(&end, 0);
work_restart = NULL;
@@ -749,13 +751,29 @@ static void bench_algo(
memset(name_spaces_pad, ' ', n);
name_spaces_pad[n] = 0;
- applog(LOG_ERR, "\"%s\"%s : benchmarking algorithm ...", algo_names[algo], name_spaces_pad);
- double rate = bench_algo_stage2(algo);
+ applog(
+ LOG_ERR,
+ "\"%s\"%s : benchmarking algorithm ...",
+ algo_names[algo],
+ name_spaces_pad
+ );
+ double rate = bench_algo_stage2(algo);
if (rate<0.0) {
- applog(LOG_ERR, "\"%s\"%s : algorithm fails on this platform", algo_names[algo], name_spaces_pad);
+ applog(
+ LOG_ERR,
+ "\"%s\"%s : algorithm fails on this platform",
+ algo_names[algo],
+ name_spaces_pad
+ );
} else {
- applog(LOG_ERR, "\"%s\"%s : algorithm runs at %.5f MH/s", algo_names[algo], name_spaces_pad, rate);
+ applog(
+ LOG_ERR,
+ "\"%s\"%s : algorithm runs at %.5f MH/s",
+ algo_names[algo],
+ name_spaces_pad,
+ rate
+ );
if (*best_rate<rate) {
*best_rate = rate;
*best_algo = algo;
@@ -770,9 +788,8 @@ static void init_max_name_len()
for (i=0; i<nb_names; ++i) {
const char *p = algo_names[i];
size_t name_len = p ? strlen(p) : 0;
- if (max_name_len<name_len) {
+ if (max_name_len<name_len)
max_name_len = name_len;
- }
}
name_spaces_pad = (char*) malloc(max_name_len+16);
@@ -782,26 +799,34 @@ static void init_max_name_len()
}
}
+// Pick the fastest CPU hasher
static enum sha256_algos pick_fastest_algo()
{
double best_rate = -1.0;
enum sha256_algos best_algo = 0;
+ applog(LOG_ERR, "benchmarking all sha256 algorithms ...");
bench_algo(&best_rate, &best_algo, ALGO_C);
- #ifdef WANT_SSE2_4WAY
+
+ #if defined(WANT_SSE2_4WAY)
bench_algo(&best_rate, &best_algo, ALGO_4WAY);
#endif
- #ifdef WANT_VIA_PADLOCK
+
+ #if defined(WANT_VIA_PADLOCK)
bench_algo(&best_rate, &best_algo, ALGO_VIA);
#endif
+
bench_algo(&best_rate, &best_algo, ALGO_CRYPTOPP);
- #ifdef WANT_CRYPTOPP_ASM32
+
+ #if defined(WANT_CRYPTOPP_ASM32)
bench_algo(&best_rate, &best_algo, ALGO_CRYPTOPP_ASM32);
#endif
- #ifdef WANT_X8664_SSE2
+
+ #if defined(WANT_X8664_SSE2)
bench_algo(&best_rate, &best_algo, ALGO_SSE2_64);
#endif
- #ifdef WANT_X8664_SSE4
+
+ #if defined(WANT_X8664_SSE4)
bench_algo(&best_rate, &best_algo, ALGO_SSE4_64);
#endif
@@ -815,7 +840,6 @@ static enum sha256_algos pick_fastest_algo()
name_spaces_pad,
best_rate
);
-
return best_algo;
}
@@ -1088,17 +1112,20 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--scan-time|-s",
set_int_0_to_9999, opt_show_intval, &opt_scantime,
"Upper bound on time spent scanning current work, in seconds"),
+ OPT_WITH_ARG("--bench-algo|-b",
+ set_int_0_to_9999, opt_show_intval, &opt_bench_algo,
+ opt_hidden),
#ifdef HAVE_SYSLOG_H
OPT_WITHOUT_ARG("--syslog",
opt_set_bool, &use_syslog,
"Use system log for output messages (default: standard error)"),
#endif
-#if !defined(WIN32)
+#if defined(unix)
OPT_WITH_ARG("--monitor|-m",
opt_set_charp, NULL, &opt_stderr_cmd,
"Use custom pipe cmd for output messages"),
-#endif // !WIN32
+#endif // defined(unix)
OPT_WITHOUT_ARG("--text-only|-T",
opt_set_invbool, &use_curses,
@@ -4558,10 +4585,10 @@ int main (int argc, char *argv[])
openlog(PROGRAM_NAME, LOG_PID, LOG_USER);
#endif
-#if !defined(WIN32)
- if (opt_stderr_cmd)
- fork_monitor();
-#endif // !WIN32
+ #if defined(unix)
+ if (opt_stderr_cmd)
+ fork_monitor();
+ #endif // defined(unix)
mining_threads = opt_n_threads + gpu_threads;