wxinix 0 Posted November 8 I wonder if there is any existing Delphi library for setting E-Core and P-Core Affinity? Share this post Link to post
Anders Melander 1780 Posted November 8 https://github.com/graphics32/graphics32/blob/e38452f2eeb1dd234cf6dae91edee51488453602/Source/GR32_System.pas#L146 // Set process affinity to exclude efficiency cores function SetPerformanceAffinityMask(Force: boolean = False): boolean; procedure RestoreAffinityMask; 1 Share this post Link to post
DelphiUdIT 172 Posted November 8 (edited) I made some times ago this to retrive the p-core (I think is similar to that used in the post from @Anders Melander ) : use Windows.System.SystemInformation; //this come from WINMD (getit) //Result = 0 --> No Hybrid system //Result = -1 --> DIFFERENT RECORD LENGTH (API VERSION OLD OR NEW) //Result = -2 --> API Error //Result > 0 --> mask with Power Core (no more than 63 core, or the result type should be change) //Tested only with Intel x64 CPU (no Xeon, no Numa system) function GetCPUPowerArray: INT64; var CPUInfoSet: TArray<SYSTEM_CPU_SET_INFORMATION>; dwlengthsize: ULong; begin Result := 0; dwlengthsize := 0; setlength(CPUInfoSet, 0); GetSystemCpuSetInformation(nil, 0, dwlengthsize, 0, nil); if (dwlengthsize <= 0) then begin Result := -2; exit; end; if ((dwlengthsize mod sizeof(SYSTEM_CPU_SET_INFORMATION)) <> 0) then begin Result := -1; exit; end; setlength(CPUInfoSet, dwlengthsize div sizeof(SYSTEM_CPU_SET_INFORMATION)); GetSystemCpuSetInformation(@CPUInfoSet[0], dwlengthsize, dwlengthsize, 0, nil); for var i := Low(CpuInfoSet) to High(CpuInfoSet) do if (CpuInfoSet[i].CpuSet.EfficiencyClass > 0) and (i < (sizeof(INT64)*8 -1)) then begin Result := Result or (1 shl i); end; setlength(CPUInfoSet, 0); end; Edited November 9 by DelphiUdIT 1 Share this post Link to post