Preface Intel's hyper-threading technology allows two threads to be executed in parallel on one physical core, which in most cases can improve the utilization of hardware resources and enhance system performance. For CPU-intensive numerical programs, hyperthreading technology may cause overall program performance to degrade. For this reason, it is recommended to disable hyperthreading technology when executing OpenMP or MPI numerical programs. The following is a script found on github that dynamically turns on and off hyper-threading technology. The principle is to find the relationship between logical cores according to the /sys/devices/system/cpu/cpuX/topology/thread_siblings_list file, and then edit the /sys/devices/system/cpu/cpuX/online file to dynamically turn on and off hyper-threading technology. #!/bin/bash HYPERTHREADING=1 function toggleHyperThreading() { for CPU in /sys/devices/system/cpu/cpu[0-9]*; do CPUID=`basename $CPU | cut -b4-` echo -en "CPU: $CPUID\t" [ -e $CPU/online ] && echo "1" > $CPU/online THREAD1=`cat $CPU/topology/thread_siblings_list | cut -f1 -d,` if [ $CPUID = $THREAD1 ]; then echo "-> enable" [ -e $CPU/online ] && echo "1" > $CPU/online else if [ "$HYPERTHREADING" -eq "0" ]; then echo "-> disabled"; else echo "-> enabled"; fi echo "$HYPERTHREADING" > $CPU/online fi done } function enabled() { echo -en "Enabling HyperThreading\n" HYPERTHREADING=1 toggleHyperThreading } function disabled() { echo -en "Disabling HyperThreading\n" HYPERTHREADING=0 toggleHyperThreading } # ONLINE=$(cat /sys/devices/system/cpu/online) OFFLINE=$(cat /sys/devices/system/cpu/offline) echo "---------------------------------------------------" echo -en "CPU's online: $ONLINE\t CPU's offline: $OFFLINE\n" echo "---------------------------------------------------" while true; do read -p "Type in e to enable or d disable hyperThreading or q to quit [e/d/q] ?" ed case $ed in [Ee]* ) enabled; break;; [Dd]* ) disabled;exit;; [Qq]* ) exit;; * ) echo "Please answer e for enable or d for disable hyperThreading.";; esac done Remark:
refer to Disable / Enable HyperThreading cores on runtime – linux Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: MySql 8.0.11 installation and configuration tutorial
>>: Vue detailed introductory notes
Table of contents Implementing an irregular form ...
A brief description of environment variable confi...
Install fastdfs on Docker Mount directory -v /e/f...
First, open the virtual machine Open xshell5 to c...
System environment: Ubuntu 16.04LTS This article ...
Copy code The code is as follows: html { overflow...
Mainly used knowledge points: •css3 3d transforma...
Preface In the last issue, we explained LinearLay...
Application scenario 1: Domain name-based redirec...
Table of contents 1. substring() 2. substr() 3.in...
This article describes how to install mysql5.7.16...
Table of contents 1. Index Basics 1. Types of Ind...
introduction When I was learning more about datab...
Example source code: https://codepen.io/shadeed/p...
First, let's simulate the data coming from th...