* temperature
*/
-/*
if (data.gpu_temp_disable == 0)
{
fprintf (out, "TEMP\t");
hc_thread_mutex_unlock (mux_adl);
}
-*/
#ifdef _WIN
fputc ('\r', out);
}
}
-/*
if (data.gpu_temp_disable == 0)
{
hc_thread_mutex_lock (mux_adl);
{
const int temperature = hm_get_temperature_with_device_id (i);
const int utilization = hm_get_utilization_with_device_id (i);
- const int fanspeed = hm_get_fanspeed_with_device_id (i);
+ const int fanspeed = hm_get_fanspeed_with_device_id (i);
- if (vendor_id == VENDOR_ID_AMD)
+ if (data.vendor_id == VENDOR_ID_AMD)
{
log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
}
- if (vendor_id == VENDOR_ID_NV)
+ if (data.vendor_id == VENDOR_ID_NV)
{
#ifdef LINUX
log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
hc_thread_mutex_unlock (mux_adl);
}
-*/
}
static void status_benchmark ()
uint remove_left = data.remove_timer;
uint status_left = data.status_timer;
+ // these variables are mainly used for fan control (AMD only)
+
int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
// temperature controller "loopback" values
uint sleep_time = 1;
if (data.runtime)
+ {
runtime_check = 1;
+ }
if (data.restore_timer)
+ {
restore_check = 1;
+ }
if ((data.remove == 1) && (data.hashlist_mode == HL_MODE_FILE))
+ {
remove_check = 1;
+ }
if (data.status == 1)
+ {
status_check = 1;
+ }
if (data.gpu_temp_disable == 0)
{
if (data.devices_status != STATUS_RUNNING) continue;
- /*
if (hwmon_check == 1)
{
hc_thread_mutex_lock (mux_adl);
const int gpu_temp_retain = data.gpu_temp_retain;
- if (gpu_temp_retain)
+ if (gpu_temp_retain) // VENDOR_ID_AMD implied
{
if (data.hm_device[i].fan_supported == 1)
{
if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1))
{
- hm_set_fanspeed_with_device_id (i, fan_speed_new);
+ hm_set_fanspeed_with_device_id_amd (i, fan_speed_new);
fan_speed_chgd[i] = 1;
}
hc_thread_mutex_unlock (mux_adl);
}
- */
if (restore_check == 1)
{
}
/**
- * main
+ * some further helper function
*/
-// temp ?
+// wrapper around mymalloc for ADL
+
void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
{
return mymalloc (iSize);
return collisions;
}
+/**
+ * main
+ */
+
int main (int argc, char **argv)
{
/**
else if (strcmp (CL_platform_vendor, CL_VENDOR_NV) == 0)
{
vendor_id = VENDOR_ID_NV;
+
+ // make sure that we do not directly control the fan for NVidia
+
+ gpu_temp_retain = 0;
+ data.gpu_temp_retain = gpu_temp_retain;
}
else
{
vendor_id = VENDOR_ID_UNKNOWN;
}
+ if (vendor_id == VENDOR_ID_UNKNOWN)
+ {
+ log_error ("Warning: unknown OpenCL vendor '%s' detected", CL_platform_vendor);
+
+ gpu_temp_disable = 1;
+ }
+
data.vendor_id = vendor_id;
/**
memset (hm_adapter_all, 0, sizeof (hm_adapter_all));
- /*
if (gpu_temp_disable == 0)
{
if (vendor_id == VENDOR_ID_NV)
#ifdef LINUX
if (hc_NVML_nvmlInit () == NVML_SUCCESS)
{
- HM_ADAPTER nvGPUHandle[DEVICES_MAX];
+ HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX];
- int tmp_in = hm_get_adapter_index (nvGPUHandle);
+ int tmp_in = hm_get_adapter_index_nv (nvGPUHandle);
int tmp_out = 0;
for (int i = 0; i < tmp_in; i++)
{
- hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
+ hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i];
}
hm_adapters_all = tmp_out;
{
unsigned int speed;
- if (nvmlDeviceGetFanSpeed (hm_adapter_all[i].adapter_index, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
+ if (nvmlDeviceGetFanSpeed (hm_adapter_all[i].adapter_index.nv, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
}
}
#endif
#ifdef WIN
if (NvAPI_Initialize () == NVAPI_OK)
{
- HM_ADAPTER nvGPUHandle[DEVICES_MAX];
+ HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX];
- int tmp_in = hm_get_adapter_index (nvGPUHandle);
+ int tmp_in = hm_get_adapter_index_nv (nvGPUHandle);
int tmp_out = 0;
for (int i = 0; i < tmp_in; i++)
{
- hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
+ hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i];
}
hm_adapters_all = tmp_out;
{
NvU32 speed;
- if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
+ if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index.nv, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
}
}
#endif
if (vendor_id == VENDOR_ID_AMD)
{
- HM_LIB hm_dll = hm_init ();
+ HM_LIB hm_dll = hm_init_amd ();
data.hm_dll = hm_dll;
int hm_adapters_num;
- if (get_adapters_num (hm_dll, &hm_adapters_num) != 0) return (-1);
+ if (get_adapters_num_amd (hm_dll, &hm_adapters_num) != 0) return (-1);
// adapter info
- LPAdapterInfo lpAdapterInfo = hm_get_adapter_info (hm_dll, hm_adapters_num);
+ LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_amd (hm_dll, hm_adapters_num);
if (lpAdapterInfo == NULL) return (-1);
// hm_get_opencl_busid_devid (hm_adapter_all, devices_all_cnt, devices_all);
- hm_get_adapter_index (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
+ hm_get_adapter_index_amd (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
hm_get_overdrive_version (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
hm_check_fanspeed_control (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
gpu_temp_abort = 0;
gpu_temp_retain = 0;
}
- */
/**
* enable custom signal handler(s)
}
/*
- * Temporary fix:
- * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
- * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
- * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem)
- * Driver / ADL bug?
- *
-
+ * Temporary fix:
+ * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
+ * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
+ * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem)
+ * Driver / ADL bug?
+ */
if (vendor_id == VENDOR_ID_AMD)
{
int ADL_rc = 0;
- if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK)
{
log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
// powertune set
ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
- if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index, &powertune)) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune)) != ADL_OK)
{
log_error ("ERROR: Failed to get current ADL PowerControl settings");
return (-1);
}
- if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, powertune.iMaxValue)) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, powertune.iMaxValue)) != ADL_OK)
{
log_error ("ERROR: Failed to set new ADL PowerControl values");
hc_thread_mutex_unlock (mux_adl);
}
}
- */
uint gpu_blocks_all = 0;
int gpu_temp_retain_set = 0;
- /*
if (gpu_temp_disable == 0)
{
- if (gpu_temp_retain != 0)
+ if (gpu_temp_retain != 0) // VENDOR_ID_AMD implied
{
hc_thread_mutex_lock (mux_adl);
uint cur_temp = 0;
uint default_temp = 0;
- int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index, (int *) &cur_temp, (int *) &default_temp);
+ int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, (int *) &cur_temp, (int *) &default_temp);
if (ADL_rc == ADL_OK)
{
hc_thread_mutex_unlock (mux_adl);
}
}
- */
/**
* Store original powercontrol/clocks settings, set overdrive 6 performance tuning settings
*/
- /*
- if (powertune_enable == 1)
+ if (powertune_enable == 1) // VENDOR_ID_AMD implied
{
hc_thread_mutex_lock (mux_adl);
int powertune_supported = 0;
- if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune_supported)) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune_supported)) != ADL_OK)
{
log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
- if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune)) == ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune)) == ADL_OK)
{
- ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &od_power_control_status[device_id]);
+ ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &od_power_control_status[device_id]);
}
if (ADL_rc != ADL_OK)
return (-1);
}
- if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index, powertune.iMaxValue)) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, powertune.iMaxValue)) != ADL_OK)
{
log_error ("ERROR: Failed to set new ADL PowerControl values");
od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2;
- if ((ADL_rc = hc_ADL_Overdrive_StateInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &od_clock_mem_status[device_id])) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive_StateInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &od_clock_mem_status[device_id])) != ADL_OK)
{
log_error ("ERROR: Failed to get ADL memory and engine clock frequency");
ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0};
- if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &caps)) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &caps)) != ADL_OK)
{
log_error ("ERROR: Failed to get ADL device capabilities");
performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max;
performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max;
- if ((ADL_rc = hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
+ if ((ADL_rc = hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
{
log_info ("ERROR: Failed to set ADL performance state");
hc_thread_mutex_unlock (mux_adl);
}
- */
}
data.gpu_blocks_all = gpu_blocks_all;
// reset default fan speed
-/*
if (gpu_temp_disable == 0)
{
- if (gpu_temp_retain != 0)
+ if (gpu_temp_retain != 0) // VENDOR_ID_AMD is implied here
{
hc_thread_mutex_lock (mux_adl);
if (fanspeed == -1) continue;
- int rc = hm_set_fanspeed_with_device_id (i, fanspeed);
+ int rc = hm_set_fanspeed_with_device_id_amd (i, fanspeed);
if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i);
}
// reset power tuning
- if (powertune_enable == 1)
+ if (powertune_enable == 1) // VENDOR_ID_AMD is implied here
{
hc_thread_mutex_lock (mux_adl);
int powertune_supported = 0;
- if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
+ if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK)
{
log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
{
// powercontrol settings
- if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, od_power_control_status[i])) != ADL_OK)
+ if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, od_power_control_status[i])) != ADL_OK)
{
log_info ("ERROR: Failed to restore the ADL PowerControl values");
performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[i].state.aLevels[0].iMemoryClock;
performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[i].state.aLevels[1].iMemoryClock;
- if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
+ if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
{
log_info ("ERROR: Failed to restore ADL performance state");
{
hc_ADL_Main_Control_Destroy (data.hm_dll);
- hm_close (data.hm_dll);
+ hm_close_amd (data.hm_dll);
}
}
-*/
// free memory