Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Refactor to abstract device-specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Jan 9, 2012
1 parent 9552226 commit 845961a
Show file tree
Hide file tree
Showing 4 changed files with 425 additions and 323 deletions.
9 changes: 9 additions & 0 deletions adl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -662,21 +662,21 @@ 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) {
strcpy(io_buffer, message(MSG_GPUMRE, id, isjson));
return;
}

gpu_devices[id] = true;
gpus[id].enabled = true;
tq_push(thr->q, &ping);

}
Expand Down Expand Up @@ -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));
}
Expand Down
Loading

0 comments on commit 845961a

Please sign in to comment.