mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-30 08:24:26 +00:00
Iterate and change virtual device order instead of shuffling ram.
This commit is contained in:
parent
371e5f688a
commit
3bc0583454
91
adl.c
91
adl.c
@ -28,6 +28,12 @@ const int opt_overheattemp = 85;
|
|||||||
const int opt_cutofftemp = 95;
|
const int opt_cutofftemp = 95;
|
||||||
static pthread_mutex_t adl_lock;
|
static pthread_mutex_t adl_lock;
|
||||||
|
|
||||||
|
struct gpu_adapters {
|
||||||
|
int iAdapterIndex;
|
||||||
|
int iBusNumber;
|
||||||
|
int id;
|
||||||
|
};
|
||||||
|
|
||||||
// Memory allocation function
|
// Memory allocation function
|
||||||
static void * __stdcall ADL_Main_Memory_Alloc(int iSize)
|
static void * __stdcall ADL_Main_Memory_Alloc(int iSize)
|
||||||
{
|
{
|
||||||
@ -106,35 +112,10 @@ static bool fanspeed_twin(struct gpu_adl *ga, struct gpu_adl *other_ga)
|
|||||||
return true;
|
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)
|
void init_adl(int nDevs)
|
||||||
{
|
{
|
||||||
int i, j, devices = 0, last_adapter = -1, gpu = 0, dummy = 0;
|
int i, j, devices = 0, last_adapter = -1, gpu = 0, dummy = 0;
|
||||||
bool map_devices = false;
|
struct gpu_adapters adapters[nDevs], vadapters[nDevs];
|
||||||
|
|
||||||
#if defined (LINUX)
|
#if defined (LINUX)
|
||||||
hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL);
|
hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL);
|
||||||
@ -220,12 +201,10 @@ void init_adl(int nDevs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Iterate over iNumberAdapters and find the lpAdapterID of real devices */
|
||||||
for (i = 0; i < iNumberAdapters; i++) {
|
for (i = 0; i < iNumberAdapters; i++) {
|
||||||
struct gpu_adl *ga;
|
|
||||||
int iAdapterIndex;
|
int iAdapterIndex;
|
||||||
int lpAdapterID;
|
int lpAdapterID;
|
||||||
ADLODPerformanceLevels *lpOdPerformanceLevels;
|
|
||||||
int lev;
|
|
||||||
|
|
||||||
iAdapterIndex = lpInfo[i].iAdapterIndex;
|
iAdapterIndex = lpInfo[i].iAdapterIndex;
|
||||||
/* Get unique identifier of the adapter, 0 means not AMD */
|
/* Get unique identifier of the adapter, 0 means not AMD */
|
||||||
@ -238,21 +217,53 @@ void init_adl(int nDevs)
|
|||||||
if (lpAdapterID == last_adapter)
|
if (lpAdapterID == last_adapter)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
adapters[devices].iAdapterIndex = iAdapterIndex;
|
||||||
|
adapters[devices].iBusNumber = lpInfo[i].iBusNumber;
|
||||||
|
adapters[devices].id = i;
|
||||||
|
|
||||||
/* We found a truly new adapter instead of a logical
|
/* We found a truly new adapter instead of a logical
|
||||||
* one. Now since there's no way of correlating the
|
* one. Now since there's no way of correlating the
|
||||||
* opencl enumerated devices and the ADL enumerated
|
* opencl enumerated devices and the ADL enumerated
|
||||||
* ones, we have to assume they're in the same order.*/
|
* ones, we have to assume they're in the same order.*/
|
||||||
if (++devices > nDevs) {
|
if (++devices > nDevs) {
|
||||||
applog(LOG_ERR, "ADL found more devices than opencl");
|
applog(LOG_ERR, "ADL found more devices than opencl");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpu = devices - 1;
|
|
||||||
last_adapter = lpAdapterID;
|
last_adapter = lpAdapterID;
|
||||||
|
|
||||||
if (!lpAdapterID) {
|
if (!lpAdapterID) {
|
||||||
applog(LOG_INFO, "Adapter returns ID 0 meaning not AMD. Card order might be confused");
|
applog(LOG_INFO, "Adapter returns ID 0 meaning not AMD. Card order might be confused");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < devices; i++) {
|
||||||
|
int j, virtual_gpu = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < devices; j++) {
|
||||||
|
if (i == j)
|
||||||
|
continue;
|
||||||
|
if (adapters[j].iBusNumber < adapters[i].iBusNumber)
|
||||||
|
virtual_gpu++;
|
||||||
|
}
|
||||||
|
vadapters[virtual_gpu].id = adapters[i].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (gpu = 0; gpu < devices; gpu++) {
|
||||||
|
struct gpu_adl *ga;
|
||||||
|
int iAdapterIndex;
|
||||||
|
int lpAdapterID;
|
||||||
|
ADLODPerformanceLevels *lpOdPerformanceLevels;
|
||||||
|
int lev;
|
||||||
|
|
||||||
|
i = vadapters[gpu].id;
|
||||||
|
iAdapterIndex = lpInfo[i].iAdapterIndex;
|
||||||
|
|
||||||
|
/* Get unique identifier of the adapter, 0 means not AMD */
|
||||||
|
if (ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID) != ADL_OK) {
|
||||||
|
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!gpus[gpu].enabled) {
|
if (!gpus[gpu].enabled) {
|
||||||
gpus[i].gpu_engine =
|
gpus[i].gpu_engine =
|
||||||
@ -393,10 +404,8 @@ void init_adl(int nDevs)
|
|||||||
|
|
||||||
for (gpu = 0; gpu < devices; gpu++) {
|
for (gpu = 0; gpu < devices; gpu++) {
|
||||||
struct gpu_adl *ga = &gpus[gpu].adl;
|
struct gpu_adl *ga = &gpus[gpu].adl;
|
||||||
struct cgpu_info *cgpu = &gpus[gpu];
|
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
cgpu->virtual_gpu = 0;
|
|
||||||
for (j = 0; j < devices; j++) {
|
for (j = 0; j < devices; j++) {
|
||||||
struct gpu_adl *other_ga;
|
struct gpu_adl *other_ga;
|
||||||
|
|
||||||
@ -405,11 +414,6 @@ void init_adl(int nDevs)
|
|||||||
|
|
||||||
other_ga = &gpus[j].adl;
|
other_ga = &gpus[j].adl;
|
||||||
|
|
||||||
/* Find the real GPU order based on their order
|
|
||||||
* according to their iBusNumber value */
|
|
||||||
if (other_ga->iBusNumber < ga->iBusNumber)
|
|
||||||
cgpu->virtual_gpu++;
|
|
||||||
|
|
||||||
/* Search for twin GPUs on a single card. They will be
|
/* Search for twin GPUs on a single card. They will be
|
||||||
* separated by one bus id and one will have fanspeed
|
* separated by one bus id and one will have fanspeed
|
||||||
* while the other won't. */
|
* while the other won't. */
|
||||||
@ -422,14 +426,7 @@ void init_adl(int nDevs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)
|
static float __gpu_temp(struct gpu_adl *ga)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user