nvapi: allow different led modes (mining,shares)
This commit is contained in:
parent
0e942bf60c
commit
fc1472b5f7
24
ccminer.cpp
24
ccminer.cpp
@ -131,6 +131,7 @@ uint32_t device_plimit[MAX_GPUS] = { 0 };
|
||||
uint8_t device_tlimit[MAX_GPUS] = { 0 };
|
||||
int8_t device_pstate[MAX_GPUS] = { -1, -1 };
|
||||
int32_t device_led[MAX_GPUS] = { -1, -1 };
|
||||
int opt_led_mode = 0;
|
||||
int opt_cudaschedule = -1;
|
||||
static bool opt_keep_clocks = false;
|
||||
|
||||
@ -1255,9 +1256,11 @@ static void *workio_thread(void *userdata)
|
||||
ok = workio_get_work(wc, curl);
|
||||
break;
|
||||
case WC_SUBMIT_WORK:
|
||||
gpu_led_on(device_map[wc->thr->id]);
|
||||
if (opt_led_mode == LED_MODE_SHARES)
|
||||
gpu_led_on(device_map[wc->thr->id]);
|
||||
ok = workio_submit_work(wc, curl);
|
||||
gpu_led_off(device_map[wc->thr->id]);
|
||||
if (opt_led_mode == LED_MODE_SHARES)
|
||||
gpu_led_off(device_map[wc->thr->id]);
|
||||
break;
|
||||
case WC_ABORT:
|
||||
default: /* should never happen */
|
||||
@ -1968,6 +1971,9 @@ static void *miner_thread(void *userdata)
|
||||
gpulog(LOG_DEBUG, thr_id, "start=%08x end=%08x range=%08x",
|
||||
start_nonce, max_nonce, (max_nonce-start_nonce));
|
||||
|
||||
if (opt_led_mode == LED_MODE_MINING)
|
||||
gpu_led_on(dev_id);
|
||||
|
||||
hashes_done = 0;
|
||||
gettimeofday(&tv_start, NULL);
|
||||
|
||||
@ -2110,6 +2116,9 @@ static void *miner_thread(void *userdata)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (opt_led_mode == LED_MODE_MINING)
|
||||
gpu_led_off(dev_id);
|
||||
|
||||
if (abort_flag)
|
||||
break; // time to leave the mining loop...
|
||||
|
||||
@ -2204,7 +2213,8 @@ static void *miner_thread(void *userdata)
|
||||
|
||||
/* if nonce found, submit work */
|
||||
if (rc > 0 && !opt_benchmark) {
|
||||
gpu_led_percent(dev_id, 50);
|
||||
if (opt_led_mode == LED_MODE_SHARES)
|
||||
gpu_led_percent(dev_id, 50);
|
||||
if (!submit_work(mythr, &work))
|
||||
break;
|
||||
|
||||
@ -2233,6 +2243,8 @@ static void *miner_thread(void *userdata)
|
||||
}
|
||||
|
||||
out:
|
||||
if (opt_led_mode)
|
||||
gpu_led_off(dev_id);
|
||||
if (opt_debug_threads)
|
||||
applog(LOG_DEBUG, "%s() died", __func__);
|
||||
tq_freeze(mythr->q);
|
||||
@ -2959,12 +2971,18 @@ void parse_arg(int key, char *arg)
|
||||
break;
|
||||
case 1080: /* --led */
|
||||
{
|
||||
if (!opt_led_mode)
|
||||
opt_led_mode = LED_MODE_SHARES;
|
||||
char *pch = strtok(arg,",");
|
||||
int n = 0, val;
|
||||
while (pch != NULL && n < MAX_GPUS) {
|
||||
int dev_id = device_map[n++];
|
||||
char * p = strstr(pch, "0x");
|
||||
val = p ? (int32_t) strtoul(p, NULL, 16) : atoi(pch);
|
||||
if (!val && !strcmp(pch, "mining"))
|
||||
opt_led_mode = LED_MODE_MINING;
|
||||
if (!val && !strcmp(pch, "shares"))
|
||||
opt_led_mode = LED_MODE_SHARES;
|
||||
device_led[dev_id] = val;
|
||||
pch = strtok(NULL, ",");
|
||||
}
|
||||
|
8
nvml.cpp
8
nvml.cpp
@ -1819,9 +1819,9 @@ int gpu_info(struct cgpu_info *gpu)
|
||||
static int rgb_percent(int RGB, int percent)
|
||||
{
|
||||
uint8_t* comp = (uint8_t*) &RGB;
|
||||
int res = ((comp[2] * percent) / 100) << 16;
|
||||
res += ((comp[1] * percent) / 100) << 8;
|
||||
return res + ((comp[0] * percent) / 100);
|
||||
int res = ((percent*comp[2]) / 100) << 16;
|
||||
res += ((percent*comp[1]) / 100) << 8;
|
||||
return res + ((percent*comp[0]) / 100);
|
||||
}
|
||||
|
||||
void gpu_led_on(int dev_id)
|
||||
@ -1838,7 +1838,7 @@ void gpu_led_on(int dev_id)
|
||||
void gpu_led_percent(int dev_id, int percent)
|
||||
{
|
||||
#if defined(WIN32) && defined(USE_WRAPNVML)
|
||||
int value = device_led[dev_id] > 100 ? rgb_percent(device_led[dev_id], percent) : (device_led[dev_id] * percent)/100;
|
||||
int value = rgb_percent(device_led[dev_id], percent);
|
||||
if (device_led_state[dev_id] != value) {
|
||||
if (nvapi_set_led(nvapi_dev_map[dev_id], value, device_name[dev_id]) == 0)
|
||||
device_led_state[dev_id] = value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user