Browse Source

Merge pull request #252 from pshep/master

More timing changes
nfactor-troky
Con Kolivas 12 years ago
parent
commit
6b11d4e4cc
  1. 27
      driver-bitforce.c

27
driver-bitforce.c

@ -21,7 +21,8 @@
#include "miner.h" #include "miner.h"
#define BITFORCE_SLEEP_MS 3000 #define BITFORCE_SLEEP_MS 3000
#define BITFORCE_TIMEOUT_MS 10000 #define BITFORCE_TIMEOUT_MS 7000
#define BITFORCE_LONG_TIMEOUT_MS 15000
#define BITFORCE_CHECK_INTERVAL_MS 10 #define BITFORCE_CHECK_INTERVAL_MS 10
#define WORK_CHECK_INTERVAL_MS 50 #define WORK_CHECK_INTERVAL_MS 50
#define MAX_START_DELAY_US 100000 #define MAX_START_DELAY_US 100000
@ -196,6 +197,7 @@ void bitforce_init(struct cgpu_info *bitforce)
} }
bitforce->device_fd = fdDev; bitforce->device_fd = fdDev;
bitforce->sleep_ms = BITFORCE_SLEEP_MS;
mutex_unlock(&bitforce->device_mutex); mutex_unlock(&bitforce->device_mutex);
} }
@ -301,7 +303,7 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
if (!fdDev) if (!fdDev)
return 0; return 0;
while (bitforce->wait_ms < BITFORCE_TIMEOUT_MS) { while (bitforce->wait_ms < BITFORCE_LONG_TIMEOUT_MS) {
if (unlikely(work_restart[thr->id].restart)) if (unlikely(work_restart[thr->id].restart))
return 1; return 1;
mutex_lock(&bitforce->device_mutex); mutex_lock(&bitforce->device_mutex);
@ -317,10 +319,11 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
} }
if (bitforce->wait_ms >= BITFORCE_TIMEOUT_MS) { if (bitforce->wait_ms >= BITFORCE_TIMEOUT_MS) {
applog(LOG_ERR, "BFL%i: took longer than 10s", bitforce->device_id); applog(LOG_ERR, "BFL%i: took longer than %dms", bitforce->device_id, BITFORCE_TIMEOUT_MS);
bitforce->device_last_not_well = time(NULL); bitforce->device_last_not_well = time(NULL);
bitforce->device_not_well_reason = REASON_DEV_OVER_HEAT; bitforce->device_not_well_reason = REASON_DEV_OVER_HEAT;
bitforce->dev_over_heat_count++; bitforce->dev_over_heat_count++;
if (!pdevbuf[0]) /* Only return if we got nothing after timeout - there still may be results */
return 1; return 1;
} else if (pdevbuf[0] == 'N') {/* Hashing complete (NONCE-FOUND or NO-NONCE) */ } else if (pdevbuf[0] == 'N') {/* Hashing complete (NONCE-FOUND or NO-NONCE) */
/* Simple timing adjustment */ /* Simple timing adjustment */
@ -328,9 +331,9 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
if (bitforce->wait_ms > (bitforce->sleep_ms + BITFORCE_CHECK_INTERVAL_MS)) if (bitforce->wait_ms > (bitforce->sleep_ms + BITFORCE_CHECK_INTERVAL_MS))
bitforce->sleep_ms += (unsigned int) ((double) (bitforce->wait_ms - bitforce->sleep_ms) / 1.6); bitforce->sleep_ms += (unsigned int) ((double) (bitforce->wait_ms - bitforce->sleep_ms) / 1.6);
else if (bitforce->wait_ms == bitforce->sleep_ms) else if (bitforce->wait_ms == bitforce->sleep_ms)
bitforce->sleep_ms -= BITFORCE_CHECK_INTERVAL_MS; bitforce->sleep_ms -= WORK_CHECK_INTERVAL_MS;
if (delay_time_ms != bitforce->sleep_ms) if (delay_time_ms != bitforce->sleep_ms)
applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d. Waited: %d", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms); applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms);
} }
applog(LOG_DEBUG, "BFL%i: waited %dms until %s", bitforce->device_id, bitforce->wait_ms, pdevbuf); applog(LOG_DEBUG, "BFL%i: waited %dms until %s", bitforce->device_id, bitforce->wait_ms, pdevbuf);
@ -439,10 +442,24 @@ static bool bitforce_thread_init(struct thr_info *thr)
return true; return true;
} }
static struct api_data *bitforce_api_stats(struct cgpu_info *cgpu)
{
struct api_data *root = NULL;
// Warning, access to these is not locked - but we don't really
// care since hashing performance is way more important than
// locking access to displaying API debug 'stats'
// If locking becomes an issue for any of them, use copy_data=true also
root = api_add_int(root, "Sleep Time", &(cgpu->sleep_ms), false);
return root;
}
struct device_api bitforce_api = { struct device_api bitforce_api = {
.dname = "bitforce", .dname = "bitforce",
.name = "BFL", .name = "BFL",
.api_detect = bitforce_detect, .api_detect = bitforce_detect,
.get_api_stats = bitforce_api_stats,
.reinit_device = bitforce_init, .reinit_device = bitforce_init,
.get_statline_before = get_bitforce_statline_before, .get_statline_before = get_bitforce_statline_before,
.get_stats = bitforce_get_stats, .get_stats = bitforce_get_stats,

Loading…
Cancel
Save