Skip to content

Commit

Permalink
CPU (BSD): improve base freq detection
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Jan 13, 2025
1 parent ace336d commit 373b435
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/detection/cpu/cpu_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
CPU_SET(1, &currentCPU);
CPU_SET(2, &currentCPU);
cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(cpuset_t), &currentCPU);
ffCPUDetectSpeedByCpuid(cpu);
#endif

ffCPUDetectSpeedByCpuid(cpu);

uint32_t clockrate = (uint32_t) ffSysctlGetInt("hw.clockrate", 0);
if (clockrate > cpu->frequencyBase) cpu->frequencyBase = clockrate;
cpu->temperature = FF_CPU_TEMP_UNSET;
Expand Down
3 changes: 1 addition & 2 deletions src/detection/cpu/cpu_nbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
ffCPUDetectSpeedByCpuid(cpu);

uint32_t freq = (uint32_t) ffSysctlGetInt("machdep.cpu.frequency.target", 0);
if (freq > cpu->frequencyBase)
cpu->frequencyBase = freq;
if (freq > cpu->frequencyBase) cpu->frequencyBase = freq;

cpu->temperature = FF_CPU_TEMP_UNSET;

Expand Down
4 changes: 3 additions & 1 deletion src/detection/cpu/cpu_obsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)

ffCPUDetectSpeedByCpuid(cpu);

cpu->frequencyBase = (uint32_t) ffSysctlGetInt(CTL_HW, HW_CPUSPEED, 0);
uint32_t cpuspeed = (uint32_t) ffSysctlGetInt(CTL_HW, HW_CPUSPEED, 0);
if (cpuspeed > cpu->frequencyBase) cpu->frequencyBase = cpuspeed;

cpu->temperature = FF_CPU_TEMP_UNSET;
if (options->temp)
{
Expand Down

0 comments on commit 373b435

Please sign in to comment.