Skip to content

Commit

Permalink
fix output of khash/s and increase hashes_done size
Browse files Browse the repository at this point in the history
Signed-off-by: Tanguy Pruvot <[email protected]>
  • Loading branch information
tpruvot committed Aug 2, 2014
1 parent c6427bc commit a873736
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion blake.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void blakehash(void *state, const void *input)
}

int scanhash_blake(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
Expand Down
14 changes: 7 additions & 7 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ static void *miner_thread(void *userdata) {
uint32_t *nonceptr = (uint32_t*) (((char*)work.data) + (jsonrpc_2 ? 39 : 76));

while (1) {
unsigned long hashes_done;
uint64_t hashes_done;
struct timeval tv_start, tv_end, diff;
int64_t max64;
int rc;
Expand Down Expand Up @@ -1185,12 +1185,12 @@ static void *miner_thread(void *userdata) {
}

/* record scanhash elapsed time */
gettimeofday(&tv_end, NULL );
gettimeofday(&tv_end, NULL);
timeval_subtract(&diff, &tv_end, &tv_start);
if (diff.tv_usec || diff.tv_sec) {
pthread_mutex_lock(&stats_lock);
thr_hashrates[thr_id] = hashes_done
/ (diff.tv_sec + 1e-6 * diff.tv_usec);
thr_hashrates[thr_id] =
hashes_done / (diff.tv_sec + diff.tv_usec * 1e-6);
pthread_mutex_unlock(&stats_lock);
}
if (!opt_quiet) {
Expand All @@ -1201,8 +1201,8 @@ static void *miner_thread(void *userdata) {
break;
default:
sprintf(s, thr_hashrates[thr_id] >= 1e6 ? "%.0f" : "%.2f",
1e-3 * thr_hashrates[thr_id]);
applog(LOG_INFO, "thread %d: %lu hashes, %.2f khash/s", thr_id,
thr_hashrates[thr_id] / 1e3);
applog(LOG_INFO, "thread %d: %llu hashes, %s khash/s", thr_id,
hashes_done, s);
break;
}
Expand All @@ -1217,7 +1217,7 @@ static void *miner_thread(void *userdata) {
applog(LOG_INFO, "Total: %s H/s", hashrate);
break;
default:
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate);
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", hashrate / 1000);
applog(LOG_INFO, "Total: %s khash/s", s);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion cryptonight.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void cryptonight_hash_ctx_aes_ni(void* output, const void* input, size_t len, st
}

int scanhash_cryptonight(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done) {
uint32_t max_nonce, uint64_t *hashes_done) {
uint32_t *nonceptr = (uint32_t*) (((char*)pdata) + 39);
uint32_t n = *nonceptr - 1;
const uint32_t first_nonce = n + 1;
Expand Down
2 changes: 1 addition & 1 deletion heavy.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void heavycoin_hash(unsigned char* output, const unsigned char* input, int len)
}

int scanhash_heavy(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t hash[8];
uint32_t start_nonce = pdata[19];
Expand Down
2 changes: 1 addition & 1 deletion ink.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void inkhash(void *state, const void *input)
}

int scanhash_ink(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
Expand Down
2 changes: 1 addition & 1 deletion keccak.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static void keccakhash(void *state, const void *input)
}

int scanhash_keccak(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
Expand Down
26 changes: 13 additions & 13 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,43 +149,43 @@ void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
#endif
#endif

extern int scanhash_sha256d(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_sha256d(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, uint64_t *hashes_done);

extern unsigned char *scrypt_buffer_alloc(int N);
extern int scanhash_scrypt(int thr_id, uint32_t *pdata,
unsigned char *scratchbuf, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, int N);
unsigned char *scratchbuf, const uint32_t *ptarget,
uint32_t max_nonce, uint64_t *hashes_done, int N);

extern int scanhash_keccak(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done);
extern int scanhash_keccak(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, uint64_t *hashes_done);

extern int scanhash_heavy(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done);
uint32_t max_nonce, uint64_t *hashes_done);

extern int scanhash_quark(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done);
uint32_t max_nonce, uint64_t *hashes_done);

extern void init_quarkhash_contexts();

extern int scanhash_skein(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done);
uint32_t max_nonce, uint64_t *hashes_done);

extern int scanhash_ink(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done);
uint32_t max_nonce, uint64_t *hashes_done);

extern void init_blakehash_contexts();

extern int scanhash_blake(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done);
uint32_t max_nonce, uint64_t *hashes_done);

extern int scanhash_x11(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done);
uint32_t max_nonce, uint64_t *hashes_done);

extern void cryptonight_hash(void* output, const void* input, size_t input_len);

extern int scanhash_cryptonight(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done);
uint32_t max_nonce, uint64_t *hashes_done);

struct thr_info {
int id;
Expand Down
2 changes: 1 addition & 1 deletion quark.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static void quarkhash(void *state, const void *input)
}

int scanhash_quark(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
Expand Down
2 changes: 1 addition & 1 deletion scrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ static void scrypt_1024_1_1_256_24way(const uint32_t *input,

int scanhash_scrypt(int thr_id, uint32_t *pdata,
unsigned char *scratchbuf, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, int N)
uint32_t max_nonce, uint64_t *hashes_done, int N)
{
uint32_t data[SCRYPT_MAX_WAYS * 20], hash[SCRYPT_MAX_WAYS * 8];
uint32_t midstate[8];
Expand Down
6 changes: 3 additions & 3 deletions sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void sha256d_ms_4way(uint32_t *hash, uint32_t *data,
const uint32_t *midstate, const uint32_t *prehash);

static inline int scanhash_sha256d_4way(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done)
const uint32_t *ptarget, uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t data[4 * 64] __attribute__((aligned(128)));
uint32_t hash[4 * 8] __attribute__((aligned(32)));
Expand Down Expand Up @@ -528,7 +528,7 @@ void sha256d_ms_8way(uint32_t *hash, uint32_t *data,
const uint32_t *midstate, const uint32_t *prehash);

static inline int scanhash_sha256d_8way(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done)
const uint32_t *ptarget, uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t data[8 * 64] __attribute__((aligned(128)));
uint32_t hash[8 * 8] __attribute__((aligned(32)));
Expand Down Expand Up @@ -582,7 +582,7 @@ static inline int scanhash_sha256d_8way(int thr_id, uint32_t *pdata,
#endif /* HAVE_SHA256_8WAY */

int scanhash_sha256d(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t data[64] __attribute__((aligned(128)));
uint32_t hash[8] __attribute__((aligned(32)));
Expand Down
2 changes: 1 addition & 1 deletion skein.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void skeinhash(void *state, const void *input)
}

int scanhash_skein(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
Expand Down
2 changes: 1 addition & 1 deletion x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void x11_hash(char* output, const char* input)
}

int scanhash_x11(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done)
uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
Expand Down

0 comments on commit a873736

Please sign in to comment.