mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Make the number of queued work items configurable and default to 2.
This commit is contained in:
parent
131f60a5ee
commit
edd0591e19
41
cpu-miner.c
41
cpu-miner.c
@ -121,6 +121,7 @@ static bool opt_quiet = false;
|
|||||||
static int opt_retries = 10;
|
static int opt_retries = 10;
|
||||||
static int opt_fail_pause = 30;
|
static int opt_fail_pause = 30;
|
||||||
static int opt_log_interval = 5;
|
static int opt_log_interval = 5;
|
||||||
|
static int opt_queue = 2;
|
||||||
int opt_vectors;
|
int opt_vectors;
|
||||||
int opt_worksize;
|
int opt_worksize;
|
||||||
int opt_scantime = 60;
|
int opt_scantime = 60;
|
||||||
@ -192,14 +193,14 @@ static struct option_help options_help[] = {
|
|||||||
{ "gpu-threads N",
|
{ "gpu-threads N",
|
||||||
"(-g N) Number of threads per-GPU (0 - 10, default: 2)" },
|
"(-g N) Number of threads per-GPU (0 - 10, default: 2)" },
|
||||||
|
|
||||||
{ "intensity",
|
{ "intensity N",
|
||||||
"(-I) Intensity of scanning (0 - 14, default 4)" },
|
"(-I) Intensity of scanning (0 - 14, default 4)" },
|
||||||
|
|
||||||
{ "log",
|
{ "log N",
|
||||||
"(-l) Interval in seconds between log output (default: 5)" },
|
"(-l N) Interval in seconds between log output (default: 5)" },
|
||||||
|
|
||||||
{ "ndevs",
|
{ "ndevs",
|
||||||
"(-n) Display number of detected GPUs" },
|
"(-n) Display number of detected GPUs and exit" },
|
||||||
|
|
||||||
{ "no-longpoll",
|
{ "no-longpoll",
|
||||||
"Disable X-Long-Polling support (default: enabled)" },
|
"Disable X-Long-Polling support (default: enabled)" },
|
||||||
@ -211,6 +212,9 @@ static struct option_help options_help[] = {
|
|||||||
{ "protocol-dump",
|
{ "protocol-dump",
|
||||||
"(-P) Verbose dump of protocol-level activities (default: off)" },
|
"(-P) Verbose dump of protocol-level activities (default: off)" },
|
||||||
|
|
||||||
|
{ "queue N",
|
||||||
|
"(-Q N) Number of work items to queue (1 - 10, default 2)" },
|
||||||
|
|
||||||
{ "quiet",
|
{ "quiet",
|
||||||
"(-q) Disable per-thread hashmeter output (default: off)" },
|
"(-q) Disable per-thread hashmeter output (default: off)" },
|
||||||
|
|
||||||
@ -264,6 +268,7 @@ static struct option options[] = {
|
|||||||
{ "no-longpoll", 0, NULL, 1003 },
|
{ "no-longpoll", 0, NULL, 1003 },
|
||||||
{ "pass", 1, NULL, 'p' },
|
{ "pass", 1, NULL, 'p' },
|
||||||
{ "protocol-dump", 0, NULL, 'P' },
|
{ "protocol-dump", 0, NULL, 'P' },
|
||||||
|
{ "queue", 1, NULL, 'Q' },
|
||||||
{ "quiet", 0, NULL, 'q' },
|
{ "quiet", 0, NULL, 'q' },
|
||||||
{ "retries", 1, NULL, 'r' },
|
{ "retries", 1, NULL, 'r' },
|
||||||
{ "retry-pause", 1, NULL, 'R' },
|
{ "retry-pause", 1, NULL, 'R' },
|
||||||
@ -719,9 +724,10 @@ static bool queue_request(void)
|
|||||||
static bool get_work(struct work *work)
|
static bool get_work(struct work *work)
|
||||||
{
|
{
|
||||||
struct thr_info *thr = &thr_info[0];
|
struct thr_info *thr = &thr_info[0];
|
||||||
|
static bool first_work = true;
|
||||||
struct work *work_heap;
|
struct work *work_heap;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
static bool first_work = true;
|
unsigned int i;
|
||||||
|
|
||||||
get_new:
|
get_new:
|
||||||
if (unlikely(!queue_request()))
|
if (unlikely(!queue_request()))
|
||||||
@ -737,15 +743,27 @@ get_new:
|
|||||||
free(work_heap);
|
free(work_heap);
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
applog(LOG_DEBUG, "New block detected, discarding old work");
|
applog(LOG_DEBUG, "New block detected, discarding old work");
|
||||||
|
for (i = 1; i < opt_queue; i++) {
|
||||||
|
/* Pop off all the work. Cancelling the requests would
|
||||||
|
* be better but tricky. */
|
||||||
|
work_heap = tq_pop(thr->q, NULL);
|
||||||
|
if (unlikely(!work_heap))
|
||||||
|
goto out;
|
||||||
|
free(work_heap);
|
||||||
|
if (unlikely(!queue_request()))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
goto get_new;
|
goto get_new;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(first_work)) {
|
if (unlikely(first_work)) {
|
||||||
first_work = false;
|
first_work = false;
|
||||||
/* send for another work request for the next time get_work
|
/* send for extra work requests for the next time get_work
|
||||||
* is called. */
|
* is called. */
|
||||||
if (unlikely(!queue_request()))
|
for (i = 1; i < opt_queue; i++) {
|
||||||
goto out_free;
|
if (unlikely(!queue_request()))
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(work, work_heap, sizeof(*work));
|
memcpy(work, work_heap, sizeof(*work));
|
||||||
@ -1252,6 +1270,13 @@ static void parse_arg (int key, char *arg)
|
|||||||
case 'P':
|
case 'P':
|
||||||
opt_protocol = true;
|
opt_protocol = true;
|
||||||
break;
|
break;
|
||||||
|
case 'Q':
|
||||||
|
v = atoi(arg);
|
||||||
|
if (v < 1 || v > 10)
|
||||||
|
show_usage();
|
||||||
|
|
||||||
|
opt_queue = v;
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
opt_quiet = true;
|
opt_quiet = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user