Önceki cevap çok ilginç.
Biraz googling yaptıktan sonra bazı ilgili konular buldum:
Son bağlantıda, ana makinenizde çok sayıda fiziksel kimlik varsa python betiği çalışmaz. Sonunda farklı bir koşulla değiştirmeye çalıştım:
Değiştirme:
if p > 0:
için
if p % 2 == 1:
Ancak, önceki iletiye göre beklendiği gibi çalışmaz. Bu arada, daha kapsamlı bir şey yapabilirsiniz:
grep . /sys/devices/system/cpu/cpu{,1}?/topology/thread_siblings | tr : \\\t | sed -r 's,^,\s\s\s\s,'
ile:
for file in /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list; do echo -n "$file "; cat $file; done |sort -k2 -n
[...]
Hiper iş parçacığı olan birçok çekirdek ana bilgisayarda ilginç olan şey, mantıksal çekirdeklerin donanım üzerindeki dağılımıdır.
Örneğin, bilgisayarımdan birinde (48 mantıksal çekirdek, 2 fiziksel işlemci, 24 (12 * 2) 'gerçek çekirdek' (yani, 24 sanal çekirdek)):
for file in /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list; do echo -n "$file "; cat $file; done |sort -k2 -n
/sys/devices/system/cpu/cpu0/topology/thread_siblings_list 0,24
/sys/devices/system/cpu/cpu24/topology/thread_siblings_list 0,24
/sys/devices/system/cpu/cpu1/topology/thread_siblings_list 1,25
/sys/devices/system/cpu/cpu25/topology/thread_siblings_list 1,25
/sys/devices/system/cpu/cpu26/topology/thread_siblings_list 2,26
/sys/devices/system/cpu/cpu2/topology/thread_siblings_list 2,26
/sys/devices/system/cpu/cpu27/topology/thread_siblings_list 3,27
/sys/devices/system/cpu/cpu3/topology/thread_siblings_list 3,27
/sys/devices/system/cpu/cpu28/topology/thread_siblings_list 4,28
/sys/devices/system/cpu/cpu4/topology/thread_siblings_list 4,28
/sys/devices/system/cpu/cpu29/topology/thread_siblings_list 5,29
/sys/devices/system/cpu/cpu5/topology/thread_siblings_list 5,29
/sys/devices/system/cpu/cpu30/topology/thread_siblings_list 6,30
/sys/devices/system/cpu/cpu6/topology/thread_siblings_list 6,30
/sys/devices/system/cpu/cpu31/topology/thread_siblings_list 7,31
/sys/devices/system/cpu/cpu7/topology/thread_siblings_list 7,31
/sys/devices/system/cpu/cpu32/topology/thread_siblings_list 8,32
/sys/devices/system/cpu/cpu8/topology/thread_siblings_list 8,32
/sys/devices/system/cpu/cpu33/topology/thread_siblings_list 9,33
/sys/devices/system/cpu/cpu9/topology/thread_siblings_list 9,33
/sys/devices/system/cpu/cpu10/topology/thread_siblings_list 10,34
/sys/devices/system/cpu/cpu34/topology/thread_siblings_list 10,34
/sys/devices/system/cpu/cpu11/topology/thread_siblings_list 11,35
/sys/devices/system/cpu/cpu35/topology/thread_siblings_list 11,35
/sys/devices/system/cpu/cpu12/topology/thread_siblings_list 12,36
/sys/devices/system/cpu/cpu36/topology/thread_siblings_list 12,36
/sys/devices/system/cpu/cpu13/topology/thread_siblings_list 13,37
/sys/devices/system/cpu/cpu37/topology/thread_siblings_list 13,37
/sys/devices/system/cpu/cpu14/topology/thread_siblings_list 14,38
/sys/devices/system/cpu/cpu38/topology/thread_siblings_list 14,38
/sys/devices/system/cpu/cpu15/topology/thread_siblings_list 15,39
/sys/devices/system/cpu/cpu39/topology/thread_siblings_list 15,39
/sys/devices/system/cpu/cpu16/topology/thread_siblings_list 16,40
/sys/devices/system/cpu/cpu40/topology/thread_siblings_list 16,40
/sys/devices/system/cpu/cpu17/topology/thread_siblings_list 17,41
/sys/devices/system/cpu/cpu41/topology/thread_siblings_list 17,41
/sys/devices/system/cpu/cpu18/topology/thread_siblings_list 18,42
/sys/devices/system/cpu/cpu42/topology/thread_siblings_list 18,42
/sys/devices/system/cpu/cpu19/topology/thread_siblings_list 19,43
/sys/devices/system/cpu/cpu43/topology/thread_siblings_list 19,43
/sys/devices/system/cpu/cpu20/topology/thread_siblings_list 20,44
/sys/devices/system/cpu/cpu44/topology/thread_siblings_list 20,44
/sys/devices/system/cpu/cpu21/topology/thread_siblings_list 21,45
/sys/devices/system/cpu/cpu45/topology/thread_siblings_list 21,45
/sys/devices/system/cpu/cpu22/topology/thread_siblings_list 22,46
/sys/devices/system/cpu/cpu46/topology/thread_siblings_list 22,46
/sys/devices/system/cpu/cpu23/topology/thread_siblings_list 23,47
/sys/devices/system/cpu/cpu47/topology/thread_siblings_list 23,47
Yani cpu0 ve cpu24 aynı fiziksel donanım "adresini" paylaşır. CPU1 ve CPU25 için aynı şey ...
Bu nedenle, temel olarak, linux işletim sistemimden hyperthreading özelliğini devre dışı bırakmak istersem, '0' değerini cpu {24..47} / online ile
for fake_cpu in {24..47}; do echo 0 > /sys/devices/system/cpu/cpu$fake_cpu/online;done
Sistemimin çekirdekleri numaralandırmasının ne kadar ilginç olduğunu göreceksiniz.
ht
Etkin veya değil değilse - bayrak sadece çoklu iş parçacığı (HTT) CPU tarafından desteklendiğini göstermektedir. O zaman bile, her zaman güvenilemez, örneğin, i5 i5-6500'ün HTT'yi desteklediğini yanlış bir şekilde gösterir: ark.intel.com/content/www/us/en/ark/products/88184/…