Browse Source

Get rid of several opt_scrypt checks.

--scrypt will eventually become a default, and is the only reason to use this
version of cgminer.
nfactor-troky
Noel Maersk 11 years ago
parent
commit
37cd3fb04c
  1. 34
      cgminer.c
  2. 33
      driver-opencl.c
  3. 4
      findnonce.c

34
cgminer.c

@ -2869,8 +2869,8 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit) @@ -2869,8 +2869,8 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
snprintf(worktime, sizeof(worktime),
" <-%08lx.%08lx M:%c D:%1.*f G:%02d:%02d:%02d:%1.3f %s (%1.3f) W:%1.3f (%1.3f) S:%1.3f R:%02d:%02d:%02d",
(unsigned long)be32toh(*(uint32_t *)&(work->data[opt_scrypt ? 32 : 28])),
(unsigned long)be32toh(*(uint32_t *)&(work->data[opt_scrypt ? 28 : 24])),
(unsigned long)be32toh(*(uint32_t *)&(work->data[32])),
(unsigned long)be32toh(*(uint32_t *)&(work->data[28])),
work->getwork_mode, diffplaces, work->work_difficulty,
tm_getwork.tm_hour, tm_getwork.tm_min,
tm_getwork.tm_sec, getwork_time, workclone,
@ -3127,9 +3127,7 @@ static void calc_diff(struct work *work, double known) @@ -3127,9 +3127,7 @@ static void calc_diff(struct work *work, double known)
else {
double d64, dcut64;
d64 = truediffone;
if (opt_scrypt)
d64 *= (double)65536;
d64 = (double)65536 * truediffone;
dcut64 = le256todouble(work->target);
if (unlikely(!dcut64))
dcut64 = 1;
@ -3763,9 +3761,7 @@ static uint64_t share_diff(const struct work *work) @@ -3763,9 +3761,7 @@ static uint64_t share_diff(const struct work *work)
double d64, s64;
uint64_t ret;
d64 = truediffone;
if (opt_scrypt)
d64 *= (double)65536;
d64 = (double)65536 * truediffone;
s64 = le256todouble(work->hash);
if (unlikely(!s64))
s64 = 0;
@ -3788,6 +3784,7 @@ static uint64_t share_diff(const struct work *work) @@ -3788,6 +3784,7 @@ static uint64_t share_diff(const struct work *work)
return ret;
}
// FIXME: not used?
static void regen_hash(struct work *work)
{
uint32_t *data32 = (uint32_t *)(work->data);
@ -3800,12 +3797,10 @@ static void regen_hash(struct work *work) @@ -3800,12 +3797,10 @@ static void regen_hash(struct work *work)
sha256(hash1, 32, (unsigned char *)(work->hash));
}
// FIXME: just call scrypt_regenhash where needed
static void rebuild_hash(struct work *work)
{
if (opt_scrypt)
scrypt_regenhash(work);
else
regen_hash(work);
scrypt_regenhash(work);
}
static bool cnx_needed(struct pool *pool);
@ -6001,9 +5996,7 @@ void set_target(unsigned char *dest_target, double diff) @@ -6001,9 +5996,7 @@ void set_target(unsigned char *dest_target, double diff)
diff = 1.0;
}
d64 = truediffone;
if (opt_scrypt)
d64 *= (double)65536;
d64 = (double)65536 * truediffone;
d64 /= diff;
dcut64 = d64 / bits192;
@ -6214,7 +6207,7 @@ bool test_nonce(struct work *work, uint32_t nonce) @@ -6214,7 +6207,7 @@ bool test_nonce(struct work *work, uint32_t nonce)
uint32_t diff1targ;
rebuild_nonce(work, nonce);
diff1targ = opt_scrypt ? 0x0000ffffUL : 0;
diff1targ = 0x0000ffffUL;
return (le32toh(*hash_32) <= diff1targ);
}
@ -6225,7 +6218,7 @@ bool test_nonce_diff(struct work *work, uint32_t nonce, double diff) @@ -6225,7 +6218,7 @@ bool test_nonce_diff(struct work *work, uint32_t nonce, double diff)
uint64_t *hash64 = (uint64_t *)(work->hash + 24), diff64;
rebuild_nonce(work, nonce);
diff64 = opt_scrypt ? 0x0000ffff00000000ULL : 0x00000000ffff0000ULL;
diff64 = 0x0000ffff00000000ULL;
diff64 /= diff;
return (le64toh(*hash64) <= diff64);
@ -6237,8 +6230,7 @@ static void update_work_stats(struct thr_info *thr, struct work *work) @@ -6237,8 +6230,7 @@ static void update_work_stats(struct thr_info *thr, struct work *work)
work->share_diff = share_diff(work);
if (opt_scrypt)
test_diff *= 65536;
test_diff *= 65536;
if (unlikely(work->share_diff >= test_diff)) {
work->block = true;
@ -8162,9 +8154,9 @@ int main(int argc, char *argv[]) @@ -8162,9 +8154,9 @@ int main(int argc, char *argv[])
if (want_per_device_stats)
opt_log_output = true;
/* Use a shorter scantime for scrypt */
/* Use a shorter scantime for scrypt (SHA256d had 60) */
if (opt_scantime < 0)
opt_scantime = opt_scrypt ? 30 : 60;
opt_scantime = 30;
total_control_threads = 9;
control_thr = calloc(total_control_threads, sizeof(*thr));

33
driver-opencl.c

@ -221,8 +221,8 @@ char *set_kernel(char *arg) @@ -221,8 +221,8 @@ char *set_kernel(char *arg)
int i, device = 0;
char *nextptr;
if (opt_scrypt)
return "Cannot specify a kernel with scrypt";
// FIXME: executes always (add more kernels!)
return "Cannot specify a kernel with scrypt";
nextptr = strtok(arg, ",");
if (nextptr == NULL)
return "Invalid parameters for set kernel";
@ -1096,7 +1096,7 @@ static void set_threads_hashes(unsigned int vectors,int64_t *hashes, size_t *glo @@ -1096,7 +1096,7 @@ static void set_threads_hashes(unsigned int vectors,int64_t *hashes, size_t *glo
unsigned int threads = 0;
while (threads < minthreads) {
threads = 1 << ((opt_scrypt ? 0 : 15) + *intensity);
threads = 1 << *intensity;
if (threads < minthreads) {
if (likely(*intensity < MAX_INTENSITY))
(*intensity)++;
@ -1242,17 +1242,11 @@ static void opencl_detect(bool hotplug) @@ -1242,17 +1242,11 @@ static void opencl_detect(bool hotplug)
if (!nDevs)
return;
/* If opt_g_threads is not set, use default 1 thread on scrypt and
* 2 for regular mining */
if (opt_g_threads == -1) {
if (opt_scrypt)
opt_g_threads = 1;
else
opt_g_threads = 2;
}
/* If opt_g_threads is not set, use default 1 thread */
if (opt_g_threads == -1)
opt_g_threads = 1;
if (opt_scrypt)
opencl_drv.max_diff = 65536;
opencl_drv.max_diff = 65536;
for (i = 0; i < nDevs; ++i) {
struct cgpu_info *cgpu;
@ -1322,7 +1316,7 @@ static bool opencl_thread_prepare(struct thr_info *thr) @@ -1322,7 +1316,7 @@ static bool opencl_thread_prepare(struct thr_info *thr)
int virtual_gpu = cgpu->virtual_gpu;
int i = thr->id;
static bool failmessage = false;
int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
int buffersize = SCRYPT_BUFFERSIZE;
if (!blank_res)
blank_res = calloc(buffersize, 1);
@ -1404,7 +1398,7 @@ static bool opencl_thread_init(struct thr_info *thr) @@ -1404,7 +1398,7 @@ static bool opencl_thread_init(struct thr_info *thr)
cl_int status = 0;
thrdata = calloc(1, sizeof(*thrdata));
thr->cgpu_data = thrdata;
int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
int buffersize = SCRYPT_BUFFERSIZE;
if (!thrdata) {
applog(LOG_ERR, "Failed to calloc in opencl_thread_init");
@ -1458,11 +1452,8 @@ static bool opencl_thread_init(struct thr_info *thr) @@ -1458,11 +1452,8 @@ static bool opencl_thread_init(struct thr_info *thr)
static bool opencl_prepare_work(struct thr_info __maybe_unused *thr, struct work *work)
{
#ifdef USE_SCRYPT
if (opt_scrypt)
work->blk.work = work;
else
work->blk.work = work;
#endif
precalc_hash(&work->blk, (uint32_t *)(work->midstate), (uint32_t *)(work->data + 64));
return true;
}
@ -1482,8 +1473,8 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work, @@ -1482,8 +1473,8 @@ static int64_t opencl_scanhash(struct thr_info *thr, struct work *work,
size_t globalThreads[1];
size_t localThreads[1] = { clState->wsize };
int64_t hashes;
int found = opt_scrypt ? SCRYPT_FOUND : FOUND;
int buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
int found = SCRYPT_FOUND;
int buffersize = SCRYPT_BUFFERSIZE;
/* Windows' timer resolution is only 15ms so oversample 5x */
if (gpu->dynamic && (++gpu->intervals * dynamic_us) > 70000) {

4
findnonce.c

@ -184,7 +184,7 @@ static void *postcalc_hash(void *userdata) @@ -184,7 +184,7 @@ static void *postcalc_hash(void *userdata)
struct pc_data *pcd = (struct pc_data *)userdata;
struct thr_info *thr = pcd->thr;
unsigned int entry = 0;
int found = opt_scrypt ? SCRYPT_FOUND : FOUND;
int found = SCRYPT_FOUND;
pthread_detach(pthread_self());
@ -223,7 +223,7 @@ void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res) @@ -223,7 +223,7 @@ void postcalc_hash_async(struct thr_info *thr, struct work *work, uint32_t *res)
pcd->thr = thr;
pcd->work = copy_work(work);
buffersize = opt_scrypt ? SCRYPT_BUFFERSIZE : BUFFERSIZE;
buffersize = SCRYPT_BUFFERSIZE;
memcpy(&pcd->res, res, buffersize);
if (pthread_create(&pcd->pth, NULL, postcalc_hash, (void *)pcd)) {

Loading…
Cancel
Save