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

33
driver-opencl.c

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

4
findnonce.c

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

Loading…
Cancel
Save