Browse Source

basic pool algo switch (without free barrier)

not really proper but should works for 2 "small" algos.

just put the "algo" param in each pools config
master
Tanguy Pruvot 9 years ago
parent
commit
d3e2088398
  1. 13
      ccminer.cpp
  2. 28
      pools.cpp

13
ccminer.cpp

@ -340,11 +340,12 @@ struct option options[] = {
{ "max-rate", 1, NULL, 1062 }, { "max-rate", 1, NULL, 1062 },
{ "pass", 1, NULL, 'p' }, { "pass", 1, NULL, 'p' },
{ "pool-name", 1, NULL, 1100 }, // pool { "pool-name", 1, NULL, 1100 }, // pool
{ "pool-removed", 1, NULL, 1101 }, // pool { "pool-algo", 1, NULL, 1101 }, // pool
{ "pool-scantime", 1, NULL, 1102 }, // pool { "pool-scantime", 1, NULL, 1102 }, // pool
{ "pool-time-limit", 1, NULL, 1108 }, { "pool-time-limit", 1, NULL, 1108 },
{ "pool-max-diff", 1, NULL, 1161 }, // pool { "pool-max-diff", 1, NULL, 1161 }, // pool
{ "pool-max-rate", 1, NULL, 1162 }, // pool { "pool-max-rate", 1, NULL, 1162 }, // pool
{ "pool-disabled", 1, NULL, 1199 }, // pool
{ "protocol-dump", 0, NULL, 'P' }, { "protocol-dump", 0, NULL, 'P' },
{ "proxy", 1, NULL, 'x' }, { "proxy", 1, NULL, 'x' },
{ "quiet", 0, NULL, 'q' }, { "quiet", 0, NULL, 'q' },
@ -1633,6 +1634,9 @@ static void *miner_thread(void *userdata)
/* conditional mining */ /* conditional mining */
if (!wanna_mine(thr_id)) { if (!wanna_mine(thr_id)) {
// free gpu resources
algo_free_all(thr_id);
// conditional pool switch // conditional pool switch
if (num_pools > 1 && conditional_pool_rotate) { if (num_pools > 1 && conditional_pool_rotate) {
if (!pool_is_switching) if (!pool_is_switching)
@ -2833,8 +2837,8 @@ void parse_arg(int key, char *arg)
case 1100: /* pool name */ case 1100: /* pool name */
pool_set_attr(cur_pooln, "name", arg); pool_set_attr(cur_pooln, "name", arg);
break; break;
case 1101: /* pool removed */ case 1101: /* pool algo */
pool_set_attr(cur_pooln, "removed", arg); pool_set_attr(cur_pooln, "algo", arg);
break; break;
case 1102: /* pool scantime */ case 1102: /* pool scantime */
pool_set_attr(cur_pooln, "scantime", arg); pool_set_attr(cur_pooln, "scantime", arg);
@ -2848,6 +2852,9 @@ void parse_arg(int key, char *arg)
case 1162: /* pool max-rate */ case 1162: /* pool max-rate */
pool_set_attr(cur_pooln, "max-rate", arg); pool_set_attr(cur_pooln, "max-rate", arg);
break; break;
case 1199:
pool_set_attr(cur_pooln, "disabled", arg);
break;
case 'V': case 'V':
show_version_and_exit(); show_version_and_exit();

28
pools.cpp

@ -38,6 +38,8 @@ extern volatile int pool_switch_count;
extern volatile bool pool_is_switching; extern volatile bool pool_is_switching;
extern uint8_t conditional_state[MAX_GPUS]; extern uint8_t conditional_state[MAX_GPUS];
extern double thr_hashrates[MAX_GPUS];
extern struct option options[]; extern struct option options[];
#define CFG_NULL 0 #define CFG_NULL 0
@ -51,13 +53,12 @@ struct opt_config_array {
{ CFG_POOL, "user", NULL }, { CFG_POOL, "user", NULL },
{ CFG_POOL, "pass", NULL }, { CFG_POOL, "pass", NULL },
{ CFG_POOL, "userpass", NULL }, { CFG_POOL, "userpass", NULL },
{ CFG_POOL, "algo", NULL },
{ CFG_POOL, "name", "pool-name" }, { CFG_POOL, "name", "pool-name" },
{ CFG_POOL, "algo", "pool-algo" },
{ CFG_POOL, "scantime", "pool-scantime" }, { CFG_POOL, "scantime", "pool-scantime" },
{ CFG_POOL, "max-diff", "pool-max-diff" }, { CFG_POOL, "max-diff", "pool-max-diff" },
{ CFG_POOL, "max-rate", "pool-max-rate" }, { CFG_POOL, "max-rate", "pool-max-rate" },
{ CFG_POOL, "removed", "pool-removed" }, { CFG_POOL, "disabled", "pool-disabled" },
{ CFG_POOL, "disabled", "pool-removed" }, // sample alias
{ CFG_POOL, "time-limit", "pool-time-limit" }, { CFG_POOL, "time-limit", "pool-time-limit" },
{ CFG_NULL, NULL, NULL } { CFG_NULL, NULL, NULL }
}; };
@ -117,14 +118,14 @@ void pool_init_defaults()
void pool_set_attr(int pooln, const char* key, char* arg) void pool_set_attr(int pooln, const char* key, char* arg)
{ {
struct pool_infos *p = &pools[pooln]; struct pool_infos *p = &pools[pooln];
if (!strcasecmp(key, "algo")) {
p->algo = algo_to_int(arg);
return;
}
if (!strcasecmp(key, "name")) { if (!strcasecmp(key, "name")) {
snprintf(p->name, sizeof(p->name), "%s", arg); snprintf(p->name, sizeof(p->name), "%s", arg);
return; return;
} }
if (!strcasecmp(key, "algo")) {
p->algo = algo_to_int(arg);
return;
}
if (!strcasecmp(key, "scantime")) { if (!strcasecmp(key, "scantime")) {
p->scantime = atoi(arg); p->scantime = atoi(arg);
return; return;
@ -141,7 +142,7 @@ void pool_set_attr(int pooln, const char* key, char* arg)
p->time_limit = atoi(arg); p->time_limit = atoi(arg);
return; return;
} }
if (!strcasecmp(key, "removed")) { if (!strcasecmp(key, "disabled")) {
int removed = atoi(arg); int removed = atoi(arg);
if (removed) { if (removed) {
p->status |= POOL_ST_REMOVED; p->status |= POOL_ST_REMOVED;
@ -154,6 +155,7 @@ void pool_set_attr(int pooln, const char* key, char* arg)
bool pool_switch(int thr_id, int pooln) bool pool_switch(int thr_id, int pooln)
{ {
int prevn = cur_pooln; int prevn = cur_pooln;
bool algo_switch = false;
struct pool_infos *prev = &pools[cur_pooln]; struct pool_infos *prev = &pools[cur_pooln];
struct pool_infos* p = NULL; struct pool_infos* p = NULL;
@ -195,6 +197,16 @@ bool pool_switch(int thr_id, int pooln)
pthread_mutex_unlock(&stratum_work_lock); pthread_mutex_unlock(&stratum_work_lock);
// algo "blind" switch without free, not proper
if (p->algo != (int) opt_algo) {
opt_algo = (enum sha_algos) p->algo;
for (int n=0; n<opt_n_threads; n++)
thr_hashrates[n] = 0.;
// todo: a barrier is required to free algo resources
if (opt_algo != ALGO_AUTO)
algo_switch = true;
}
if (prevn != cur_pooln) { if (prevn != cur_pooln) {
pool_switch_count++; pool_switch_count++;

Loading…
Cancel
Save