Browse Source

Get rid of the stage thread since all work can be asynchronously added now via hash_push anyway.

Conflicts:
	cgminer.c
nfactor-troky
Con Kolivas 11 years ago committed by Noel Maersk
parent
commit
d38802a68f
  1. 69
      cgminer.c

69
cgminer.c

@ -149,7 +149,6 @@ char *cgminer_path;
struct thr_info *control_thr; struct thr_info *control_thr;
struct thr_info **mining_thr; struct thr_info **mining_thr;
static int gwsched_thr_id; static int gwsched_thr_id;
static int stage_thr_id;
static int watchpool_thr_id; static int watchpool_thr_id;
static int watchdog_thr_id; static int watchdog_thr_id;
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
@ -3006,11 +3005,7 @@ static void __kill_work(void)
cg_completion_timeout(&kill_mining, NULL, 3000); cg_completion_timeout(&kill_mining, NULL, 3000);
forcelog(LOG_DEBUG, "Killing off stage thread");
/* Stop the others */ /* Stop the others */
thr = &control_thr[stage_thr_id];
kill_timeout(thr);
forcelog(LOG_DEBUG, "Killing off API thread"); forcelog(LOG_DEBUG, "Killing off API thread");
thr = &control_thr[api_thr_id]; thr = &control_thr[api_thr_id];
kill_timeout(thr); kill_timeout(thr);
@ -3912,42 +3907,6 @@ static bool hash_push(struct work *work)
return rc; return rc;
} }
static void *stage_thread(void *userdata)
{
struct thr_info *mythr = userdata;
bool ok = true;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
RenameThread("stage");
while (ok) {
struct work *work = NULL;
applog(LOG_DEBUG, "Popping work to stage thread");
work = tq_pop(mythr->q, NULL);
if (unlikely(!work)) {
applog(LOG_ERR, "Failed to tq_pop in stage_thread");
ok = false;
break;
}
work->work_block = work_block;
test_work_current(work);
applog(LOG_DEBUG, "Pushing work to getwork queue");
if (unlikely(!hash_push(work))) {
applog(LOG_WARNING, "Failed to hash_push in stage_thread");
continue;
}
}
tq_freeze(mythr->q);
return NULL;
}
static void stage_work(struct work *work) static void stage_work(struct work *work)
{ {
applog(LOG_DEBUG, "Pushing work from pool %d to hash queue", work->pool->pool_no); applog(LOG_DEBUG, "Pushing work from pool %d to hash queue", work->pool->pool_no);
@ -5488,7 +5447,7 @@ retry_stratum:
calc_diff(work, 0); calc_diff(work, 0);
applog(LOG_DEBUG, "Pushing pooltest work to base pool"); applog(LOG_DEBUG, "Pushing pooltest work to base pool");
tq_push(control_thr[stage_thr_id].q, work); stage_work(work);
total_getworks++; total_getworks++;
pool->getwork_requested++; pool->getwork_requested++;
ret = true; ret = true;
@ -7630,7 +7589,7 @@ int main(int argc, char *argv[])
if (opt_scantime < 0) if (opt_scantime < 0)
opt_scantime = 30; opt_scantime = 30;
total_control_threads = 9; total_control_threads = 8;
control_thr = calloc(total_control_threads, sizeof(*thr)); control_thr = calloc(total_control_threads, sizeof(*thr));
if (!control_thr) if (!control_thr)
quit(1, "Failed to calloc control_thr"); quit(1, "Failed to calloc control_thr");
@ -7745,16 +7704,6 @@ int main(int argc, char *argv[])
quit(1, "Failed to calloc mining_thr[%d]", i); quit(1, "Failed to calloc mining_thr[%d]", i);
} }
stage_thr_id = 2;
thr = &control_thr[stage_thr_id];
thr->q = tq_new();
if (!thr->q)
quit(1, "Failed to tq_new");
/* start stage thread */
if (thr_info_create(thr, NULL, stage_thread, thr))
quit(1, "stage thread create failed");
pthread_detach(thr->pth);
/* Create a unique get work queue */ /* Create a unique get work queue */
getq = tq_new(); getq = tq_new();
if (!getq) if (!getq)
@ -7857,14 +7806,14 @@ begin_bench:
cgtime(&total_tv_start); cgtime(&total_tv_start);
cgtime(&total_tv_end); cgtime(&total_tv_end);
watchpool_thr_id = 3; watchpool_thr_id = 2;
thr = &control_thr[watchpool_thr_id]; thr = &control_thr[watchpool_thr_id];
/* start watchpool thread */ /* start watchpool thread */
if (thr_info_create(thr, NULL, watchpool_thread, NULL)) if (thr_info_create(thr, NULL, watchpool_thread, NULL))
quit(1, "watchpool thread create failed"); quit(1, "watchpool thread create failed");
pthread_detach(thr->pth); pthread_detach(thr->pth);
watchdog_thr_id = 4; watchdog_thr_id = 3;
thr = &control_thr[watchdog_thr_id]; thr = &control_thr[watchdog_thr_id];
/* start watchdog thread */ /* start watchdog thread */
if (thr_info_create(thr, NULL, watchdog_thread, NULL)) if (thr_info_create(thr, NULL, watchdog_thread, NULL))
@ -7872,7 +7821,7 @@ begin_bench:
pthread_detach(thr->pth); pthread_detach(thr->pth);
/* Create reinit gpu thread */ /* Create reinit gpu thread */
gpur_thr_id = 5; gpur_thr_id = 4;
thr = &control_thr[gpur_thr_id]; thr = &control_thr[gpur_thr_id];
thr->q = tq_new(); thr->q = tq_new();
if (!thr->q) if (!thr->q)
@ -7881,7 +7830,7 @@ begin_bench:
quit(1, "reinit_gpu thread create failed"); quit(1, "reinit_gpu thread create failed");
/* Create API socket thread */ /* Create API socket thread */
api_thr_id = 6; api_thr_id = 5;
thr = &control_thr[api_thr_id]; thr = &control_thr[api_thr_id];
if (thr_info_create(thr, NULL, api_thread, thr)) if (thr_info_create(thr, NULL, api_thread, thr))
quit(1, "API thread create failed"); quit(1, "API thread create failed");
@ -7890,7 +7839,7 @@ begin_bench:
/* Create curses input thread for keyboard input. Create this last so /* Create curses input thread for keyboard input. Create this last so
* that we know all threads are created since this can call kill_work * that we know all threads are created since this can call kill_work
* to try and shut down all previous threads. */ * to try and shut down all previous threads. */
input_thr_id = 8; input_thr_id = 7;
thr = &control_thr[input_thr_id]; thr = &control_thr[input_thr_id];
if (thr_info_create(thr, NULL, input_thread, thr)) if (thr_info_create(thr, NULL, input_thread, thr))
quit(1, "input thread create failed"); quit(1, "input thread create failed");
@ -7898,8 +7847,8 @@ begin_bench:
#endif #endif
/* Just to be sure */ /* Just to be sure */
if (total_control_threads != 9) if (total_control_threads != 8)
quit(1, "incorrect total_control_threads (%d) should be 9", total_control_threads); quit(1, "incorrect total_control_threads (%d) should be 8", total_control_threads);
/* Once everything is set up, main() becomes the getwork scheduler */ /* Once everything is set up, main() becomes the getwork scheduler */
while (42) { while (42) {

Loading…
Cancel
Save