mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-13 06:01:03 +00:00
Reorder displayed devices to map to physical locations and initialise according to logical location instead.
This commit is contained in:
parent
5a0b4f62d0
commit
371e5f688a
37
adl.c
37
adl.c
@ -4,6 +4,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <curses.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "miner.h"
|
||||
#include "ADL_SDK/adl_sdk.h"
|
||||
@ -94,7 +95,7 @@ static inline void unlock_adl(void)
|
||||
|
||||
/* This looks for the twin GPU that has the fanspeed control of a non fanspeed
|
||||
* control GPU on dual GPU cards */
|
||||
static inline bool fanspeed_twin(struct gpu_adl *ga, struct gpu_adl *other_ga)
|
||||
static bool fanspeed_twin(struct gpu_adl *ga, struct gpu_adl *other_ga)
|
||||
{
|
||||
if (!other_ga->has_fanspeed)
|
||||
return false;
|
||||
@ -105,9 +106,35 @@ static inline bool fanspeed_twin(struct gpu_adl *ga, struct gpu_adl *other_ga)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void reorder_devices(int devices)
|
||||
{
|
||||
struct cgpu_info base_gpus[MAX_GPUDEVICES];
|
||||
struct cgpu_info *cgpu, *base_cgpu;
|
||||
int i, j;
|
||||
|
||||
memcpy(base_gpus, gpus, sizeof(gpus));
|
||||
for (i = 0; i < devices; i++) {
|
||||
cgpu = &gpus[i];
|
||||
|
||||
for (j = 0; j < devices; j++) {
|
||||
base_cgpu = &base_gpus[j];
|
||||
if (base_cgpu->virtual_gpu == i) {
|
||||
memcpy(cgpu, base_cgpu, sizeof(struct cgpu_info));
|
||||
/* Swap the parameters so the device displayed
|
||||
* matches its physical location, but its
|
||||
* initialised from its virtual location */
|
||||
cgpu->device_id = base_cgpu->virtual_gpu;
|
||||
cgpu->virtual_gpu = base_cgpu->device_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_adl(int nDevs)
|
||||
{
|
||||
int i, j, devices = 0, last_adapter = -1, gpu = 0, dummy = 0;
|
||||
bool map_devices = false;
|
||||
|
||||
#if defined (LINUX)
|
||||
hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL);
|
||||
@ -395,8 +422,14 @@ void init_adl(int nDevs)
|
||||
}
|
||||
}
|
||||
}
|
||||
applog(LOG_INFO, "GPU %d mapped to virtual GPU %d", gpu, cgpu->virtual_gpu);
|
||||
if (cgpu->virtual_gpu != gpu) {
|
||||
map_devices = true;
|
||||
applog(LOG_INFO, "GPU %d mapped to virtual GPU %d", gpu, cgpu->virtual_gpu);
|
||||
}
|
||||
}
|
||||
|
||||
if (map_devices)
|
||||
reorder_devices(devices);
|
||||
}
|
||||
|
||||
static float __gpu_temp(struct gpu_adl *ga)
|
||||
|
12
adl.h
12
adl.h
@ -20,18 +20,8 @@ void change_gpusettings(int gpu);
|
||||
void gpu_autotune(int gpu, bool *enable);
|
||||
void clear_adl(int nDevs);
|
||||
#else /* HAVE_ADL */
|
||||
#include "miner.h"
|
||||
#define adl_active (0)
|
||||
static inline void init_adl(int nDevs)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nDevs; i++) {
|
||||
struct cgpu_info *cgpu = &gpus[i];
|
||||
|
||||
cgpu->virtual_gpu = i;
|
||||
}
|
||||
}
|
||||
static inline void init_adl(int nDevs) {}
|
||||
static inline void change_gpusettings(int gpu) { }
|
||||
static inline void clear_adl(int nDevs) {}
|
||||
#endif
|
||||
|
24
main.c
24
main.c
@ -4837,6 +4837,8 @@ select_cgpu:
|
||||
cgpu->enabled = true;
|
||||
|
||||
for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
|
||||
int virtual_gpu;
|
||||
|
||||
thr = &thr_info[thr_id];
|
||||
cgpu = thr->cgpu;
|
||||
if (cgpu->api != &opencl_api)
|
||||
@ -4844,6 +4846,7 @@ select_cgpu:
|
||||
if (dev_from_id(thr_id) != gpu)
|
||||
continue;
|
||||
|
||||
virtual_gpu = cgpu->virtual_gpu;
|
||||
/* Lose this ram cause we may get stuck here! */
|
||||
//tq_freeze(thr->q);
|
||||
|
||||
@ -4855,7 +4858,7 @@ select_cgpu:
|
||||
//free(clState);
|
||||
|
||||
applog(LOG_INFO, "Reinit GPU thread %d", thr_id);
|
||||
clStates[thr_id] = initCl(gpu, name, sizeof(name));
|
||||
clStates[thr_id] = initCl(virtual_gpu, name, sizeof(name));
|
||||
if (!clStates[thr_id]) {
|
||||
applog(LOG_ERR, "Failed to reinit GPU thread %d", thr_id);
|
||||
goto select_cgpu;
|
||||
@ -5524,16 +5527,15 @@ static void opencl_detect()
|
||||
|
||||
nDevs = clDevicesNum();
|
||||
if (nDevs < 0) {
|
||||
applog(LOG_ERR, "clDevicesNum returned error, none usable");
|
||||
applog(LOG_ERR, "clDevicesNum returned error, no GPUs usable");
|
||||
nDevs = 0;
|
||||
}
|
||||
|
||||
if (MAX_DEVICES - total_devices < nDevs)
|
||||
nDevs = MAX_DEVICES - total_devices;
|
||||
|
||||
if (!nDevs) {
|
||||
if (!nDevs)
|
||||
return;
|
||||
}
|
||||
|
||||
if (opt_kernel) {
|
||||
if (strcmp(opt_kernel, "poclbm") && strcmp(opt_kernel, "phatk"))
|
||||
@ -5547,12 +5549,16 @@ static void opencl_detect()
|
||||
|
||||
for (i = 0; i < nDevs; ++i) {
|
||||
struct cgpu_info *cgpu;
|
||||
|
||||
cgpu = devices[total_devices++] = &gpus[i];
|
||||
cgpu->enabled = true;
|
||||
cgpu->api = &opencl_api;
|
||||
cgpu->device_id = i;
|
||||
cgpu->threads = opt_g_threads;
|
||||
}
|
||||
|
||||
if (!opt_noadl)
|
||||
init_adl(nDevs);
|
||||
}
|
||||
|
||||
static void reinit_opencl_device(struct cgpu_info *gpu)
|
||||
@ -5604,6 +5610,7 @@ static bool opencl_thread_prepare(struct thr_info *thr)
|
||||
struct timeval now;
|
||||
struct cgpu_info *cgpu = thr->cgpu;
|
||||
int gpu = cgpu->device_id;
|
||||
int virtual_gpu = cgpu->virtual_gpu;
|
||||
int i = thr->id;
|
||||
static bool failmessage = false;
|
||||
|
||||
@ -5614,8 +5621,8 @@ static bool opencl_thread_prepare(struct thr_info *thr)
|
||||
return false;
|
||||
}
|
||||
|
||||
applog(LOG_INFO, "Init GPU thread %i", i);
|
||||
clStates[i] = initCl(gpu, name, sizeof(name));
|
||||
applog(LOG_INFO, "Init GPU thread %i GPU %i virtual GPU %i", i, gpu, virtual_gpu);
|
||||
clStates[i] = initCl(virtual_gpu, name, sizeof(name));
|
||||
if (!clStates[i]) {
|
||||
enable_curses();
|
||||
applog(LOG_ERR, "Failed to init GPU thread %d, disabling device %d", i, gpu);
|
||||
@ -6172,10 +6179,7 @@ retry_pools:
|
||||
gettimeofday(&total_tv_end, NULL);
|
||||
get_datestamp(datestamp, &total_tv_start);
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
if (!opt_noadl)
|
||||
init_adl(nDevs);
|
||||
#else
|
||||
#ifndef HAVE_OPENCL
|
||||
opt_g_threads = 0;
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user