production stats added, reset queue added
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
diff --git a/driver-spondoolies-sp10.c b/driver-spondoolies-sp10.c
index e19702f..0e71309 100644
--- a/driver-spondoolies-sp10.c
+++ b/driver-spondoolies-sp10.c
@@ -41,7 +41,7 @@
#include "compat.h"
#include "miner.h"
#include "driver-spondoolies-sp10-p.h"
-#include "driver-spondoolies-p.h"
+#include "driver-spondoolies.h"
#ifdef WORDS_BIGENDIAN
# define swap32tobe(out, in, sz) ((out == in) ? (void)0 : memmove(out, in, sz))
diff --git a/driver-spondoolies-sp30-p.h b/driver-spondoolies-sp30-p.h
index 128c12d..0a7d609 100644
--- a/driver-spondoolies-sp30-p.h
+++ b/driver-spondoolies-sp30-p.h
@@ -45,7 +45,7 @@ typedef struct {
#define MAX_REQUESTS_SP30 30
#define MAX_RESPONDS_SP30 60
-#define MINERGATE_TOTAL_QUEUE_SP30 20
+#define MINERGATE_ADAPTER_QUEUE_SP30 40
typedef struct {
uint32_t work_id_in_sw;
diff --git a/driver-spondoolies-sp30.c b/driver-spondoolies-sp30.c
index ab3b150..91e2d25 100644
--- a/driver-spondoolies-sp30.c
+++ b/driver-spondoolies-sp30.c
@@ -79,7 +79,7 @@ static void send_minergate_pkt(const minergate_req_packet_sp30* mp_req, minergat
assert(mp_rsp->magic == 0xcaf4);
}
-static bool spondoolies_prepare(struct thr_info *thr)
+static bool spondoolies_prepare_sp30(struct thr_info *thr)
{
struct cgpu_info *spondoolies_sp30 = thr->cgpu;
struct timeval now;
@@ -129,10 +129,12 @@ static bool spondoolies_flush_queue(struct spond_adapter* a, bool flush_queue)
printf("%d + %d != %d\n", a->works_in_minergate_and_pending_tx, a->works_pending_tx,a->works_in_driver);
assert(a->works_in_minergate_and_pending_tx + a->works_pending_tx == a->works_in_driver);
send_minergate_pkt(a->mp_next_req, a->mp_last_rsp, a->socket_fd);
- if (flush_queue)
+ if (flush_queue) {
+ printf("FLUSH!\n");
a->mp_next_req->mask |= 0x02;
- else
+ } else {
a->mp_next_req->mask &= ~0x02;
+ }
a->mp_next_req->req_count = 0;
a->parse_resp = 1;
@@ -142,7 +144,7 @@ static bool spondoolies_flush_queue(struct spond_adapter* a, bool flush_queue)
return true;
}
-static void spondoolies_detect(__maybe_unused bool hotplug)
+static void spondoolies_detect_sp30(__maybe_unused bool hotplug)
{
struct cgpu_info *cgpu = calloc(1, sizeof(*cgpu));
struct device_drv *drv = &sp30_drv;
@@ -177,10 +179,10 @@ static void spondoolies_detect(__maybe_unused bool hotplug)
spondoolies_flush_queue(a, true);
spondoolies_flush_queue(a, true);
spondoolies_flush_queue(a, true);
- applog(LOG_DEBUG, "SPOND spondoolies_detect done");
+ applog(LOG_DEBUG, "SPOND spondoolies_detect_sp30 done");
}
-static struct api_data *spondoolies_api_stats(struct cgpu_info *cgpu)
+static struct api_data *spondoolies_api_stats_sp30(struct cgpu_info *cgpu)
{
struct spond_adapter *a = cgpu->device_data;
struct api_data *root = NULL;
@@ -216,7 +218,7 @@ static unsigned char get_leading_zeroes(const unsigned char *target)
}
#endif
-static void spondoolies_shutdown(__maybe_unused struct thr_info *thr)
+static void spondoolies_shutdown_sp30(__maybe_unused struct thr_info *thr)
{
}
@@ -245,17 +247,43 @@ static void fill_minergate_request(minergate_do_job_req_sp30* work, struct work
//printf("%d %d\n",work->leading_zeroes, (int)round(cg_work->work_difficulty));
work->work_id_in_sw = cg_work->subid;
work->ntime_limit = max_offset;
- printf("ID:%d, TS:%x\n",work->work_id_in_sw,work->timestamp);
+ //printf("ID:%d, TS:%x\n",work->work_id_in_sw,work->timestamp);
//work->ntime_offset = ntime_offset;
}
// returns true if queue full.
static struct timeval last_force_queue = {0};
-static bool spondoolies_queue_full(struct cgpu_info *cgpu)
+unsigned long usec_stamp ()
+{
+ static unsigned long long int first_usec = 0;
+ struct timeval tv;
+ unsigned long long int curr_usec;
+ gettimeofday(&tv, NULL);
+ curr_usec = tv.tv_sec * 1000000 + tv.tv_usec;
+ if (first_usec == 0) {
+ first_usec = curr_usec;
+ curr_usec = 0;
+ } else
+ curr_usec -= first_usec;
+ return curr_usec;
+}
+
+
+static bool spondoolies_queue_full_sp30(struct cgpu_info *cgpu)
{
+ struct spond_adapter* a = cgpu->device_data;
+ static int bla = 0;
+
+#if 1
+ if (!((bla++)%500)) {
+ printf("FAKE TEST FLUSH T:%d!\n",usec_stamp());
+ a->reset_mg_queue = 3;
+ }
+#endif
+
+
// Only once every 1/10 second do work.
- struct spond_adapter* a = cgpu->device_data;
int next_job_id, i;
struct timeval tv;
struct work *work;
@@ -270,11 +298,17 @@ static bool spondoolies_queue_full(struct cgpu_info *cgpu)
usec = (tv.tv_sec-last_force_queue.tv_sec) * 1000000;
usec += (tv.tv_usec-last_force_queue.tv_usec);
- if ((usec >= REQUEST_PERIOD) || (a->reset_mg_queue == 2) ||
- ((a->reset_mg_queue == 1) && (a->works_pending_tx == REQUEST_SIZE))) {
- spondoolies_flush_queue(a, (a->reset_mg_queue == 2));
- if (a->reset_mg_queue)
- a->reset_mg_queue--;
+ if ((usec >= REQUEST_PERIOD) ||
+ (a->reset_mg_queue == 3) || // push flush
+ ((a->reset_mg_queue == 2)) || // Fast pull
+ ((a->reset_mg_queue == 1) && (a->works_pending_tx == REQUEST_SIZE))) { // Fast push after flush
+ spondoolies_flush_queue(a, (a->reset_mg_queue == 3));
+ if (a->reset_mg_queue) {
+ //printf("FLUSH(%d) %d T:%d\n",a->reset_mg_queue , a->works_pending_tx, usec_stamp());
+ if (a->works_pending_tx || (a->reset_mg_queue == 3)) {
+ a->reset_mg_queue--;
+ }
+ }
last_force_queue = tv;
}
@@ -285,8 +319,10 @@ static bool spondoolies_queue_full(struct cgpu_info *cgpu)
}
// see if can take 1 more job.
- next_job_id = (a->current_job_id + 1) % MAX_JOBS_IN_MINERGATE_SP30;
- if (a->my_jobs[next_job_id].cgminer_work) {
+ // Must be smaller to prevent overflow.
+ assert(MAX_JOBS_PENDING_IN_MINERGATE_SP30 < MINERGATE_ADAPTER_QUEUE_SP30);
+ next_job_id = (a->current_job_id + 1) % MAX_JOBS_PENDING_IN_MINERGATE_SP30;
+ if (a->my_jobs[next_job_id].cgminer_work) {
ret = true;
goto return_unlock;
}
@@ -300,12 +336,12 @@ static bool spondoolies_queue_full(struct cgpu_info *cgpu)
work->thr_id = cgpu->thr[0]->id;
assert(work->thr);
- // Create 5 works using ntime increment
a->current_job_id = next_job_id;
work->subid = a->current_job_id;
// Get pointer for the request
a->my_jobs[a->current_job_id].cgminer_work = work;
a->my_jobs[a->current_job_id].state = SPONDWORK_STATE_IN_BUSY;
+ //printf("Push: %d\n", a->current_job_id);
int max_ntime_roll = (work->drv_rolllimit < MAX_NROLES) ? work->drv_rolllimit : MAX_NROLES;
@@ -317,6 +353,8 @@ static bool spondoolies_queue_full(struct cgpu_info *cgpu)
a->my_jobs[a->current_job_id].merkle_root = pkt_job->mrkle_root;
return_unlock:
+ //printf("D:P.TX:%d inD:%d\n", a->works_pending_tx, a->works_in_driver);
+
mutex_unlock(&a->lock);
return ret;
@@ -344,7 +382,7 @@ static void spond_poll_stats(struct cgpu_info *spond, struct spond_adapter *a)
// Return completed work to submit_nonce() and work_completed()
// struct timeval last_force_queue = {0};
-static int64_t spond_scanhash(struct thr_info *thr)
+static int64_t spond_scanhash_sp30(struct thr_info *thr)
{
struct cgpu_info *cgpu = thr->cgpu;
struct spond_adapter *a = cgpu->device_data;
@@ -375,15 +413,13 @@ static int64_t spond_scanhash(struct thr_info *thr)
if ((a->my_jobs[job_id].cgminer_work)) {
if (a->my_jobs[job_id].merkle_root == work->mrkle_root) {
assert(a->my_jobs[job_id].state == SPONDWORK_STATE_IN_BUSY);
- a->works_in_minergate_and_pending_tx--;
- a->works_in_driver--;
if (work->winner_nonce) {
bool __maybe_unused ok;
struct work *cg_work = a->my_jobs[job_id].cgminer_work;
ok = submit_noffset_nonce(cg_work->thr, cg_work, work->winner_nonce, work->ntime_offset);
- printf("OK on %d (+%d), none=%x = %d\n",
- work->work_id_in_sw, work->ntime_offset, htole32(work->winner_nonce), ok);
+ /*printf("WIn on %d (+%d), none=%x = %d\n",
+ work->work_id_in_sw, work->ntime_offset, htole32(work->winner_nonce), ok);*/
a->wins++;
}
@@ -391,10 +427,13 @@ static int64_t spond_scanhash(struct thr_info *thr)
//printf("Done with %d\n", job_id);
if (work->job_complete) {
+ //printf("Complete %d\n", job_id);
work_completed(a->cgpu, a->my_jobs[job_id].cgminer_work);
a->good++;
a->my_jobs[job_id].cgminer_work = NULL;
a->my_jobs[job_id].state = SPONDWORK_STATE_EMPTY;
+ a->works_in_minergate_and_pending_tx--;
+ a->works_in_driver--;
}
} else {
@@ -417,12 +456,12 @@ static int64_t spond_scanhash(struct thr_info *thr)
}
// Remove all work from queue
-static void spond_flush_work(struct cgpu_info *cgpu)
+static void spond_flush_work_sp30(struct cgpu_info *cgpu)
{
struct spond_adapter *a = cgpu->device_data;
-
+ //printf("GOT FLUSH!%d\n");
mutex_lock(&a->lock);
- a->reset_mg_queue = 2;
+ a->reset_mg_queue = 3;
mutex_unlock(&a->lock);
}
@@ -431,12 +470,12 @@ struct device_drv sp30_drv = {
.dname = "Sp30",
.name = "S30",
.max_diff = 64.0, // Limit max diff to get some nonces back regardless
- .drv_detect = spondoolies_detect,
- .get_api_stats = spondoolies_api_stats,
- .thread_prepare = spondoolies_prepare,
- .thread_shutdown = spondoolies_shutdown,
+ .drv_detect = spondoolies_detect_sp30,
+ .get_api_stats = spondoolies_api_stats_sp30,
+ .thread_prepare = spondoolies_prepare_sp30,
+ .thread_shutdown = spondoolies_shutdown_sp30,
.hash_work = hash_queued_work,
- .queue_full = spondoolies_queue_full,
- .scanwork = spond_scanhash,
- .flush_work = spond_flush_work,
+ .queue_full = spondoolies_queue_full_sp30,
+ .scanwork = spond_scanhash_sp30,
+ .flush_work = spond_flush_work_sp30,
};
diff --git a/driver-spondoolies-sp30.h b/driver-spondoolies-sp30.h
index 3c336fa..c7ecc10 100644
--- a/driver-spondoolies-sp30.h
+++ b/driver-spondoolies-sp30.h
@@ -26,9 +26,10 @@ typedef enum spond_work_state {
SPONDWORK_STATE_IN_BUSY,
} SPONDWORK_STATE;
-#define MAX_JOBS_IN_MINERGATE_SP30 MINERGATE_TOTAL_QUEUE_SP30 // 1.5 sec worth of jobs
+#define MAX_JOBS_PENDING_IN_MINERGATE_SP30 30
#define MAX_NROLES 60
+
typedef struct {
struct work *cgminer_work;
SPONDWORK_STATE state;
@@ -37,6 +38,8 @@ typedef struct {
int job_id;
} spond_driver_work_sp30;
+
+
struct spond_adapter {
pthread_mutex_t lock;
ADAPTER_STATE adapter_state;
@@ -53,12 +56,12 @@ struct spond_adapter {
int works_in_minergate_and_pending_tx;
int works_pending_tx;
int socket_fd;
- int reset_mg_queue; // 2=reset, 1=fast send, 0=nada
+ int reset_mg_queue; // 3=reset, 2=fast send 1 job, 1=fast send 10 jobs, 0=nada
int current_job_id;
int parse_resp;
minergate_req_packet_sp30* mp_next_req;
minergate_rsp_packet_sp30* mp_last_rsp;
- spond_driver_work_sp30 my_jobs[MAX_JOBS_IN_MINERGATE_SP30];
+ spond_driver_work_sp30 my_jobs[MAX_JOBS_PENDING_IN_MINERGATE_SP30];
// Temperature statistics
int temp_rate;