Skip to content

Commit 5bb6e22

Browse files
committed
GPU (Intel): read render engine temperature only
1 parent 9ea9291 commit 5bb6e22

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

src/detection/gpu/gpu_intel.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct FFIgclData {
1010
FF_LIBRARY_SYMBOL(ctlEnumerateDevices)
1111
FF_LIBRARY_SYMBOL(ctlGetDeviceProperties)
1212
FF_LIBRARY_SYMBOL(ctlEnumTemperatureSensors)
13-
FF_LIBRARY_SYMBOL(ctlTemperatureGetState)
13+
FF_LIBRARY_SYMBOL(ctlTemperatureGetProperties)
1414
FF_LIBRARY_SYMBOL(ctlEnumMemoryModules)
1515
FF_LIBRARY_SYMBOL(ctlMemoryGetProperties)
1616
FF_LIBRARY_SYMBOL(ctlMemoryGetState)
@@ -41,7 +41,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
4141
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumerateDevices)
4242
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlGetDeviceProperties)
4343
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumTemperatureSensors)
44-
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlTemperatureGetState)
44+
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlTemperatureGetProperties)
4545
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumMemoryModules)
4646
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlMemoryGetProperties)
4747
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlMemoryGetState)
@@ -204,19 +204,20 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
204204
uint32_t sensorCount = ARRAY_SIZE(sensors);
205205
if (igclData.ffctlEnumTemperatureSensors(device, &sensorCount, sensors) == CTL_RESULT_SUCCESS && sensorCount > 0)
206206
{
207-
double sumValue = 0;
208-
uint32_t availableCount = 0;
209207
for (uint32_t iSensor = 0; iSensor < sensorCount; iSensor++)
210208
{
211-
double value;
212-
if (igclData.ffctlTemperatureGetState(sensors[iSensor], &value) == CTL_RESULT_SUCCESS)
209+
ctl_temp_properties_t props = { .Size = sizeof(props) };
210+
// The official sample code does not set Version
211+
// https://github.com/intel/drivers.gpu.control-library/blob/1bbacbf3814f2fd0d2b930cdf42fad83f3628db9/Samples/Telemetry_Samples/Sample_TelemetryAPP.cpp#L256
212+
if (igclData.ffctlTemperatureGetProperties(sensors[iSensor], &props) == CTL_RESULT_SUCCESS)
213213
{
214-
sumValue += value;
215-
availableCount++;
214+
if (props.type == CTL_TEMP_SENSORS_GPU)
215+
{
216+
*result.temp = props.maxTemperature;
217+
break;
218+
}
216219
}
217220
}
218-
if (availableCount > 0)
219-
*result.temp = sumValue / availableCount;
220221
}
221222
}
222223

src/detection/gpu/igcl.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,28 @@ typedef struct ctl_temp_handle_t* ctl_temp_handle_t;
120120

121121
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#ctlenumtemperaturesensors
122122
extern ctl_result_t ctlEnumTemperatureSensors(ctl_device_adapter_handle_t hDAhandle, uint32_t* pCount, ctl_temp_handle_t* phTemperature);
123-
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#ctltemperaturegetstate
124-
extern ctl_result_t ctlTemperatureGetState(ctl_temp_handle_t hTemperature, double* pTemperature);
123+
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv427ctlTemperatureGetProperties17ctl_temp_handle_tP21ctl_temp_properties_t
124+
125+
typedef enum ctl_temp_sensors_t
126+
{
127+
CTL_TEMP_SENSORS_GLOBAL = 0,
128+
CTL_TEMP_SENSORS_GPU = 1,
129+
CTL_TEMP_SENSORS_MEMORY = 2,
130+
CTL_TEMP_SENSORS_GLOBAL_MIN = 3,
131+
CTL_TEMP_SENSORS_GPU_MIN = 4,
132+
CTL_TEMP_SENSORS_MEMORY_MIN = 5,
133+
CTL_TEMP_SENSORS_MAX
134+
} ctl_temp_sensors_t;
135+
136+
typedef struct _ctl_temp_properties_t
137+
{
138+
uint32_t Size;
139+
uint8_t Version;
140+
ctl_temp_sensors_t type;
141+
double maxTemperature;
142+
} ctl_temp_properties_t;
143+
144+
extern ctl_result_t ctlTemperatureGetProperties(ctl_temp_handle_t hTemperature, ctl_temp_properties_t* pTemperature);
125145
// https://intel.github.io/drivers.gpu.control-library/Control/api.html#_CPPv420ctlEnumMemoryModules27ctl_device_adapter_handle_tP8uint32_tP16ctl_mem_handle_t
126146

127147
typedef struct ctl_mem_handle_t* ctl_mem_handle_t;

0 commit comments

Comments
 (0)