Browse Source

Various minor changes

- Fixed a type bug on 32bit platform in algo bench
	- Some re-indenting
nfactor-troky
Znort 987 13 years ago
parent
commit
39bdec8bbe
  1. 65
      main.c

65
main.c

@ -408,11 +408,13 @@ static double bench_algo_stage3(
struct timeval end; struct timeval end;
struct timeval start; struct timeval start;
uint64_t hashes_done = 0; uint32_t max_nonce = (1<<22);
uint32_t max_nonce = (1<<21); unsigned long hashes_done = 0;
gettimeofday(&start, 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) { if (ALGO_VIA==algo) {
(void)scanhash_via( (void)scanhash_via(
0, 0,
@ -749,13 +751,29 @@ static void bench_algo(
memset(name_spaces_pad, ' ', n); memset(name_spaces_pad, ' ', n);
name_spaces_pad[n] = 0; name_spaces_pad[n] = 0;
applog(LOG_ERR, "\"%s\"%s : benchmarking algorithm ...", algo_names[algo], name_spaces_pad); applog(
double rate = bench_algo_stage2(algo); LOG_ERR,
"\"%s\"%s : benchmarking algorithm ...",
algo_names[algo],
name_spaces_pad
);
double rate = bench_algo_stage2(algo);
if (rate<0.0) { 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 { } 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) { if (*best_rate<rate) {
*best_rate = rate; *best_rate = rate;
*best_algo = algo; *best_algo = algo;
@ -770,10 +788,9 @@ static void init_max_name_len()
for (i=0; i<nb_names; ++i) { for (i=0; i<nb_names; ++i) {
const char *p = algo_names[i]; const char *p = algo_names[i];
size_t name_len = p ? strlen(p) : 0; 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; max_name_len = name_len;
} }
}
name_spaces_pad = (char*) malloc(max_name_len+16); name_spaces_pad = (char*) malloc(max_name_len+16);
if (0==name_spaces_pad) { if (0==name_spaces_pad) {
@ -782,26 +799,34 @@ static void init_max_name_len()
} }
} }
// Pick the fastest CPU hasher
static enum sha256_algos pick_fastest_algo() static enum sha256_algos pick_fastest_algo()
{ {
double best_rate = -1.0; double best_rate = -1.0;
enum sha256_algos best_algo = 0; enum sha256_algos best_algo = 0;
applog(LOG_ERR, "benchmarking all sha256 algorithms ...");
bench_algo(&best_rate, &best_algo, ALGO_C); 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); bench_algo(&best_rate, &best_algo, ALGO_4WAY);
#endif #endif
#ifdef WANT_VIA_PADLOCK
#if defined(WANT_VIA_PADLOCK)
bench_algo(&best_rate, &best_algo, ALGO_VIA); bench_algo(&best_rate, &best_algo, ALGO_VIA);
#endif #endif
bench_algo(&best_rate, &best_algo, ALGO_CRYPTOPP); 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); bench_algo(&best_rate, &best_algo, ALGO_CRYPTOPP_ASM32);
#endif #endif
#ifdef WANT_X8664_SSE2
#if defined(WANT_X8664_SSE2)
bench_algo(&best_rate, &best_algo, ALGO_SSE2_64); bench_algo(&best_rate, &best_algo, ALGO_SSE2_64);
#endif #endif
#ifdef WANT_X8664_SSE4
#if defined(WANT_X8664_SSE4)
bench_algo(&best_rate, &best_algo, ALGO_SSE4_64); bench_algo(&best_rate, &best_algo, ALGO_SSE4_64);
#endif #endif
@ -815,7 +840,6 @@ static enum sha256_algos pick_fastest_algo()
name_spaces_pad, name_spaces_pad,
best_rate best_rate
); );
return best_algo; return best_algo;
} }
@ -1088,17 +1112,20 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--scan-time|-s", OPT_WITH_ARG("--scan-time|-s",
set_int_0_to_9999, opt_show_intval, &opt_scantime, set_int_0_to_9999, opt_show_intval, &opt_scantime,
"Upper bound on time spent scanning current work, in seconds"), "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 #ifdef HAVE_SYSLOG_H
OPT_WITHOUT_ARG("--syslog", OPT_WITHOUT_ARG("--syslog",
opt_set_bool, &use_syslog, opt_set_bool, &use_syslog,
"Use system log for output messages (default: standard error)"), "Use system log for output messages (default: standard error)"),
#endif #endif
#if !defined(WIN32) #if defined(unix)
OPT_WITH_ARG("--monitor|-m", OPT_WITH_ARG("--monitor|-m",
opt_set_charp, NULL, &opt_stderr_cmd, opt_set_charp, NULL, &opt_stderr_cmd,
"Use custom pipe cmd for output messages"), "Use custom pipe cmd for output messages"),
#endif // !WIN32 #endif // defined(unix)
OPT_WITHOUT_ARG("--text-only|-T", OPT_WITHOUT_ARG("--text-only|-T",
opt_set_invbool, &use_curses, opt_set_invbool, &use_curses,
@ -4558,10 +4585,10 @@ int main (int argc, char *argv[])
openlog(PROGRAM_NAME, LOG_PID, LOG_USER); openlog(PROGRAM_NAME, LOG_PID, LOG_USER);
#endif #endif
#if !defined(WIN32) #if defined(unix)
if (opt_stderr_cmd) if (opt_stderr_cmd)
fork_monitor(); fork_monitor();
#endif // !WIN32 #endif // defined(unix)
mining_threads = opt_n_threads + gpu_threads; mining_threads = opt_n_threads + gpu_threads;

Loading…
Cancel
Save