GPU: support printing frequency in MHz

This commit is contained in:
李通洲
2024-07-17 14:52:35 +08:00
parent 46abc4f5f7
commit 408a2d731a
8 changed files with 14 additions and 15 deletions
+2 -2
View File
@@ -5,7 +5,7 @@
#define FF_GPU_TEMP_UNSET (0/0.0)
#define FF_GPU_CORE_COUNT_UNSET -1
#define FF_GPU_VMEM_SIZE_UNSET ((uint64_t)-1)
#define FF_GPU_FREQUENCY_UNSET (0/0.0)
#define FF_GPU_FREQUENCY_UNSET 0
extern const char* FF_GPU_VENDOR_NAME_APPLE;
extern const char* FF_GPU_VENDOR_NAME_AMD;
@@ -32,7 +32,7 @@ typedef struct FFGPUResult
FFstrbuf platformApi;
double temperature;
int32_t coreCount;
double frequency; // Maximum time clock frequency in GHz
uint32_t frequency; // Maximum time clock frequency in MHz
FFGPUMemory dedicated;
FFGPUMemory shared;
uint64_t deviceId; // Used internally, may be uninitialized
+1 -1
View File
@@ -60,7 +60,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
}
if (result.frequency)
*result.frequency = device->coreClock / 1000.; // Maximum frequency
*result.frequency = (uint32_t) device->coreClock; // Maximum frequency
if (result.type)
*result.type = device->isAPU ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE;
+1 -1
View File
@@ -41,7 +41,7 @@ typedef struct FFGpuDriverResult
FFGPUMemory* memory;
uint32_t* coreCount;
FFGPUType* type;
double* frequency;
uint32_t* frequency;
} FFGpuDriverResult;
const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResult result, const char* soName);
+1 -1
View File
@@ -191,7 +191,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
maxValue = props.max;
}
}
*result.frequency = maxValue / 1000;
*result.frequency = (uint32_t) (maxValue + 0.5);
}
}
+2 -2
View File
@@ -152,7 +152,7 @@ static void pciDetectIntelSpecific(FFGPUResult* gpu, FFstrbuf* pciDir, FFstrbuf*
ffStrbufAppendS(pciDir, "/gt_max_freq_mhz");
}
if (ffReadFileBuffer(pciDir->chars, buffer))
gpu->frequency = ffStrbufToDouble(buffer) / 1000.0;
gpu->frequency = (uint32_t) ffStrbufToUInt(buffer, 0);
}
static bool loadPciIds(FFstrbuf* pciids)
@@ -346,7 +346,7 @@ FF_MAYBE_UNUSED static const char* detectAsahi(FFlist* gpus, FFstrbuf* buffer, F
}) >= 0)
{
gpu->coreCount = (int) paramsGlobal.num_cores_total_active;
gpu->frequency = paramsGlobal.max_frequency_khz / 1e6;
gpu->frequency = paramsGlobal.max_frequency_khz / 1000;
gpu->deviceId = paramsGlobal.chip_id;
}
}
+1 -5
View File
@@ -122,11 +122,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
nvmlData.ffnvmlDeviceGetNumGpuCores(device, result.coreCount);
if (result.frequency)
{
uint32_t clockMHz;
if (nvmlData.ffnvmlDeviceGetMaxClockInfo(device, NVML_CLOCK_GRAPHICS, &clockMHz) == NVML_SUCCESS)
*result.frequency = clockMHz / 1000.;
}
nvmlData.ffnvmlDeviceGetMaxClockInfo(device, NVML_CLOCK_GRAPHICS, result.frequency);
return NULL;
+1 -1
View File
@@ -116,7 +116,7 @@ static const char* openCLHandleData(OpenCLData* data, FFOpenCLResult* result)
{
cl_uint value;
if (data->ffclGetDeviceInfo(deviceID, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(value), &value, NULL) == CL_SUCCESS)
gpu->frequency = value / 1000.;
gpu->frequency = value;
}
{
+5 -2
View File
@@ -39,8 +39,11 @@ static void printGPUResult(FFGPUOptions* options, uint8_t index, const FFGPUResu
if(gpu->coreCount != FF_GPU_CORE_COUNT_UNSET)
ffStrbufAppendF(&output, " (%d)", gpu->coreCount);
if(gpu->frequency == gpu->frequency && gpu->frequency > 0 /* Inactive? */)
ffStrbufAppendF(&output, " @ %.2f GHz", gpu->frequency);
if(gpu->frequency > 0)
{
ffStrbufAppendS(&output, " @ ");
ffParseFrequency(gpu->frequency, &output);
}
if(gpu->temperature == gpu->temperature) //FF_GPU_TEMP_UNSET
{