Browse Source

Refactor to abstract device-specific code

nfactor-troky
Luke Dashjr 13 years ago
parent
commit
845961af66
  1. 9
      adl.c
  2. 12
      api.c
  3. 698
      main.c
  4. 29
      miner.h

9
adl.c

@ -212,6 +212,15 @@ void init_adl(int nDevs)
continue; continue;
} }
if (!gpus[gpu].enabled) {
gpus[i].gpu_engine =
gpus[i].gpu_memclock =
gpus[i].gpu_vddc =
gpus[i].gpu_fan =
gpus[i].gpu_powertune = 0;
continue;
}
gpus[gpu].has_adl = true; gpus[gpu].has_adl = true;
/* Flag adl as active if any card is successfully activated */ /* Flag adl as active if any card is successfully activated */
adl_active = true; adl_active = true;

12
api.c

@ -387,7 +387,7 @@ void gpustatus(int gpu, bool isjson)
#endif #endif
gt = gv = gm = gc = ga = gf = gp = pt = 0; gt = gv = gm = gc = ga = gf = gp = pt = 0;
if (gpu_devices[gpu]) if (cgpu->enabled)
enabled = (char *)YES; enabled = (char *)YES;
else else
enabled = (char *)NO; enabled = (char *)NO;
@ -662,13 +662,13 @@ void gpuenable(SOCKETTYPE c, char *param, bool isjson)
return; return;
} }
if (gpu_devices[id]) { if (gpus[id].enabled) {
strcpy(io_buffer, message(MSG_ALRENA, id, isjson)); strcpy(io_buffer, message(MSG_ALRENA, id, isjson));
return; return;
} }
for (i = 0; i < gpu_threads; i++) { for (i = 0; i < gpu_threads; i++) {
gpu = thr_info[i].cgpu->cpu_gpu; gpu = thr_info[i].cgpu->device_id;
if (gpu == id) { if (gpu == id) {
thr = &thr_info[i]; thr = &thr_info[i];
if (thr->cgpu->status != LIFE_WELL) { if (thr->cgpu->status != LIFE_WELL) {
@ -676,7 +676,7 @@ void gpuenable(SOCKETTYPE c, char *param, bool isjson)
return; return;
} }
gpu_devices[id] = true; gpus[id].enabled = true;
tq_push(thr->q, &ping); tq_push(thr->q, &ping);
} }
@ -705,12 +705,12 @@ void gpudisable(SOCKETTYPE c, char *param, bool isjson)
return; return;
} }
if (!gpu_devices[id]) { if (!gpus[id].enabled) {
strcpy(io_buffer, message(MSG_ALRDIS, id, isjson)); strcpy(io_buffer, message(MSG_ALRDIS, id, isjson));
return; return;
} }
gpu_devices[id] = false; gpus[id].enabled = false;
strcpy(io_buffer, message(MSG_GPUDIS, id, isjson)); strcpy(io_buffer, message(MSG_GPUDIS, id, isjson));
} }

698
main.c

File diff suppressed because it is too large Load Diff

29
miner.h

@ -208,9 +208,28 @@ struct gpu_adl {
}; };
#endif #endif
struct cgpu_info;
struct thr_info;
struct device_api {
char*name;
// API-global functions
void (*api_detect)();
// Device-specific functions
void (*reinit_device)(struct cgpu_info*);
void (*get_statline)(char*, struct cgpu_info*);
// Thread-specific functions
void (*thread_start)(struct thr_info*);
};
struct cgpu_info { struct cgpu_info {
int is_gpu; int cgminer_id;
int cpu_gpu; struct device_api *api;
int device_id;
bool enabled;
int accepted; int accepted;
int rejected; int rejected;
int hw_errors; int hw_errors;
@ -221,6 +240,8 @@ struct cgpu_info {
char init[40]; char init[40];
struct timeval last_message_tv; struct timeval last_message_tv;
int threads;
bool dynamic; bool dynamic;
int intensity; int intensity;
#ifdef HAVE_ADL #ifdef HAVE_ADL
@ -431,6 +452,7 @@ extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, flo
extern void api(void); extern void api(void);
#define MAX_GPUDEVICES 16 #define MAX_GPUDEVICES 16
#define MAX_DEVICES 32
#define MAX_POOLS (32) #define MAX_POOLS (32)
extern int nDevs; extern int nDevs;
@ -444,9 +466,10 @@ extern struct work_restart *work_restart;
extern struct cgpu_info gpus[MAX_GPUDEVICES]; extern struct cgpu_info gpus[MAX_GPUDEVICES];
extern int gpu_threads; extern int gpu_threads;
extern double total_secs; extern double total_secs;
extern bool gpu_devices[MAX_GPUDEVICES];
extern int mining_threads; extern int mining_threads;
extern struct cgpu_info *cpus; extern struct cgpu_info *cpus;
extern int total_devices;
extern struct cgpu_info *devices[];
extern int total_pools; extern int total_pools;
extern struct pool *pools[MAX_POOLS]; extern struct pool *pools[MAX_POOLS];
extern const char *algo_names[]; extern const char *algo_names[];

Loading…
Cancel
Save