Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

Programmatically enable HyperThreding in the CMOS setup

miltonkb
Beginner
1,116 Views

Hi experts

forgive me if this is not the right forum.

I am looking for a way to programmatically enable/disable Hyperthreading in the CMOS setup. Since I have around 50 nodes, it would be easy if I could do it through a program and restart the machine. Do we have any assembly instruction or any Intel library which can be used for this? If there is not any, is it possible to use PORT address 70 and 71 to manipulate CMOS and modify the settings? I remember I manipulated CMOS settings by OUTing to Port address 70 and 71 long time back (for resetting system password).

Thanks in advance
Milton K Baby

0 Kudos
11 Replies
gaston-hillar
Valued Contributor I
1,116 Views
Quoting - Milton Kb

Hi experts

forgive me if this is not the right forum.

I am looking for a way to programmatically enable/disable Hyperthreading in the CMOS setup. Since I have around 50 nodes, it would be easy if I could do it through a program and restart the machine. Do we have any assembly instruction or any Intel library which can be used for this? If there is not any, is it possible to use PORT address 70 and 71 to manipulate CMOS and modify the settings? I remember I manipulated CMOS settings by OUTing to Port address 70 and 71 long time back (for resetting system password).

Thanks in advance
Milton K Baby


Hi Milton,

In which operating system are you working on? By the way, PORT 70 and 71 allowed access to the first 128 bytes of the CMOS Setup, and you need driver privileges to do that inmodern operating systems. That was possible in old DOStimes.
0 Kudos
miltonkb
Beginner
1,116 Views
Quoting - Gastn C. Hillar

Hi Milton,

In which operating system are you working on? By the way, PORT 70 and 71 allowed access to the first 128 bytes of the CMOS Setup, and you need driver privileges to do that inmodern operating systems. That was possible in old DOStimes.

Hi Gaston

Thanks for the response. I am working on Windows 2008.

Yes, I was aware that we cant access any hardware ports using OUT instruction in Windows OS as we were doing in DOS. I was sharing it as a pointer to get more info on the CMOS bit layout as a last option if there is no direct approch.

Thanks
Milton K Baby
0 Kudos
gaston-hillar
Valued Contributor I
1,116 Views
Quoting - Milton Kb

Hi Gaston

Thanks for the response. I am working on Windows 2008.

Yes, I was aware that we cant access any hardware ports using OUT instruction in Windows OS as we were doing in DOS. I was sharing it as a pointer to get more info on the CMOS bit layout as a last option if there is no direct approch.

Thanks
Milton K Baby

Hi Milton,

I don't know if a BIOS driver allows you to do that. However, perhaps this helps.
Yo can change the boot.ini to add different configurationsestablishinglimitsthe number of maximum logical cores in the [operating systems] section, adding the following to the end of each line that defines the OS.
To use just one core:
/NUMPROC=1

To use just two cores:
/NUMPROC=2

An so on:
/NUMPROC=4
/NUMPROC=8

This can help you. Because, you can make an application that changes the default value for the next reboot. And then, reboot the computer.

Please, take into account that you should be very careful when changing boot.ini.

0 Kudos
Om_S_Intel
Employee
1,116 Views

On Nehalem, if you boot the system where HT is enabled in the BIOS, then you can use OS boot options to control the number of CPUs.
Say we have 1 Nehalem chip with 8 logical cpus on 4 cores (so HT is enabled). If you use the OS boot options to reduce the number of CPUs to 4, then the behavior of the system will be the same as if you had disabled HT in the BIOS.
On windowsXP, you can edit the boot.ini file and add the option /numproc=4 to the boot command line.
On Vista, you may have to use the bcdedit command to change the boot options. For more on bcdedit, see http://technet.microsoft.com/en-us/library/cc721886.aspx
On linux you can use the maxcpus=4 boot option (for example, on my linux box (from /boot/grup/menu.lst)
kernel /boot/vmlinuz-2.6.16.60-0.21-smp root=/dev/disk/by-id/scsi-SATA_ST3500320AS_5QM22FZB-part2 vga=0x314 resume=/dev/sda3 splash=silent showopts maxcpus=4
More info on linux boot options is available at http://tldp.org/HOWTO/BootPrompt-HOWTO-3.html#ss3.4

So a sample session might look like:

1) boot with HT enabled
2) do whatever you need to do with all 8 logical threads
3) change the default boot option to allow only 4 cpus
4) reboot (note that the dashes below are supposed to be short dashes - not long dashes .
a. On windows: shutdown -r -t 0
b. On linux: shutdown r t 0 now
5) The system should come back up with only 1 logical cpu per core and it should behave the same as if you had disabled HT in the BIOS.
0 Kudos
miltonkb
Beginner
1,116 Views

On Nehalem, if you boot the system where HT is enabled in the BIOS, then you can use OS boot options to control the number of CPUs.
Say we have 1 Nehalem chip with 8 logical cpus on 4 cores (so HT is enabled). If you use the OS boot options to reduce the number of CPUs to 4, then the behavior of the system will be the same as if you had disabled HT in the BIOS.
On windowsXP, you can edit the boot.ini file and add the option /numproc=4 to the boot command line.
On Vista, you may have to use the bcdedit command to change the boot options. For more on bcdedit, see http://technet.microsoft.com/en-us/library/cc721886.aspx
On linux you can use the maxcpus=4 boot option (for example, on my linux box (from /boot/grup/menu.lst)
kernel /boot/vmlinuz-2.6.16.60-0.21-smp root=/dev/disk/by-id/scsi-SATA_ST3500320AS_5QM22FZB-part2 vga=0x314 resume=/dev/sda3 splash=silent showopts maxcpus=4
More info on linux boot options is available at http://tldp.org/HOWTO/BootPrompt-HOWTO-3.html#ss3.4

So a sample session might look like:

1) boot with HT enabled
2) do whatever you need to do with all 8 logical threads
3) change the default boot option to allow only 4 cpus
4) reboot (note that the dashes below are supposed to be short dashes - not long dashes .
a. On windows: shutdown -r -t 0
b. On linux: shutdown r t 0 now
5) The system should come back up with only 1 logical cpu per core and it should behave the same as if you had disabled HT in the BIOS.

Thank a lot Gastn and Om Sachan.

Definitely bcdedit is an option even though I am not sure if it will give the exact same behavior as we disable in the BIOS. Let us take the scenario where I have a quad core which implies 8 logical processors with HT enabled. I have two concerns here:

1) If I say 4 proc in boot.ini does it mean that OS will not consider the 4 HT provided logical processors and instead it will take the 4 physical cores?

Or is there a chance that OS will take the first 2 physical cores and its 2 HT enabled logical processors so that a total of 4 procs. But 2 are physical and 2 are logical here. Do you know if this can happen or not?

2) Suppose OS consider 4 physical cores only and not the logical ones. In this case, will these logical cores be completely turned off as in the case of disabling in BIOS? Or is there a chance that it will use power and it will contribute to the total heat generated and hence any possible impact on the performance?

Thanks in advance
Milton
0 Kudos
sfive
Beginner
1,116 Views
Quoting - Gastn C. Hillar

Hi Milton,

I don't know if a BIOS driver allows you to do that. However, perhaps this helps.
Yo can change the boot.ini to add different configurationsestablishinglimitsthe number of maximum logical cores in the [operating systems] section, adding the following to the end of each line that defines the OS.
To use just one core:
/NUMPROC=1

To use just two cores:
/NUMPROC=2

An so on:
/NUMPROC=4
/NUMPROC=8

This can help you. Because, you can make an application that changes the default value for the next reboot. And then, reboot the computer.

Please, take into account that you should be very careful when changing boot.ini.


Thanks it useful information...
0 Kudos
gaston-hillar
Valued Contributor I
1,116 Views
Quoting - Milton Kb

Thank a lot Gastn and Om Sachan.

Definitely bcdedit is an option even though I am not sure if it will give the exact same behavior as we disable in the BIOS. Let us take the scenario where I have a quad core which implies 8 logical processors with HT enabled. I have two concerns here:

1) If I say 4 proc in boot.ini does it mean that OS will not consider the 4 HT provided logical processors and instead it will take the 4 physical cores?

Or is there a chance that OS will take the first 2 physical cores and its 2 HT enabled logical processors so that a total of 4 procs. But 2 are physical and 2 are logical here. Do you know if this can happen or not?

2) Suppose OS consider 4 physical cores only and not the logical ones. In this case, will these logical cores be completely turned off as in the case of disabling in BIOS? Or is there a chance that it will use power and it will contribute to the total heat generated and hence any possible impact on the performance?

Thanks in advance
Milton

Hi Milton,

I cannot tell you exactly how the OS works. However, I can tell you about my experience in recent tests made with a Core i7. I had many applications using pipelines to scale up to 8 cores and I wanted to test Hyper-Threading: http://www.ddj.com/go-parallel/blog/archives/2009/04/intels_hyperthr.html

I ran the tests disabling HT and then leaving HT enabled and doing exactly the same changes in boot.ini. Then, I compared the results and disabling HT worked the same than specifying the number of cores in boot.ini.
I guess (I guess), the OS gives priority to the physical cores first when you limit then. However, be careful because I ran these tests in Windows 2008 Server, FreeBSD 7 and OpenSuse 11. I wanted to make an OS independent test.

You told you were working with Windows 2008 Server too. I tell you this because I believe Windows XP's maximum number of cores is 4.

I'm sure it will not use additional power, because the OS completely ignores the additional cores. I've tested that situation.

Hope it helps.

Cheers,

Gastn
0 Kudos
TimP
Honored Contributor III
1,116 Views
Unfortunately, the BIOS numbering of logicals on Intel platforms hasn't been totally consistent. In general, you must check for your system whether booting HT enabled with half the logicals enabled will in fact make all cores active.
As to the effect on power, the answer is correct, it doesn't matter whether the 2nd logical processor is turned off in BIOS or at OS boot time. As long as the OS scheduler never gives a task to the 2nd logical, it won't draw increased power and affect the Turbo operation, if you have enabled that.
If you build an application with Intel OpenMP, and set one of the OpenMP environment variable verbose options, such as KMP_AFFINITY=compact,0,verbose
you get a screen enumeration of how the OpenMP library sees your logical processes and the order it will use for thread to logical assignment. "compact" will pair up the logicals on each core, threads 0 and 1 being assigned to the same core,....
"scatter," with OMP_NUM_THREADS set to the number of cores, would pick out 1 logical from each core.
0 Kudos
miltonkb
Beginner
1,116 Views
Thank you Gastn for the response, it was really helpful, and Thank you Tim18 for the confirmation.

Milton K Baby.
0 Kudos
Thomas_W_Intel
Employee
1,116 Views
If you use the OS boot options to reduce the number of CPUs to 4, then the behavior of the system will be the same as if you had disabled HT in the BIOS.
Om,

This is not entirely true. There are some ressources in the Core that are partitioned when Hyper-Threading is enabled in the BIOS. These are load buffers, store buffers, re-order buffers, and small-page ITLB. You canfind this information in section 2.2.9 of the Intel 64 and IA-32 Architectures Optimization Reference Manual. Even when the OS uses only one hardware thread per core, these buffers will still remain partitioned.

For most tuning and optimizations, I agree that this difference is most likely not relevant. However, there are quite some developers around who optimize their code on a micro-architectural level and therefore might experience the difference.

Kind regards
Thomas

0 Kudos
TimP
Honored Contributor III
1,116 Views
Thanks for pointing out that reference. It will be useful next time we hear scorn from management about not seeing better results from Hyper-Threading. ITLB partitioning, along with increasing emphasis on multiple architecture code paths, would likely increase the importance of segregating hot and cold functions during link.
The "competitively-shared" resources are an important distinction from the NetBurst HT. Where Prescott allowed only 3 write combining buffers to be in use per logical processor, we now have at least 8 fill buffers available for demand sharing between logicals.
0 Kudos
Reply