From 4ae0aad113452f6459042109c2d52ba8c6e560a2 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 08:05:36 +1100 Subject: [PATCH 01/10] Revert "Set iSize for thermal device enum first." This reverts commit 990bb4a994261fb0aca8a6bd1b324a3007583207. Thermal devices is not used. 1st of 3 reverts. --- adl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/adl.c b/adl.c index aad827bd..a7cd0ebf 100644 --- a/adl.c +++ b/adl.c @@ -316,7 +316,6 @@ void init_adl(int nDevs) ga->DefPerfLev = 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"); From 430a19543ede2baedfc98148d31585a0d041a737 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 08:06:00 +1100 Subject: [PATCH 02/10] Revert "Read off lpThermalControllerInfo from each ADL device." This reverts commit 2d29cdb6117be29ff6353d94a6be0784a588fdb6. --- adl.c | 3 --- miner.h | 1 - 2 files changed, 4 deletions(-) diff --git a/adl.c b/adl.c index a7cd0ebf..5a19c741 100644 --- a/adl.c +++ b/adl.c @@ -316,9 +316,6 @@ void init_adl(int nDevs) ga->DefPerfLev = NULL; ga->twin = NULL; - 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); if (ADL_Overdrive5_ODParameters_Get(iAdapterIndex, &ga->lpOdParameters) != ADL_OK) applog(LOG_INFO, "Failed to ADL_Overdrive5_ODParameters_Get"); diff --git a/miner.h b/miner.h index d91b82f9..47e773d8 100644 --- a/miner.h +++ b/miner.h @@ -206,7 +206,6 @@ struct gpu_adl { ADLFanSpeedInfo lpFanSpeedInfo; ADLFanSpeedValue lpFanSpeedValue; ADLFanSpeedValue DefFanSpeedValue; - ADLThermalControllerInfo lpThermalControllerInfo; int iEngineClock; int iMemoryClock; From cdcaaba630e8a22140fffab8c956a3a2f9010224 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 08:06:23 +1100 Subject: [PATCH 03/10] Revert "Add ADL_Overdrive5_ThermalDevices_Enum interface." This reverts commit 1e1519e93ec6a3de432dd0b34504675f037c3542. --- adl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/adl.c b/adl.c index 5a19c741..278f4d05 100644 --- a/adl.c +++ b/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_ID_GET ADL_Adapter_ID_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_ODPARAMETERS_GET ADL_Overdrive5_ODParameters_Get; static ADL_OVERDRIVE5_FANSPEEDINFO_GET ADL_Overdrive5_FanSpeedInfo_Get; @@ -143,7 +142,6 @@ void init_adl(int nDevs) 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_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_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"); @@ -159,7 +157,7 @@ void init_adl(int nDevs) if (!ADL_Main_Control_Create || !ADL_Main_Control_Destroy || !ADL_Adapter_NumberOfAdapters_Get || !ADL_Adapter_AdapterInfo_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_FanSpeed_Get || !ADL_Overdrive5_FanSpeed_Set || !ADL_Overdrive5_ODPerformanceLevels_Get || !ADL_Overdrive5_ODPerformanceLevels_Set || From 5747b070de1470ae3a04f46e84b69ace9a1b09b5 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 08:07:12 +1100 Subject: [PATCH 04/10] Fix unused warning. --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index 0995172c..850fbfe3 100644 --- a/main.c +++ b/main.c @@ -997,11 +997,13 @@ static char *set_float_0_to_99(const char *arg, float *f) return NULL; } +#ifdef USE_BITFORCE static char *add_serial(char *arg) { string_elist_add(arg, &scan_devices); return NULL; } +#endif static char *set_devices(char *arg) { From f0746f0b4c198df48e5348c647f4987f1c639624 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 08:18:50 +1100 Subject: [PATCH 05/10] Display error codes should ADL not return ADL_OK in the more critical function calls. --- adl.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/adl.c b/adl.c index 278f4d05..0eadeab8 100644 --- a/adl.c +++ b/adl.c @@ -114,7 +114,7 @@ static bool fanspeed_twin(struct gpu_adl *ga, struct gpu_adl *other_ga) 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]; #if defined (LINUX) @@ -169,19 +169,22 @@ void init_adl(int nDevs) // Initialise ADL. The second parameter is 1, which means: // 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) { - applog(LOG_INFO, "ADL Initialisation Error!"); + result = ADL_Main_Control_Create (ADL_Main_Memory_Alloc, 1); + if (result != ADL_OK) { + applog(LOG_INFO, "ADL Initialisation Error! Error %d!", result); return ; } - if (ADL_Main_Control_Refresh() != ADL_OK) { - applog(LOG_INFO, "ADL Refresh Error!"); + result = ADL_Main_Control_Refresh(); + if (result != ADL_OK) { + applog(LOG_INFO, "ADL Refresh Error! Error %d!", result); return ; } // Obtain the number of adapters for the system - if (ADL_Adapter_NumberOfAdapters_Get ( &iNumberAdapters ) != ADL_OK) { - applog(LOG_INFO, "Cannot get the number of adapters!\n"); + result = ADL_Adapter_NumberOfAdapters_Get (&iNumberAdapters); + if (result != ADL_OK) { + applog(LOG_INFO, "Cannot get the number of adapters! Error %d!", result); return ; } @@ -191,8 +194,9 @@ void init_adl(int nDevs) lpInfo->iSize = sizeof(lpInfo); // Get the AdapterInfo structure for all adapters in the system - if (ADL_Adapter_AdapterInfo_Get (lpInfo, sizeof (AdapterInfo) * iNumberAdapters) != ADL_OK) { - applog(LOG_INFO, "ADL_Adapter_AdapterInfo_Get Error!"); + result = ADL_Adapter_AdapterInfo_Get (lpInfo, sizeof (AdapterInfo) * iNumberAdapters); + if (result != ADL_OK) { + applog(LOG_INFO, "ADL_Adapter_AdapterInfo_Get Error! Error %d", result); return ; } } else { @@ -207,8 +211,9 @@ void init_adl(int nDevs) 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"); + result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID); + if (result != ADL_OK) { + applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result); continue; } @@ -286,8 +291,9 @@ void init_adl(int nDevs) gpus[gpu].virtual_gpu = vadapters[gpu].virtual_gpu; /* 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"); + result = ADL_Adapter_ID_Get(iAdapterIndex, &lpAdapterID); + if (result != ADL_OK) { + applog(LOG_INFO, "Failed to ADL_Adapter_ID_Get. Error %d", result); continue; } From 891960389e90a1dce5416ed75eb7208c7cbf8ab4 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 09:15:20 +1100 Subject: [PATCH 06/10] Don't fail in the case the number of ADL and OpenCL devices do not match, and do not attempt to reorder devices unless they match. Instead give a warning about the likely cause and the potential consequence of it - Hardware monitoring may NOT match up with devices. --- adl.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/adl.c b/adl.c index 0eadeab8..156b0062 100644 --- a/adl.c +++ b/adl.c @@ -116,6 +116,7 @@ void init_adl(int nDevs) { int result, i, j, devices = 0, last_adapter = -1, gpu = 0, dummy = 0; struct gpu_adapters adapters[MAX_GPUDEVICES], vadapters[MAX_GPUDEVICES]; + bool devs_match = true; #if defined (LINUX) hDLL = dlopen( "libatiadlxx.so", RTLD_LAZY|RTLD_GLOBAL); @@ -248,8 +249,11 @@ void init_adl(int nDevs) * opencl enumerated devices and the ADL enumerated * ones, we have to assume they're in the same order.*/ if (++devices > nDevs) { - applog(LOG_ERR, "ADL found more devices than opencl"); - return; + applog(LOG_ERR, "ADL found more devices than opencl!"); + applog(LOG_ERR, "There is possibly at least one GPU that doesn't support OpenCL"); + devs_match = false; + devices = nDevs; + break; } last_adapter = lpAdapterID; @@ -259,24 +263,33 @@ void init_adl(int nDevs) } } - /* Windows has some kind of random ordering for bus number IDs and - * ordering the GPUs according to ascending order fixes it. Linux - * has usually sequential but decreasing order instead! */ - for (i = 0; i < devices; i++) { - int j, virtual_gpu = 0; + if (devs_match && devices == nDevs) { + /* Windows has some kind of random ordering for bus number IDs and + * ordering the GPUs according to ascending order fixes it. Linux + * has usually sequential but decreasing order instead! */ + for (i = 0; i < devices; i++) { + int j, virtual_gpu = 0; - for (j = 0; j < devices; j++) { - if (i == j) - continue; + for (j = 0; j < devices; j++) { + if (i == j) + continue; #ifdef WIN32 - if (adapters[j].iBusNumber < adapters[i].iBusNumber) + if (adapters[j].iBusNumber < adapters[i].iBusNumber) #else - if (adapters[j].iBusNumber > adapters[i].iBusNumber) + if (adapters[j].iBusNumber > adapters[i].iBusNumber) #endif - virtual_gpu++; + virtual_gpu++; + } + vadapters[virtual_gpu].virtual_gpu = i; + 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"); } - vadapters[virtual_gpu].virtual_gpu = i; - vadapters[virtual_gpu].id = adapters[i].id; + 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++) { From 176bbcbc797f434fac0d0addd74d0c5ace562f1e Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 09:44:19 +1100 Subject: [PATCH 07/10] Display GPU ordering remapping in verbose mode. --- adl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adl.c b/adl.c index 156b0062..3ea4a06b 100644 --- a/adl.c +++ b/adl.c @@ -280,6 +280,9 @@ void init_adl(int nDevs) #endif 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].id = adapters[i].id; } From a73156ac763f64a01d4247839bee187fe2d44923 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 10:02:51 +1100 Subject: [PATCH 08/10] Display GPU number and device name when ADL is successfully enabled on it. --- adl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/adl.c b/adl.c index 3ea4a06b..2d97a817 100644 --- a/adl.c +++ b/adl.c @@ -322,6 +322,7 @@ void init_adl(int nDevs) continue; } + applog(LOG_INFO, "GPU %d %s hardware monitoring enabled", gpu, lpInfo[i].strAdapterName); gpus[gpu].has_adl = true; /* Flag adl as active if any card is successfully activated */ adl_active = true; From 7bcda9a28fcaff801ed9ee9e0b6613cbdb3be646 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 12:42:43 +1100 Subject: [PATCH 09/10] Pass the correct GPU from the menu to the adl code. --- adl.c | 3 ++- adl.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/adl.c b/adl.c index 2d97a817..d7055759 100644 --- a/adl.c +++ b/adl.c @@ -1153,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; float fval, fmin = 0, fmax = 0; int val, imin = 0, imax = 0; diff --git a/adl.h b/adl.h index 50bd5b89..8e54983a 100644 --- a/adl.h +++ b/adl.h @@ -16,13 +16,13 @@ int gpu_fanspeed(int gpu); int gpu_fanpercent(int gpu); bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vddc, 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 clear_adl(int nDevs); #else /* HAVE_ADL */ #define adl_active (0) 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) {} #endif #endif From 09184720c293bbbef113cecfc829830a2a71f913 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 30 Jan 2012 15:09:58 +1100 Subject: [PATCH 10/10] As share submission is usually staggered, and delays can be costly, submit shares without delay even when --net-delay is enabled. --- main.c | 8 ++++---- miner.h | 2 +- util.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 850fbfe3..713253cc 100644 --- a/main.c +++ b/main.c @@ -2331,7 +2331,7 @@ static bool submit_upstream_work(const struct work *work) curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1); /* 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)) { applog(LOG_INFO, "submit_upstream_work json_rpc_call failed"); if (!pool_tset(pool, &pool->submit_fail)) { @@ -2482,7 +2482,7 @@ retry: * failure so retry a few times before giving up */ while (!val && retries++ < 3) { 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 (opt_debug) applog(LOG_DEBUG, "Donor pool lagging"); @@ -3993,7 +3993,7 @@ static bool pool_active(struct pool *pool, bool pinging) applog(LOG_INFO, "Testing pool %s", pool->rpc_url); val = json_rpc_call(curl, pool->rpc_url, pool->rpc_userpass, rpc_req, - true, false, &rolltime, pool); + true, false, &rolltime, pool, false); if (val) { struct work *work = make_work(); @@ -4721,7 +4721,7 @@ new_longpoll: while (1) { gettimeofday(&start, NULL); val = json_rpc_call(curl, lp_url, pool->rpc_userpass, rpc_req, - false, true, &rolltime, pool); + false, true, &rolltime, pool, false); if (likely(val)) { convert_to_work(val, rolltime, pool); failures = 0; diff --git a/miner.h b/miner.h index 47e773d8..8f4e0357 100644 --- a/miner.h +++ b/miner.h @@ -452,7 +452,7 @@ extern pthread_rwlock_t netacc_lock; extern const uint32_t sha256_init_state[]; extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass, 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 bool hex2bin(unsigned char *p, const char *hexstr, size_t len); diff --git a/util.c b/util.c index aab5070e..733d8ad3 100644 --- a/util.c +++ b/util.c @@ -305,7 +305,7 @@ static void set_nettime(void) json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass, const char *rpc_req, bool probe, bool longpoll, bool *rolltime, - struct pool *pool) + struct pool *pool, bool share) { json_t *val, *err_val, *res_val; 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_ENCODING, ""); 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_WRITEFUNCTION, all_data_cb); 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); - if (opt_delaynet) { + if (opt_delaynet && !share) { long long now_msecs, last_msecs; struct timeval now, last;