Skip to content

Commit

Permalink
Titan: different hardware diff for different N
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Demianets committed Dec 4, 2014
1 parent e561ca0 commit f51d12e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
40 changes: 33 additions & 7 deletions driver-titan.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,34 @@

/* Specify here minimum number of leading zeroes in hash */
#define DEFAULT_DIFF_FILTERING_ZEROES 24
#define DEFAULT_DIFF_FILTERING_FLOAT (1. / ((double)(0x00000000FFFFFFFF >> DEFAULT_DIFF_FILTERING_ZEROES)))
#define DEFAULT_DIFF_HASHES_PER_NONCE (1 << DEFAULT_DIFF_FILTERING_ZEROES)
static inline uint32_t get_diff_filtering_zeroes(uint32_t Nfactor)
{
switch (Nfactor) {
case 10:
default:
return DEFAULT_DIFF_FILTERING_ZEROES;
case 11:
return 22;
case 12:
return 20;
case 13:
return 18;
case 14:
return 17;
case 15:
return 15;
case 16:
return 13;
case 17:
return 11;
case 18:
return 9;
case 19:
return 7;
}
}
#define DIFF_FILTERING_FLOAT(Nfactor) (1. / ((double)(0x00000000FFFFFFFF >> get_diff_filtering_zeroes(Nfactor))))
#define DIFF_HASHES_PER_NONCE(Nfactor) (1 << get_diff_filtering_zeroes(Nfactor))

BFG_REGISTER_DRIVER(knc_titan_drv)

Expand Down Expand Up @@ -336,7 +362,7 @@ static bool configure_one_die(struct knc_titan_info *knc, int asic, int die)
struct titan_setup_core_params setup_params = {
.bad_address_mask = {0, 0},
.bad_address_match = {0x3FF, 0x3FF},
.difficulty = DEFAULT_DIFF_FILTERING_ZEROES - 1,
.difficulty = get_diff_filtering_zeroes(opt_scrypt_Nfactor) - 1,
.thread_enable = 0xFF,
.thread_base_address = {0, 1, 2, 3, 4, 5, 6, 7},
.lookup_gap_mask = {0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7},
Expand Down Expand Up @@ -368,7 +394,7 @@ static bool configure_one_die(struct knc_titan_info *knc, int asic, int die)
static
float titan_min_nonce_diff(struct cgpu_info * const proc, const struct mining_algorithm * const malgo)
{
return (malgo->algo == POW_SCRYPT) ? DEFAULT_DIFF_FILTERING_FLOAT : -1.;
return (malgo->algo == POW_SCRYPT) ? DIFF_FILTERING_FLOAT(opt_scrypt_Nfactor) : -1.;
}

static bool knc_titan_init(struct thr_info * const thr)
Expand Down Expand Up @@ -510,7 +536,7 @@ static bool die_reconfigure(struct knc_titan_info * const knc, int asic, int die

static bool knc_titan_prepare_work(struct thr_info *thr, struct work *work)
{
work->nonce_diff = DEFAULT_DIFF_FILTERING_FLOAT;
work->nonce_diff = DIFF_FILTERING_FLOAT(opt_scrypt_Nfactor);
return true;
}

Expand Down Expand Up @@ -620,8 +646,8 @@ static bool knc_titan_process_report(struct knc_titan_info * const knc, struct k
continue;
}
if (submit_nonce(proc->thr[0], work, report->nonce[i].nonce)) {
hashes_done2(proc->thr[0], DEFAULT_DIFF_HASHES_PER_NONCE, NULL);
knc_titan_die_hashmeter(knccore->die, DEFAULT_DIFF_HASHES_PER_NONCE);
hashes_done2(proc->thr[0], DIFF_HASHES_PER_NONCE(opt_scrypt_Nfactor), NULL);
knc_titan_die_hashmeter(knccore->die, DIFF_HASHES_PER_NONCE(opt_scrypt_Nfactor));
knccore->hwerr_in_row = 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion knc-asic
Submodule knc-asic updated 1 files
+1 −1 knc-asic.h

0 comments on commit f51d12e

Please sign in to comment.