Community
cancel
Showing results for 
Search instead for 
Did you mean: 
rao
Beginner
241 Views

Enabling/disabling Hyperthreading?

I'm wondering if someone has answers to the following questions.

1. Is there some way to enable or disable hyperthreading, while the machine is running?
2. While the machine is runnng, is there a utility that tells me whether hyperthreading is on or off?

- Thanks,
- Rao.


0 Kudos
4 Replies
TimP
Black Belt
241 Views

In case these answer part of your question:
Not knowing whether you count reboot as "while machine is running," you can reboot with the number of processors set to number of physical cores. If your BIOS enumerates logical processors in the correct order, this will hide the additional hyperthreaded logical processors. This does not recover the ITLB used by those logical processors, but it is essentially the same in effect for dual core processors as disabling HT in BIOS.
The usual ways to see if hyperthreading is enabled are with the performance monitoring utilities, such as top or Windows Task Manager. In linux, you could check /proc/cpuinfo, where hyperthreaded logical CPUs are referred to as "siblings," but will appear only with HT enabled.
jimdempseyatthecove
Black Belt
241 Views

I would suggest the following:

Set the environment variable OMP_NUM_THREADS to the number of processor cores.

Depending on your operating system the OpenMP threads may be satisfactorily distributed amoung the processor cores.

If this is not satisfactory then augment OMP_NUM_THREADS by creating your own environment variable that specifies the processor affinities. e.g.

OMP_THREAD_AFFINITIES = 0 2

For this you will need to write an initialization routine (conditionaly compiled in when compiling for OpenMP) that checks for the presense of OMP_THREAD_AFFINITIES.
If present, then thread processor affinities are set to the order specified. You will have to specify what to do when OMP_NUM_THREADS is not equal to the list specified by OMP_THREAD_AFFINITIES. Example:

If OMP_NUM_THREADS .lt. list specified by OMP_THREAD_AFFINITIES then ignore excess entries in list.

If OMP_NUM_THREADS .gt. list specified by OMP_THREAD_AFFINITIES then:
a) Stop assigning affinities (remainder threads unassigned)
b) rewind list specified by OMP_THREAD_AFFINITIES and continue assigning affinities.

You may also want to consider having an entry in the list specified by OMP_THREAD_AFFINITIES indicating no preference.

OMP_THREAD_AFFINITIES = 0 2 ? 4

My preference was to use a script file as I have more complex requirements. My system has NUMA archetecture and I wanted to have much more control over the thread allocation. There are other issues that can be handled in the script file method over that which you can specify with environment variables (plus you are not cluttering up the environment variables). A sample of my script file follows:

============================================

! Threads=n
! Optional command. Must be in the range of 1 to number of processors
! This is used to specify the number of main level threads
! If not specified Threads defaults to the number of processors

Threads=4Optional argument restricting max number of main level threads

! Note, for SEV2 it is detrimental to performance to request more threads than what
! will be available at run time.


! Affinity=b
! Optional command.
! Must have T or F for True/False
! Default is T
! If present forces (True) or not (False) processor affinity to thread

Affinity=T

! BlockTime=n
! Optional command.
! Default = 0
! Maximum time in miliseconds to burn waiting for additional work
BlockTime=0

! Nested=b
! Optional command.
! Must have T or F for True/False
! Default is T
Nested=T

! Dynamic=b
! Optional command.
! Must have T or F for True/False
! Default is F
! True permits the runtime system to alter the number of threads
! between 1 and the number requested.
Dynamic=F

! Reserve=n
! Optional command.
! Default = 0
! Number of processors to reserve (beginning a 0) from thread
! assignments to tethers.
Reserve=0Optional argument, number of processors to reserve

! Bias=n
! Optional command.
! Used to specify number of threads that will receive preload weights
! If not specified the default is Bias=0
! If specified n must be in range of 0 to number of processors-1
! And the Bias=n line must be followed by n lines indicating processing
! weights.

Bias=3Optional argument supplying the number of preload weights
100
0
0

! Objects=n
! Optional section. (Currently not implimented)
! If not specified all Objects have same weighting for thread assignment.
! If specified n must be same as number of Objects in INGOSS.
! And the Objects=n line must be followed by n lines indicating processing
! weights and an optional number of second level threads to assign to Object.
!
! The format of the weights lines are:
! w
! or
! w,m
!
! If of form "w" then w is an arbitrary number indicating a relative number
! (to other weights) of processing load. And m is implicitly set to 1.
! You could specify for w a percent or mill rate. Or perhaps use a function
! based on the number of attachment points and/or control options 3DOF/6DOF, etc...
!
! If of form "w,m" then m must be in the range of 1 to number of processors
!
! Note, it is detrimental to performance to request more threads than what
! will be available at run time.

Objects=6
! Object 1 weight
0

! Object 2 weight
0

! Object 3 weight
0

! Object 4 weight
0

! Object 5 weight
0

! Object 6 weight
0

! Tethers=n
! Optional section.
! If not specified all Tethers have same weighting for thread assignment.
! If specified n must be same as number of Tethers in INGOSS.
! And the Tethers=n line must be followed by n lines indicating processing
! weights and an optional number of second level threads to assign to Tether.
!
! The format of the weights lines are
! w
! or
! w,d
! or
! w,d,p
!
! If of form "w" then w is an arbitrary number indicating a relative number
! (to other weights) of processing load. And m is implicitly set to 1.
! You could specify for w a percent or mill rate. Or perhaps use a function
! based on the number of beads and/or control options deployment, etc...
!
! If of form "w,d" then "d" is the number of ends with deployment (0:2)
! and if d=2 p assumes 2

! If of form "w,d,p" then "d" is the number of ends with deployment (0:2)
! and "p" is the number of partitions. p .ge. d
!
! Additional notes.
!
! For SEV2 configurations weights that work well are computed by
! w=number of beads (*1.2 if of t ype with deployment scenario)
! You may also want to factor in Aero, electro, etc...
!
Tethers=8
! Tether 1 weight (number of beads 100 * 120% DS1)
120,0,1

! Tether 2 weight (number of beads)
100,0,1

! Tether 3 weight (number of beads 100 * 120% DS1)
120,0,1

! Tether 4 weight (number of beads 100 * 120% DS1)
120,0,1

! Tether 5 weight (number of beads 100 * 120% DS1)
120,0,1

! Tether 6 weight (number of beads 2000)
2000,0,8

! Tether 7 weight (number of beads 2000 * 120% DS1)
2200,1,1

! Tether 8 weight (number of beads 250 * 120% DS1)
300,1,2

====================

Jim Dempsey

p__Rahul
Beginner
241 Views

How to identify hyperthreading is supported on intel processor on 64 bit os using c++?

p__Rahul
Beginner
241 Views

how to determine number number of logical processors per physical processor in 64 bit OS in  64 bit c++ application?

Reply