Browse Source

Merge remote-tracking branch 'conman/master'

nfactor-troky
Kano 13 years ago
parent
commit
98d789bd93
  1. 64
      adl.c
  2. 4
      adl.h
  3. 10
      main.c
  4. 3
      miner.h
  5. 6
      util.c

64
adl.c

@ -66,7 +66,6 @@ static ADL_ADAPTER_NUMBEROFADAPTERS_GET ADL_Adapter_NumberOfAdapters_Get;
static ADL_ADAPTER_ADAPTERINFO_GET ADL_Adapter_AdapterInfo_Get; 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_OVERDRIVE5_TEMPERATURE_GET ADL_Overdrive5_Temperature_Get; static ADL_OVERDRIVE5_TEMPERATURE_GET ADL_Overdrive5_Temperature_Get;
static ADL_OVERDRIVE5_THERMALDEVICES_ENUM ADL_Overdrive5_ThermalDevices_Enum;
static ADL_OVERDRIVE5_CURRENTACTIVITY_GET ADL_Overdrive5_CurrentActivity_Get; static ADL_OVERDRIVE5_CURRENTACTIVITY_GET ADL_Overdrive5_CurrentActivity_Get;
static ADL_OVERDRIVE5_ODPARAMETERS_GET ADL_Overdrive5_ODParameters_Get; static ADL_OVERDRIVE5_ODPARAMETERS_GET ADL_Overdrive5_ODParameters_Get;
static ADL_OVERDRIVE5_FANSPEEDINFO_GET ADL_Overdrive5_FanSpeedInfo_Get; static ADL_OVERDRIVE5_FANSPEEDINFO_GET ADL_Overdrive5_FanSpeedInfo_Get;
@ -115,8 +114,9 @@ static bool fanspeed_twin(struct gpu_adl *ga, struct gpu_adl *other_ga)
void init_adl(int nDevs) void init_adl(int nDevs)
{ {
int 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;
#if defined (LINUX) #if defined (LINUX)
hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL); hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL);
@ -143,7 +143,6 @@ void init_adl(int nDevs)
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_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_Overdrive5_Temperature_Get = (ADL_OVERDRIVE5_TEMPERATURE_GET) GetProcAddress(hDLL,"ADL_Overdrive5_Temperature_Get"); ADL_Overdrive5_Temperature_Get = (ADL_OVERDRIVE5_TEMPERATURE_GET) GetProcAddress(hDLL,"ADL_Overdrive5_Temperature_Get");
ADL_Overdrive5_ThermalDevices_Enum = (ADL_OVERDRIVE5_THERMALDEVICES_ENUM) GetProcAddress(hDLL,"ADL_Overdrive5_ThermalDevices_Enum");
ADL_Overdrive5_CurrentActivity_Get = (ADL_OVERDRIVE5_CURRENTACTIVITY_GET) GetProcAddress(hDLL, "ADL_Overdrive5_CurrentActivity_Get"); ADL_Overdrive5_CurrentActivity_Get = (ADL_OVERDRIVE5_CURRENTACTIVITY_GET) GetProcAddress(hDLL, "ADL_Overdrive5_CurrentActivity_Get");
ADL_Overdrive5_ODParameters_Get = (ADL_OVERDRIVE5_ODPARAMETERS_GET) GetProcAddress(hDLL, "ADL_Overdrive5_ODParameters_Get"); ADL_Overdrive5_ODParameters_Get = (ADL_OVERDRIVE5_ODPARAMETERS_GET) GetProcAddress(hDLL, "ADL_Overdrive5_ODParameters_Get");
ADL_Overdrive5_FanSpeedInfo_Get = (ADL_OVERDRIVE5_FANSPEEDINFO_GET) GetProcAddress(hDLL, "ADL_Overdrive5_FanSpeedInfo_Get"); ADL_Overdrive5_FanSpeedInfo_Get = (ADL_OVERDRIVE5_FANSPEEDINFO_GET) GetProcAddress(hDLL, "ADL_Overdrive5_FanSpeedInfo_Get");
@ -159,7 +158,7 @@ void init_adl(int nDevs)
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_Adapter_ID_Get || !ADL_Overdrive5_Temperature_Get || !ADL_Adapter_ID_Get || !ADL_Overdrive5_Temperature_Get ||
!ADL_Overdrive5_ThermalDevices_Enum || !ADL_Overdrive5_CurrentActivity_Get || !ADL_Overdrive5_CurrentActivity_Get ||
!ADL_Overdrive5_ODParameters_Get || !ADL_Overdrive5_FanSpeedInfo_Get || !ADL_Overdrive5_ODParameters_Get || !ADL_Overdrive5_FanSpeedInfo_Get ||
!ADL_Overdrive5_FanSpeed_Get || !ADL_Overdrive5_FanSpeed_Set || !ADL_Overdrive5_FanSpeed_Get || !ADL_Overdrive5_FanSpeed_Set ||
!ADL_Overdrive5_ODPerformanceLevels_Get || !ADL_Overdrive5_ODPerformanceLevels_Set || !ADL_Overdrive5_ODPerformanceLevels_Get || !ADL_Overdrive5_ODPerformanceLevels_Set ||
@ -171,19 +170,22 @@ void init_adl(int nDevs)
// 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
if (ADL_Main_Control_Create (ADL_Main_Memory_Alloc, 1) != ADL_OK) { result = ADL_Main_Control_Create (ADL_Main_Memory_Alloc, 1);
applog(LOG_INFO, "ADL Initialisation Error!"); if (result != ADL_OK) {
applog(LOG_INFO, "ADL Initialisation Error! Error %d!", result);
return ; return ;
} }
if (ADL_Main_Control_Refresh() != ADL_OK) { result = ADL_Main_Control_Refresh();
applog(LOG_INFO, "ADL Refresh Error!"); if (result != ADL_OK) {
applog(LOG_INFO, "ADL Refresh Error! Error %d!", result);
return ; return ;
} }
// Obtain the number of adapters for the system // Obtain the number of adapters for the system
if (ADL_Adapter_NumberOfAdapters_Get ( &iNumberAdapters ) != ADL_OK) { result = ADL_Adapter_NumberOfAdapters_Get (&iNumberAdapters);
applog(LOG_INFO, "Cannot get the number of adapters!\n"); if (result != ADL_OK) {
applog(LOG_INFO, "Cannot get the number of adapters! Error %d!", result);
return ; return ;
} }
@ -193,8 +195,9 @@ void init_adl(int nDevs)
lpInfo->iSize = sizeof(lpInfo); lpInfo->iSize = sizeof(lpInfo);
// Get the AdapterInfo structure for all adapters in the system // Get the AdapterInfo structure for all adapters in the system
if (ADL_Adapter_AdapterInfo_Get (lpInfo, sizeof (AdapterInfo) * iNumberAdapters) != ADL_OK) { result = ADL_Adapter_AdapterInfo_Get (lpInfo, sizeof (AdapterInfo) * iNumberAdapters);
applog(LOG_INFO, "ADL_Adapter_AdapterInfo_Get Error!"); if (result != ADL_OK) {
applog(LOG_INFO, "ADL_Adapter_AdapterInfo_Get Error! Error %d", result);
return ; return ;
} }
} else { } else {
@ -209,8 +212,9 @@ void init_adl(int nDevs)
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 */
if (ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID) != ADL_OK) { result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID);
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get"); if (result != ADL_OK) {
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result);
continue; continue;
} }
@ -245,8 +249,11 @@ void init_adl(int nDevs)
* 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; applog(LOG_ERR, "There is possibly at least one GPU that doesn't support OpenCL");
devs_match = false;
devices = nDevs;
break;
} }
last_adapter = lpAdapterID; last_adapter = lpAdapterID;
@ -256,6 +263,7 @@ void init_adl(int nDevs)
} }
} }
if (devs_match && devices == nDevs) {
/* Windows has some kind of random ordering for bus number IDs and /* Windows has some kind of random ordering for bus number IDs and
* ordering the GPUs according to ascending order fixes it. Linux * ordering the GPUs according to ascending order fixes it. Linux
* has usually sequential but decreasing order instead! */ * has usually sequential but decreasing order instead! */
@ -272,9 +280,20 @@ void init_adl(int nDevs)
#endif #endif
virtual_gpu++; virtual_gpu++;
} }
if (virtual_gpu != i)
applog(LOG_INFO, "Mapping device %d to GPU %d according to Bus Number order",
i, virtual_gpu);
vadapters[virtual_gpu].virtual_gpu = i; vadapters[virtual_gpu].virtual_gpu = i;
vadapters[virtual_gpu].id = adapters[i].id; vadapters[virtual_gpu].id = adapters[i].id;
} }
} else {
if (devices < nDevs) {
applog(LOG_ERR, "ADL found less devices than opencl!");
applog(LOG_ERR, "There is possibly more than one display attached to a GPU");
}
applog(LOG_ERR, "WARNING: Number of OpenCL and ADL devices does not match!");
applog(LOG_ERR, "Hardware monitoring may NOT match up with devices!");
}
for (gpu = 0; gpu < devices; gpu++) { for (gpu = 0; gpu < devices; gpu++) {
struct gpu_adl *ga; struct gpu_adl *ga;
@ -288,8 +307,9 @@ void init_adl(int nDevs)
gpus[gpu].virtual_gpu = vadapters[gpu].virtual_gpu; gpus[gpu].virtual_gpu = vadapters[gpu].virtual_gpu;
/* Get unique identifier of the adapter, 0 means not AMD */ /* Get unique identifier of the adapter, 0 means not AMD */
if (ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID) != ADL_OK) { result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID);
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get"); if (result != ADL_OK) {
applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result);
continue; continue;
} }
@ -302,6 +322,7 @@ void init_adl(int nDevs)
continue; continue;
} }
applog(LOG_INFO, "GPU %d %s hardware monitoring enabled", gpu, lpInfo[i].strAdapterName);
gpus[gpu].has_adl = true; gpus[gpu].has_adl = true;
/* Flag adl as active if any card is successfully activated */ /* Flag adl as active if any card is successfully activated */
adl_active = true; adl_active = true;
@ -316,10 +337,6 @@ void init_adl(int nDevs)
ga->DefPerfLev = NULL; ga->DefPerfLev = NULL;
ga->twin = NULL; ga->twin = NULL;
ga->lpThermalControllerInfo.iSize=sizeof(ADLThermalControllerInfo);
if (ADL_Overdrive5_ThermalDevices_Enum(iAdapterIndex, 0, &ga->lpThermalControllerInfo) != ADL_OK)
applog(LOG_INFO, "Failed to ADL_Overdrive5_ThermalDevices_Enum");
ga->lpOdParameters.iSize = sizeof(ADLODParameters); ga->lpOdParameters.iSize = sizeof(ADLODParameters);
if (ADL_Overdrive5_ODParameters_Get(iAdapterIndex, &ga->lpOdParameters) != ADL_OK) if (ADL_Overdrive5_ODParameters_Get(iAdapterIndex, &ga->lpOdParameters) != ADL_OK)
applog(LOG_INFO, "Failed to ADL_Overdrive5_ODParameters_Get"); applog(LOG_INFO, "Failed to ADL_Overdrive5_ODParameters_Get");
@ -1136,8 +1153,9 @@ void change_autosettings(int gpu)
} }
} }
void change_gpusettings(int gpu) void change_gpusettings(int disp_gpu)
{ {
int gpu = gpus[disp_gpu].virtual_gpu;
struct gpu_adl *ga = &gpus[gpu].adl; struct gpu_adl *ga = &gpus[gpu].adl;
float fval, fmin = 0, fmax = 0; float fval, fmin = 0, fmax = 0;
int val, imin = 0, imax = 0; int val, imin = 0, imax = 0;

4
adl.h

@ -16,13 +16,13 @@ int gpu_fanspeed(int gpu);
int gpu_fanpercent(int gpu); int gpu_fanpercent(int gpu);
bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc,
int *activity, int *fanspeed, int *fanpercent, int *powertune); int *activity, int *fanspeed, int *fanpercent, int *powertune);
void change_gpusettings(int gpu); void change_gpusettings(int disp_gpu);
void gpu_autotune(int gpu, bool *enable); void gpu_autotune(int gpu, bool *enable);
void clear_adl(int nDevs); void clear_adl(int nDevs);
#else /* HAVE_ADL */ #else /* HAVE_ADL */
#define adl_active (0) #define adl_active (0)
static inline void init_adl(int nDevs) {} static inline void init_adl(int nDevs) {}
static inline void change_gpusettings(int gpu) { } static inline void change_gpusettings(int disp_gpu) { }
static inline void clear_adl(int nDevs) {} static inline void clear_adl(int nDevs) {}
#endif #endif
#endif #endif

10
main.c

@ -997,11 +997,13 @@ static char *set_float_0_to_99(const char *arg, float *f)
return NULL; return NULL;
} }
#ifdef USE_BITFORCE
static char *add_serial(char *arg) static char *add_serial(char *arg)
{ {
string_elist_add(arg, &scan_devices); string_elist_add(arg, &scan_devices);
return NULL; return NULL;
} }
#endif
static char *set_devices(char *arg) static char *set_devices(char *arg)
{ {
@ -2329,7 +2331,7 @@ static bool submit_upstream_work(const struct work *work)
curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1); curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
/* issue JSON-RPC request */ /* issue JSON-RPC request */
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, s, false, false, &rolltime, pool); val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, s, false, false, &rolltime, pool, true);
if (unlikely(!val)) { if (unlikely(!val)) {
applog(LOG_INFO, "submit_upstream_work json_rpc_call failed"); applog(LOG_INFO, "submit_upstream_work json_rpc_call failed");
if (!pool_tset(pool, &pool->submit_fail)) { if (!pool_tset(pool, &pool->submit_fail)) {
@ -2480,7 +2482,7 @@ retry:
* failure so retry a few times before giving up */ * failure so retry a few times before giving up */
while (!val && retries++ < 3) { while (!val && retries++ < 3) {
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req, val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
false, false, &work->rolltime, pool); false, false, &work->rolltime, pool, false);
if (donor(pool) && !val) { if (donor(pool) && !val) {
if (opt_debug) if (opt_debug)
applog(LOG_DEBUG, "Donor pool lagging"); applog(LOG_DEBUG, "Donor pool lagging");
@ -3991,7 +3993,7 @@ static bool pool_active(struct pool *pool, bool pinging)
applog(LOG_INFO, "Testing pool %s", pool->rpc_url); applog(LOG_INFO, "Testing pool %s", pool->rpc_url);
val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req, val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req,
true, false, &rolltime, pool); true, false, &rolltime, pool, false);
if (val) { if (val) {
struct work *work = make_work(); struct work *work = make_work();
@ -4719,7 +4721,7 @@ new_longpoll:
while (1) { while (1) {
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req, val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req,
false, true, &rolltime, pool); false, true, &rolltime, pool, false);
if (likely(val)) { if (likely(val)) {
convert_to_work(val, rolltime, pool); convert_to_work(val, rolltime, pool);
failures = 0; failures = 0;

3
miner.h

@ -207,7 +207,6 @@ struct gpu_adl {
ADLFanSpeedInfo lpFanSpeedInfo; ADLFanSpeedInfo lpFanSpeedInfo;
ADLFanSpeedValue lpFanSpeedValue; ADLFanSpeedValue lpFanSpeedValue;
ADLFanSpeedValue DefFanSpeedValue; ADLFanSpeedValue DefFanSpeedValue;
ADLThermalControllerInfo lpThermalControllerInfo;
int iEngineClock; int iEngineClock;
int iMemoryClock; int iMemoryClock;
@ -454,7 +453,7 @@ extern pthread_rwlock_t netacc_lock;
extern const uint32_t sha256_init_state[]; extern const uint32_t sha256_init_state[];
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass, extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
const char *rpc_req, bool, bool, bool *, const char *rpc_req, bool, bool, bool *,
struct pool *pool); struct pool *pool, bool);
extern char *bin2hex(const unsigned char *p, size_t len); extern char *bin2hex(const unsigned char *p, size_t len);
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len); extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);

6
util.c

@ -305,7 +305,7 @@ static void set_nettime(void)
json_t *json_rpc_call(CURL *curl, const char *url, json_t *json_rpc_call(CURL *curl, const char *url,
const char *userpass, const char *rpc_req, const char *userpass, const char *rpc_req,
bool probe, bool longpoll, bool *rolltime, bool probe, bool longpoll, bool *rolltime,
struct pool *pool) struct pool *pool, bool share)
{ {
json_t *val, *err_val, *res_val; json_t *val, *err_val, *res_val;
int rc; int rc;
@ -336,7 +336,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_ENCODING, ""); curl_easy_setopt(curl, CURLOPT_ENCODING, "");
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
if (!opt_delaynet) if (!opt_delaynet || share)
curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1); curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, all_data_cb); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, all_data_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &all_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &all_data);
@ -380,7 +380,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
if (opt_delaynet) { if (opt_delaynet && !share) {
long long now_msecs, last_msecs; long long now_msecs, last_msecs;
struct timeval now, last; struct timeval now, last;

Loading…
Cancel
Save