mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-11 06:25:18 +00:00
Merge branch 'adl-extra-logging'
This commit is contained in:
commit
67d15f2843
83
adl.c
83
adl.c
@ -63,7 +63,7 @@ static void * __stdcall ADL_Main_Memory_Alloc(int iSize)
|
|||||||
// Optional Memory de-allocation function
|
// Optional Memory de-allocation function
|
||||||
static void __stdcall ADL_Main_Memory_Free (void **lpBuffer)
|
static void __stdcall ADL_Main_Memory_Free (void **lpBuffer)
|
||||||
{
|
{
|
||||||
if (*lpBuffer) {
|
if (*lpBuffer != NULL) {
|
||||||
free (*lpBuffer);
|
free (*lpBuffer);
|
||||||
*lpBuffer = NULL;
|
*lpBuffer = NULL;
|
||||||
}
|
}
|
||||||
@ -84,6 +84,8 @@ static ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get;
|
|||||||
static ADL_ADAPTER_ID_GET ADL_Adapter_ID_Get;
|
static ADL_ADAPTER_ID_GET ADL_Adapter_ID_Get;
|
||||||
static ADL_MAIN_CONTROL_REFRESH ADL_Main_Control_Refresh;
|
static ADL_MAIN_CONTROL_REFRESH ADL_Main_Control_Refresh;
|
||||||
static ADL_ADAPTER_VIDEOBIOSINFO_GET ADL_Adapter_VideoBiosInfo_Get;
|
static ADL_ADAPTER_VIDEOBIOSINFO_GET ADL_Adapter_VideoBiosInfo_Get;
|
||||||
|
static ADL_DISPLAY_DISPLAYINFO_GET ADL_Display_DisplayInfo_Get;
|
||||||
|
static ADL_ADAPTER_ACCESSIBILITY_GET ADL_Adapter_Accessibility_Get;
|
||||||
|
|
||||||
static ADL_OVERDRIVE_CAPS ADL_Overdrive_Caps;
|
static ADL_OVERDRIVE_CAPS ADL_Overdrive_Caps;
|
||||||
|
|
||||||
@ -119,6 +121,7 @@ static ADL_OVERDRIVE6_POWERCONTROL_SET ADL_Overdrive6_PowerControl_Set;
|
|||||||
#endif
|
#endif
|
||||||
static int iNumberAdapters;
|
static int iNumberAdapters;
|
||||||
static LPAdapterInfo lpInfo = NULL;
|
static LPAdapterInfo lpInfo = NULL;
|
||||||
|
static LPADLDisplayInfo lpAdlDisplayInfo = NULL;
|
||||||
|
|
||||||
int set_fanspeed(int gpu, int iFanSpeed);
|
int set_fanspeed(int gpu, int iFanSpeed);
|
||||||
static float __gpu_temp(struct gpu_adl *ga);
|
static float __gpu_temp(struct gpu_adl *ga);
|
||||||
@ -166,8 +169,10 @@ static bool init_overdrive5()
|
|||||||
!ADL_Overdrive5_ODPerformanceLevels_Get || !ADL_Overdrive5_ODPerformanceLevels_Set ||
|
!ADL_Overdrive5_ODPerformanceLevels_Get || !ADL_Overdrive5_ODPerformanceLevels_Set ||
|
||||||
!ADL_Overdrive5_PowerControl_Get || !ADL_Overdrive5_PowerControl_Set ||
|
!ADL_Overdrive5_PowerControl_Get || !ADL_Overdrive5_PowerControl_Set ||
|
||||||
!ADL_Overdrive5_FanSpeedToDefault_Set) {
|
!ADL_Overdrive5_FanSpeedToDefault_Set) {
|
||||||
applog(LOG_WARNING, "ATI ADL Overdrive5's API is missing");
|
applog(LOG_WARNING, "ATI ADL Overdrive5's API is missing or broken.");
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
applog(LOG_INFO, "ATI ADL Overdrive5 API found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -194,8 +199,10 @@ static bool init_overdrive6()
|
|||||||
!ADL_Overdrive6_PowerControl_Caps || !ADL_Overdrive6_PowerControlInfo_Get ||
|
!ADL_Overdrive6_PowerControl_Caps || !ADL_Overdrive6_PowerControlInfo_Get ||
|
||||||
!ADL_Overdrive6_PowerControl_Get || !ADL_Overdrive6_FanSpeed_Set ||
|
!ADL_Overdrive6_PowerControl_Get || !ADL_Overdrive6_FanSpeed_Set ||
|
||||||
!ADL_Overdrive6_State_Set || !ADL_Overdrive6_PowerControl_Set) {
|
!ADL_Overdrive6_State_Set || !ADL_Overdrive6_PowerControl_Set) {
|
||||||
applog(LOG_WARNING, "ATI ADL Overdrive6's API is missing");
|
applog(LOG_WARNING, "ATI ADL Overdrive6's API is missing or broken.");
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
applog(LOG_INFO, "ATI ADL Overdrive6 API found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -215,40 +222,46 @@ static bool prepare_adl(void)
|
|||||||
hDLL = LoadLibrary("atiadlxy.dll");
|
hDLL = LoadLibrary("atiadlxy.dll");
|
||||||
#endif
|
#endif
|
||||||
if (hDLL == NULL) {
|
if (hDLL == NULL) {
|
||||||
applog(LOG_INFO, "Unable to load ati adl library");
|
applog(LOG_INFO, "Unable to load ATI ADL library.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE) GetProcAddress(hDLL,"ADL_Main_Control_Create");
|
ADL_Main_Control_Create = (ADL_MAIN_CONTROL_CREATE) GetProcAddress(hDLL,"ADL_Main_Control_Create");
|
||||||
ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY) GetProcAddress(hDLL,"ADL_Main_Control_Destroy");
|
ADL_Main_Control_Destroy = (ADL_MAIN_CONTROL_DESTROY) GetProcAddress(hDLL,"ADL_Main_Control_Destroy");
|
||||||
ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET) GetProcAddress(hDLL,"ADL_Adapter_NumberOfAdapters_Get");
|
ADL_Adapter_NumberOfAdapters_Get = (ADL_ADAPTER_NUMBEROFADAPTERS_GET) GetProcAddress(hDLL,"ADL_Adapter_NumberOfAdapters_Get");
|
||||||
ADL_Adapter_AdapterInfo_Get = (ADL_ADAPTER_ADAPTERINFO_GET) GetProcAddress(hDLL,"ADL_Adapter_AdapterInfo_Get");
|
ADL_Adapter_AdapterInfo_Get = (ADL_ADAPTER_ADAPTERINFO_GET) GetProcAddress(hDLL,"ADL_Adapter_AdapterInfo_Get");
|
||||||
|
ADL_Display_DisplayInfo_Get = (ADL_DISPLAY_DISPLAYINFO_GET) GetProcAddress(hDLL,"ADL_Display_DisplayInfo_Get");
|
||||||
ADL_Adapter_ID_Get = (ADL_ADAPTER_ID_GET) GetProcAddress(hDLL,"ADL_Adapter_ID_Get");
|
ADL_Adapter_ID_Get = (ADL_ADAPTER_ID_GET) GetProcAddress(hDLL,"ADL_Adapter_ID_Get");
|
||||||
ADL_Main_Control_Refresh = (ADL_MAIN_CONTROL_REFRESH) GetProcAddress(hDLL, "ADL_Main_Control_Refresh");
|
ADL_Main_Control_Refresh = (ADL_MAIN_CONTROL_REFRESH) GetProcAddress(hDLL, "ADL_Main_Control_Refresh");
|
||||||
ADL_Adapter_VideoBiosInfo_Get = (ADL_ADAPTER_VIDEOBIOSINFO_GET)GetProcAddress(hDLL,"ADL_Adapter_VideoBiosInfo_Get");
|
ADL_Adapter_VideoBiosInfo_Get = (ADL_ADAPTER_VIDEOBIOSINFO_GET)GetProcAddress(hDLL,"ADL_Adapter_VideoBiosInfo_Get");
|
||||||
ADL_Overdrive_Caps = (ADL_OVERDRIVE_CAPS)GetProcAddress(hDLL, "ADL_Overdrive_Caps");
|
ADL_Overdrive_Caps = (ADL_OVERDRIVE_CAPS)GetProcAddress(hDLL, "ADL_Overdrive_Caps");
|
||||||
|
|
||||||
|
ADL_Adapter_Accessibility_Get = (ADL_ADAPTER_ACCESSIBILITY_GET)GetProcAddress(hDLL, "ADL_Adapter_Accessibility_Get");
|
||||||
|
|
||||||
if (!ADL_Main_Control_Create || !ADL_Main_Control_Destroy ||
|
if (!ADL_Main_Control_Create || !ADL_Main_Control_Destroy ||
|
||||||
!ADL_Adapter_NumberOfAdapters_Get || !ADL_Adapter_AdapterInfo_Get ||
|
!ADL_Adapter_NumberOfAdapters_Get || !ADL_Adapter_AdapterInfo_Get ||
|
||||||
|
!ADL_Display_DisplayInfo_Get ||
|
||||||
!ADL_Adapter_ID_Get || !ADL_Main_Control_Refresh ||
|
!ADL_Adapter_ID_Get || !ADL_Main_Control_Refresh ||
|
||||||
!ADL_Adapter_VideoBiosInfo_Get || !ADL_Overdrive_Caps) {
|
!ADL_Adapter_VideoBiosInfo_Get || !ADL_Overdrive_Caps) {
|
||||||
applog(LOG_WARNING, "ATI ADL's API is missing");
|
applog(LOG_WARNING, "ATI ADL API is missing or broken.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise ADL. The second parameter is 1, which means:
|
// Initialise ADL. The second parameter is 1, which means:
|
||||||
// retrieve adapter information only for adapters that are physically present and enabled in the system
|
// retrieve adapter information only for adapters that are physically present and enabled in the system
|
||||||
result = ADL_Main_Control_Create (ADL_Main_Memory_Alloc, 1);
|
result = ADL_Main_Control_Create(ADL_Main_Memory_Alloc, 1);
|
||||||
if (result != ADL_OK) {
|
if (result != ADL_OK) {
|
||||||
applog(LOG_INFO, "ADL Initialisation Error! Error %d!", result);
|
applog(LOG_INFO, "ADL initialisation error: %d!", result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = ADL_Main_Control_Refresh();
|
result = ADL_Main_Control_Refresh();
|
||||||
if (result != ADL_OK) {
|
if (result != ADL_OK) {
|
||||||
applog(LOG_INFO, "ADL Refresh Error! Error %d!", result);
|
applog(LOG_INFO, "ADL refresh error: %d!", result);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
init_overdrive5();
|
init_overdrive5();
|
||||||
|
init_overdrive6(); // FIXME: don't if ADL6 is not present
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -258,6 +271,10 @@ void init_adl(int nDevs)
|
|||||||
int result, i, j, devices = 0, last_adapter = -1, gpu = 0, dummy = 0;
|
int result, i, j, devices = 0, last_adapter = -1, gpu = 0, dummy = 0;
|
||||||
struct gpu_adapters adapters[MAX_GPUDEVICES], vadapters[MAX_GPUDEVICES];
|
struct gpu_adapters adapters[MAX_GPUDEVICES], vadapters[MAX_GPUDEVICES];
|
||||||
bool devs_match = true;
|
bool devs_match = true;
|
||||||
|
ADLBiosInfo BiosInfo;
|
||||||
|
int iNumDisplays;
|
||||||
|
|
||||||
|
applog(LOG_INFO, "Number of ADL devices: %d", nDevs);
|
||||||
|
|
||||||
if (unlikely(pthread_mutex_init(&adl_lock, NULL))) {
|
if (unlikely(pthread_mutex_init(&adl_lock, NULL))) {
|
||||||
applog(LOG_ERR, "Failed to init adl_lock in init_adl");
|
applog(LOG_ERR, "Failed to init adl_lock in init_adl");
|
||||||
@ -290,38 +307,53 @@ void init_adl(int nDevs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applog(LOG_INFO, "Found %d ADL adapters", iNumberAdapters);
|
||||||
|
|
||||||
/* Iterate over iNumberAdapters and find the lpAdapterID of real devices */
|
/* Iterate over iNumberAdapters and find the lpAdapterID of real devices */
|
||||||
for (i = 0; i < iNumberAdapters; i++) {
|
for (i = 0; i < iNumberAdapters; i++) {
|
||||||
int iAdapterIndex;
|
int iAdapterIndex;
|
||||||
int lpAdapterID;
|
int lpAdapterID;
|
||||||
|
|
||||||
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 */
|
||||||
result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID);
|
result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID);
|
||||||
|
|
||||||
|
if (ADL_Adapter_VideoBiosInfo_Get(iAdapterIndex, &BiosInfo) == ADL_ERR) {
|
||||||
|
applog(LOG_INFO, "ADL index %d, id %d - FAILED to get BIOS info", iAdapterIndex, lpAdapterID);
|
||||||
|
} else {
|
||||||
|
applog(LOG_INFO, "ADL index %d, id %d - BIOS partno.: %s, version: %s, date: %s", iAdapterIndex, lpAdapterID, BiosInfo.strPartNumber, BiosInfo.strVersion, BiosInfo.strDate);
|
||||||
|
}
|
||||||
|
|
||||||
if (result != ADL_OK) {
|
if (result != ADL_OK) {
|
||||||
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result);
|
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result);
|
||||||
if (result == -10)
|
if (result == -10)
|
||||||
applog(LOG_INFO, "This error says the device is not enabled");
|
applog(LOG_INFO, "(Device is not enabled.)");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Each adapter may have multiple entries */
|
/* Each adapter may have multiple entries */
|
||||||
if (lpAdapterID == last_adapter)
|
if (lpAdapterID == last_adapter) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
applog(LOG_DEBUG, "GPU %d "
|
applog(LOG_INFO, "GPU %d assigned: "
|
||||||
"iAdapterIndex %d "
|
"iAdapterIndex:%d "
|
||||||
"strUDID %s "
|
"iPresent:%d "
|
||||||
"iBusNumber %d "
|
"strUDID:%s "
|
||||||
"iDeviceNumber %d "
|
"iBusNumber:%d "
|
||||||
"iFunctionNumber %d "
|
"iDeviceNumber:%d "
|
||||||
"iVendorID %d "
|
"iDrvIndex:%d "
|
||||||
"strAdapterName %s ",
|
"iFunctionNumber:%d "
|
||||||
|
"iVendorID:%d "
|
||||||
|
"name:%s",
|
||||||
devices,
|
devices,
|
||||||
iAdapterIndex,
|
lpInfo[i].iAdapterIndex,
|
||||||
|
lpInfo[i].iPresent,
|
||||||
lpInfo[i].strUDID,
|
lpInfo[i].strUDID,
|
||||||
lpInfo[i].iBusNumber,
|
lpInfo[i].iBusNumber,
|
||||||
lpInfo[i].iDeviceNumber,
|
lpInfo[i].iDeviceNumber,
|
||||||
|
lpInfo[i].iDrvIndex,
|
||||||
lpInfo[i].iFunctionNumber,
|
lpInfo[i].iFunctionNumber,
|
||||||
lpInfo[i].iVendorID,
|
lpInfo[i].iVendorID,
|
||||||
lpInfo[i].strAdapterName);
|
lpInfo[i].strAdapterName);
|
||||||
@ -365,9 +397,10 @@ void init_adl(int nDevs)
|
|||||||
if (gpus[i].mapped) {
|
if (gpus[i].mapped) {
|
||||||
vadapters[gpus[i].virtual_adl].virtual_gpu = i;
|
vadapters[gpus[i].virtual_adl].virtual_gpu = i;
|
||||||
applog(LOG_INFO, "Mapping OpenCL device %d to ADL device %d", i, gpus[i].virtual_adl);
|
applog(LOG_INFO, "Mapping OpenCL device %d to ADL device %d", i, gpus[i].virtual_adl);
|
||||||
} else
|
} else {
|
||||||
gpus[i].virtual_adl = i;
|
gpus[i].virtual_adl = i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!devs_match) {
|
if (!devs_match) {
|
||||||
applog(LOG_ERR, "WARNING: Number of OpenCL and ADL devices did not match!");
|
applog(LOG_ERR, "WARNING: Number of OpenCL and ADL devices did not match!");
|
||||||
@ -451,6 +484,8 @@ void init_adl(int nDevs)
|
|||||||
ga->twin = NULL;
|
ga->twin = NULL;
|
||||||
ga->def_fan_valid = false;
|
ga->def_fan_valid = false;
|
||||||
|
|
||||||
|
applog(LOG_INFO, "ADL GPU %d is Adapter index %d and maps to adapter id %d", ga->gpu, ga->iAdapterIndex, ga->lpAdapterID);
|
||||||
|
|
||||||
if (ADL_Adapter_VideoBiosInfo_Get(iAdapterIndex, &BiosInfo) != ADL_ERR)
|
if (ADL_Adapter_VideoBiosInfo_Get(iAdapterIndex, &BiosInfo) != ADL_ERR)
|
||||||
applog(LOG_INFO, "GPU %d BIOS partno.: %s, version: %s, date: %s", gpu, BiosInfo.strPartNumber, BiosInfo.strVersion, BiosInfo.strDate);
|
applog(LOG_INFO, "GPU %d BIOS partno.: %s, version: %s, date: %s", gpu, BiosInfo.strPartNumber, BiosInfo.strVersion, BiosInfo.strDate);
|
||||||
|
|
||||||
@ -545,7 +580,7 @@ void init_adl(int nDevs)
|
|||||||
ga->has_fanspeed = true;
|
ga->has_fanspeed = true;
|
||||||
|
|
||||||
/* Save the fanspeed values as defaults in case we reset later */
|
/* Save the fanspeed values as defaults in case we reset later */
|
||||||
if (ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->DefFanSpeedValue) != ADL_OK)
|
if (ADL_Overdrive5_FanSpeed_Get(iAdapterIndex, 0, &ga->DefFanSpeedValue) != ADL_OK)
|
||||||
applog(LOG_INFO, "Failed to ADL_Overdrive5_FanSpeed_Get for default value");
|
applog(LOG_INFO, "Failed to ADL_Overdrive5_FanSpeed_Get for default value");
|
||||||
else
|
else
|
||||||
ga->def_fan_valid = true;
|
ga->def_fan_valid = true;
|
||||||
@ -556,12 +591,12 @@ void init_adl(int nDevs)
|
|||||||
gpus[gpu].gpu_fan = 85; /* Set a nominal upper limit of 85% */
|
gpus[gpu].gpu_fan = 85; /* Set a nominal upper limit of 85% */
|
||||||
|
|
||||||
/* Not fatal if powercontrol get fails */
|
/* Not fatal if powercontrol get fails */
|
||||||
if (ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy) != ADL_OK)
|
if (ADL_Overdrive5_PowerControl_Get(iAdapterIndex, &ga->iPercentage, &dummy) != ADL_OK)
|
||||||
applog(LOG_INFO, "Failed to ADL_Overdrive5_PowerControl_get");
|
applog(LOG_INFO, "Failed to ADL_Overdrive5_PowerControl_get");
|
||||||
|
|
||||||
if (gpus[gpu].gpu_powertune) {
|
if (gpus[gpu].gpu_powertune) {
|
||||||
ADL_Overdrive5_PowerControl_Set(ga->iAdapterIndex, gpus[gpu].gpu_powertune);
|
ADL_Overdrive5_PowerControl_Set(iAdapterIndex, gpus[gpu].gpu_powertune);
|
||||||
ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy);
|
ADL_Overdrive5_PowerControl_Get(iAdapterIndex, &ga->iPercentage, &dummy);
|
||||||
ga->managed = true;
|
ga->managed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user