Browse Source

Profile points and warning clean ups.

nfactor-troky
ckolivas 14 years ago committed by Con Kolivas
parent
commit
7ae9afc40f
  1. 19
      cpu-miner.c
  2. 2
      findnonce.c

19
cpu-miner.c

@ -400,8 +400,10 @@ static bool get_upstream_work(CURL *curl, struct work *work)
val = json_rpc_call(curl, rpc_url, rpc_userpass, rpc_req, val = json_rpc_call(curl, rpc_url, rpc_userpass, rpc_req,
want_longpoll, false); want_longpoll, false);
if (!val) if (unlikely(!val)) {
applog(LOG_ERR, "Failed json_rpc_call in get_upstream_work");
return false; return false;
}
rc = work_decode(json_object_get(val, "result"), work); rc = work_decode(json_object_get(val, "result"), work);
@ -465,7 +467,7 @@ static void *get_work_thread(void *userdata)
int failures = 0; int failures = 0;
ret_work = calloc(1, sizeof(*ret_work)); ret_work = calloc(1, sizeof(*ret_work));
if (!ret_work) { if (unlikely(!ret_work)) {
applog(LOG_ERR, "Failed to calloc ret_work in workio_get_work"); applog(LOG_ERR, "Failed to calloc ret_work in workio_get_work");
kill_work(); kill_work();
goto out; goto out;
@ -510,7 +512,8 @@ static bool workio_get_work(struct workio_cmd *wc, CURL *curl)
id->wc = wc; id->wc = wc;
id->curl = curl; id->curl = curl;
if (!get_thread) { if (unlikely(!get_thread)) {
/* This is only instantiated once at startup */
get_thread = malloc(sizeof(get_thread)); get_thread = malloc(sizeof(get_thread));
if (unlikely(!get_thread)) { if (unlikely(!get_thread)) {
applog(LOG_ERR, "Failed to malloc get_thread in workio_get_work"); applog(LOG_ERR, "Failed to malloc get_thread in workio_get_work");
@ -519,7 +522,7 @@ static bool workio_get_work(struct workio_cmd *wc, CURL *curl)
} else } else
pthread_join(*get_thread, NULL); pthread_join(*get_thread, NULL);
if (pthread_create(get_thread, NULL, get_work_thread, (void *)id)) { if (unlikely(pthread_create(get_thread, NULL, get_work_thread, (void *)id))) {
applog(LOG_ERR, "Failed to create get_work_thread"); applog(LOG_ERR, "Failed to create get_work_thread");
free(id); free(id);
return false; return false;
@ -565,7 +568,7 @@ static bool workio_submit_work(struct workio_cmd *wc, CURL *curl)
id->wc = wc; id->wc = wc;
id->curl = curl; id->curl = curl;
if (!submit_thread) { if (unlikely(!submit_thread)) {
submit_thread = malloc(sizeof(submit_thread)); submit_thread = malloc(sizeof(submit_thread));
if (unlikely(!submit_thread)) { if (unlikely(!submit_thread)) {
applog(LOG_ERR, "Failed to malloc submit_thread in workio_submit_work"); applog(LOG_ERR, "Failed to malloc submit_thread in workio_submit_work");
@ -574,7 +577,7 @@ static bool workio_submit_work(struct workio_cmd *wc, CURL *curl)
} else } else
pthread_join(*submit_thread, NULL); pthread_join(*submit_thread, NULL);
if (pthread_create(submit_thread, NULL, submit_work_thread, (void *)id)) { if (unlikely(pthread_create(submit_thread, NULL, submit_work_thread, (void *)id))) {
applog(LOG_ERR, "Failed to create submit_work_thread"); applog(LOG_ERR, "Failed to create submit_work_thread");
free(id); free(id);
return false; return false;
@ -905,7 +908,7 @@ static void *miner_thread(void *userdata)
if (unlikely(rc)) { if (unlikely(rc)) {
if (opt_debug) if (opt_debug)
applog(LOG_DEBUG, "CPU %d found something?", cpu_from_thr_id(thr_id)); applog(LOG_DEBUG, "CPU %d found something?", cpu_from_thr_id(thr_id));
if (!submit_work_sync(mythr, &work)) if (unlikely(!submit_work_sync(mythr, &work)))
break; break;
} }
} }
@ -1379,7 +1382,7 @@ int main (int argc, char *argv[])
struct thr_info *thr; struct thr_info *thr;
unsigned int i; unsigned int i;
char name[32]; char name[32];
struct cgpu_info *gpus, *cpus; struct cgpu_info *gpus = NULL, *cpus = NULL;
#ifdef WIN32 #ifdef WIN32
opt_n_threads = num_processors = 1; opt_n_threads = num_processors = 1;

2
findnonce.c

@ -148,7 +148,7 @@ static void *postcalc_hash(void *userdata)
struct thr_info *thr = pcd->thr; struct thr_info *thr = pcd->thr;
dev_blk_ctx *blk = &pcd->work->blk; dev_blk_ctx *blk = &pcd->work->blk;
struct work *work = pcd->work; struct work *work = pcd->work;
uint32_t start; uint32_t start = 0;
cl_uint A, B, C, D, E, F, G, H; cl_uint A, B, C, D, E, F, G, H;
cl_uint W[16]; cl_uint W[16];

Loading…
Cancel
Save