|
本帖最后由 mdyblog 于 2022-8-31 16:59 编辑
IFEX %&CurFile%.LOG, LOGS * %&CurFile%.LOG
ENVI^ ForceLocal=1
CALC #&len0=1M
^SET#$ &buf=*%len0% 0
SET#$ &count=*8 0
SET-long count=%len0%
SET &RelationProcessorCore=0 //核心Core
SET &RelationNumaNode=1 //NUMA
SET &RelationCache=2 //CACHE
SET &RelationProcessorPackage=3 //物理CPU
CALC &&SZ1=%ptrlen%*2+8*2 //SYSTEM_LOGICAL_PROCESSOR_INFORMATION 0x20:0x18
SET &len=0
CALL $--ret:&&r --qd kernel32,GetLogicalProcessorInformation,*&buf,*&count
IFEX #%r%=1, SET?long count=&len //实际长度
CALC len=%len%
IFEX $%%
SET &i=%ptrlen%
SET &Core=0 //核心数
SET &CPUPak=0 //物理处理器封装个数,即俗称的“物理CPU数”。
SET &NUMA=0 //非均匀访存模块
SET &CACHE=0
SET &Relationship=-1
LOOP #%i%<%len%,
{*
^ENVI?int &buf=&&Relationship:%i%
IFEX #%Relationship%=%RelationProcessorCore%,
{ ^ENVI?ptr &buf=&&ProcessorMask:(%i%-%ptrlen%)
SET &k=0
LOOP #[ %k%<%ptrlen% & %ProcessorMask%<>0 ],
{*
CALC #&&b0=%ProcessorMask% & 1
CALC #&ProcessorMask=shr(%ProcessorMask%,1)
CALC #&k=%k% + 1
IFEX #%b0%=1, CALC Core=%Core%+1
}
}
IFEX #%Relationship%=%RelationNumaNode%, CALC NUMA=%NUMA%+1
IFEX #%Relationship%=%RelationProcessorPackage%, CALC CPUPak=%CPUPak%+1
CALC i=%i%+%SZ1%
}
MESS. 核心数(Core)=%Core% 物理CPU数(CPUPak)=%CPUPak% NUMA数(NUMA)=%NUMA%
|
|