mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-13 06:01:03 +00:00
Refactor to abstract device-specific code
This commit is contained in:
parent
95522262ed
commit
845961af66
9
adl.c
9
adl.c
@ -212,6 +212,15 @@ void init_adl(int nDevs)
|
||||
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;
|
||||
/* Flag adl as active if any card is successfully activated */
|
||||
adl_active = true;
|
||||
|
12
api.c
12
api.c
@ -387,7 +387,7 @@ void gpustatus(int gpu, bool isjson)
|
||||
#endif
|
||||
gt = gv = gm = gc = ga = gf = gp = pt = 0;
|
||||
|
||||
if (gpu_devices[gpu])
|
||||
if (cgpu->enabled)
|
||||
enabled = (char *)YES;
|
||||
else
|
||||
enabled = (char *)NO;
|
||||
@ -662,13 +662,13 @@ void gpuenable(SOCKETTYPE c, char *param, bool isjson)
|
||||
return;
|
||||
}
|
||||
|
||||
if (gpu_devices[id]) {
|
||||
if (gpus[id].enabled) {
|
||||
strcpy(io_buffer, message(MSG_ALRENA, id, isjson));
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < gpu_threads; i++) {
|
||||
gpu = thr_info[i].cgpu->cpu_gpu;
|
||||
gpu = thr_info[i].cgpu->device_id;
|
||||
if (gpu == id) {
|
||||
thr = &thr_info[i];
|
||||
if (thr->cgpu->status != LIFE_WELL) {
|
||||
@ -676,7 +676,7 @@ void gpuenable(SOCKETTYPE c, char *param, bool isjson)
|
||||
return;
|
||||
}
|
||||
|
||||
gpu_devices[id] = true;
|
||||
gpus[id].enabled = true;
|
||||
tq_push(thr->q, &ping);
|
||||
|
||||
}
|
||||
@ -705,12 +705,12 @@ void gpudisable(SOCKETTYPE c, char *param, bool isjson)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gpu_devices[id]) {
|
||||
if (!gpus[id].enabled) {
|
||||
strcpy(io_buffer, message(MSG_ALRDIS, id, isjson));
|
||||
return;
|
||||
}
|
||||
|
||||
gpu_devices[id] = false;
|
||||
gpus[id].enabled = false;
|
||||
|
||||
strcpy(io_buffer, message(MSG_GPUDIS, id, isjson));
|
||||
}
|
||||
|
29
miner.h
29
miner.h
@ -208,9 +208,28 @@ struct gpu_adl {
|
||||
};
|
||||
#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 {
|
||||
int is_gpu;
|
||||
int cpu_gpu;
|
||||
int cgminer_id;
|
||||
struct device_api *api;
|
||||
int device_id;
|
||||
bool enabled;
|
||||
int accepted;
|
||||
int rejected;
|
||||
int hw_errors;
|
||||
@ -221,6 +240,8 @@ struct cgpu_info {
|
||||
char init[40];
|
||||
struct timeval last_message_tv;
|
||||
|
||||
int threads;
|
||||
|
||||
bool dynamic;
|
||||
int intensity;
|
||||
#ifdef HAVE_ADL
|
||||
@ -431,6 +452,7 @@ extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, flo
|
||||
extern void api(void);
|
||||
|
||||
#define MAX_GPUDEVICES 16
|
||||
#define MAX_DEVICES 32
|
||||
#define MAX_POOLS (32)
|
||||
|
||||
extern int nDevs;
|
||||
@ -444,9 +466,10 @@ extern struct work_restart *work_restart;
|
||||
extern struct cgpu_info gpus[MAX_GPUDEVICES];
|
||||
extern int gpu_threads;
|
||||
extern double total_secs;
|
||||
extern bool gpu_devices[MAX_GPUDEVICES];
|
||||
extern int mining_threads;
|
||||
extern struct cgpu_info *cpus;
|
||||
extern int total_devices;
|
||||
extern struct cgpu_info *devices[];
|
||||
extern int total_pools;
|
||||
extern struct pool *pools[MAX_POOLS];
|
||||
extern const char *algo_names[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user