1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-02-10 05:54:21 +00:00

Added idle mode

Idle is only set by pgadisable, so GPU/CPU is unaffected.
For Icarus/Ztex, in scanhash the thread is immediately set disabled then returns.
This commit is contained in:
Paul Sheppard 2012-06-09 19:30:32 -07:00
parent ed06c97e2e
commit ebeaf15f18
5 changed files with 28 additions and 19 deletions

11
api.c
View File

@ -167,6 +167,7 @@ static const char *SICK = "Sick";
static const char *NOSTART = "NoStart"; static const char *NOSTART = "NoStart";
static const char *DISABLED = "Disabled"; static const char *DISABLED = "Disabled";
static const char *ALIVE = "Alive"; static const char *ALIVE = "Alive";
static const char *IDLE = "Idle";
static const char *REJECTING = "Rejecting"; static const char *REJECTING = "Rejecting";
static const char *UNKNOWN = "Unknown"; static const char *UNKNOWN = "Unknown";
#define _DYNAMIC "D" #define _DYNAMIC "D"
@ -879,7 +880,7 @@ static void pgastatus(int pga, bool isjson)
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60; cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
if (cgpu->deven != DEV_DISABLED) if (cgpu->deven == DEV_ENABLED)
enabled = (char *)YES; enabled = (char *)YES;
else else
enabled = (char *)NO; enabled = (char *)NO;
@ -890,6 +891,8 @@ static void pgastatus(int pga, bool isjson)
status = (char *)SICK; status = (char *)SICK;
else if (cgpu->status == LIFE_NOSTART) else if (cgpu->status == LIFE_NOSTART)
status = (char *)NOSTART; status = (char *)NOSTART;
else if (cgpu->deven == DEV_IDLE)
status = (char *)IDLE;
else else
status = (char *)ALIVE; status = (char *)ALIVE;
@ -1092,7 +1095,7 @@ static void pgaenable(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
struct cgpu_info *cgpu = devices[dev]; struct cgpu_info *cgpu = devices[dev];
if (cgpu->deven != DEV_DISABLED) { if (cgpu->deven == DEV_ENABLED) {
strcpy(io_buffer, message(MSG_PGALRENA, id, NULL, isjson)); strcpy(io_buffer, message(MSG_PGALRENA, id, NULL, isjson));
return; return;
} }
@ -1143,12 +1146,12 @@ static void pgadisable(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
struct cgpu_info *cgpu = devices[dev]; struct cgpu_info *cgpu = devices[dev];
if (cgpu->deven == DEV_DISABLED) { if (cgpu->deven != DEV_ENABLED) {
strcpy(io_buffer, message(MSG_PGALRDIS, id, NULL, isjson)); strcpy(io_buffer, message(MSG_PGALRDIS, id, NULL, isjson));
return; return;
} }
cgpu->deven = DEV_DISABLED; cgpu->deven = DEV_IDLE;
strcpy(io_buffer, message(MSG_PGADIS, id, NULL, isjson)); strcpy(io_buffer, message(MSG_PGADIS, id, NULL, isjson));
} }

View File

@ -2643,22 +2643,15 @@ void remove_pool(struct pool *pool)
void write_config(FILE *fcfg) void write_config(FILE *fcfg)
{ {
int i = 0; int i;
int j = 0;
/* Write pool values in priority order */ /* Write pool values */
fputs("{\n\"pools\" : [", fcfg); fputs("{\n\"pools\" : [", fcfg);
while((j < total_pools) && (i < total_pools)) { for(i = 0; i < total_pools; i++) {
if(pools[i]->prio == j) { fprintf(fcfg, "%s\n\t{\n\t\t\"url\" : \"%s\",", i > 0 ? "," : "", pools[i]->rpc_url);
fprintf(fcfg, "%s\n\t{\n\t\t\"url\" : \"%s\",", i > 0 ? "," : "", pools[i]->rpc_url); fprintf(fcfg, "\n\t\t\"user\" : \"%s\",", pools[i]->rpc_user);
fprintf(fcfg, "\n\t\t\"user\" : \"%s\",", pools[i]->rpc_user); fprintf(fcfg, "\n\t\t\"pass\" : \"%s\"\n\t}", pools[i]->rpc_pass);
fprintf(fcfg, "\n\t\t\"pass\" : \"%s\"\n\t}", pools[i]->rpc_pass); }
j++;
i=0;
}
else
i++;
}
fputs("\n]\n", fcfg); fputs("\n]\n", fcfg);
if (nDevs) { if (nDevs) {
@ -3925,7 +3918,7 @@ void *miner_thread(void *userdata)
tv_lastupdate = tv_end; tv_lastupdate = tv_end;
} }
if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED)) { if (unlikely(mythr->pause || cgpu->deven == DEV_DISABLED || cgpu->deven == DEV_RECOVER)) {
applog(LOG_WARNING, "Thread %d being disabled", thr_id); applog(LOG_WARNING, "Thread %d being disabled", thr_id);
disabled: disabled:
mythr->rolling = mythr->cgpu->rolling = 0; mythr->rolling = mythr->cgpu->rolling = 0;

View File

@ -566,6 +566,12 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
uint32_t values; uint32_t values;
uint64_t hash_count_range; uint64_t hash_count_range;
/* Device developer can make use of idle state, until then, disable and return */
if (thr->cgpu->deven == DEV_IDLE) {
thr->cgpu->deven = DEV_DISABLED;
return 1;
}
elapsed.tv_sec = elapsed.tv_usec = 0; elapsed.tv_sec = elapsed.tv_usec = 0;
icarus = thr->cgpu; icarus = thr->cgpu;

View File

@ -199,6 +199,12 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
bool overflow, found, rv; bool overflow, found, rv;
struct libztex_hash_data hdata[GOLDEN_BACKLOG]; struct libztex_hash_data hdata[GOLDEN_BACKLOG];
/* Device developer can make use of idle state, until then, disable and return */
if (thr->cgpu->deven == DEV_IDLE) {
thr->cgpu->deven = DEV_DISABLED;
return 1;
}
ztex = thr->cgpu->device_ztex; ztex = thr->cgpu->device_ztex;
memcpy(sendbuf, work->data + 64, 12); memcpy(sendbuf, work->data + 64, 12);

View File

@ -250,6 +250,7 @@ enum dev_enable {
DEV_ENABLED, DEV_ENABLED,
DEV_DISABLED, DEV_DISABLED,
DEV_RECOVER, DEV_RECOVER,
DEV_IDLE,
}; };
enum cl_kernels { enum cl_kernels {